Skip to main content
added 454 characters in body; edited body
Source Link
drxzcl
  • 1.8k
  • 15
  • 18

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patternsUpdate

I had completely forgotten about choose(). You couldIt is the missing piece you need to do the same for every scanline, but I'm afraid that it might bee too slowtransitions "properly". On the other hand, to mimic 8-bit era transition, that could be exactlyWhat you need is something like this:

diamonds = [ ... ] # List of arrays containing 1 and 2 arranged in enlarging diamond patterns, say 100x100
for diamond in diamonds: # you probably want timers and events rather than a tight loop
    for x in [0,100,200, ...]:
        for y in [0,100,200 ....]:
            screen[x:x+100, y:y+100] = diamond.choose(screen1[x:x+100,y:y+100], screen2[x:x+100,y:y+100])
    # Pause for transition effect
    time.sleep(0.01)

This should get you the required effect. Post if you are looking for!get into trouble.

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patterns. You could do the same for every scanline, but I'm afraid that it might bee too slow. On the other hand, to mimic 8-bit era transition, that could be exactly the effect you are looking for!

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

Update

I had completely forgotten about choose(). It is the missing piece you need to do the transitions "properly". What you need is something like this:

diamonds = [ ... ] # List of arrays containing 1 and 2 arranged in enlarging diamond patterns, say 100x100
for diamond in diamonds: # you probably want timers and events rather than a tight loop
    for x in [0,100,200, ...]:
        for y in [0,100,200 ....]:
            screen[x:x+100, y:y+100] = diamond.choose(screen1[x:x+100,y:y+100], screen2[x:x+100,y:y+100])
    # Pause for transition effect
    time.sleep(0.01)

This should get you the required effect. Post if you get into trouble.

added 156 characters in body
Source Link
drxzcl
  • 1.8k
  • 15
  • 18

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patterns. You could do the same for every scanline, but this should get you startedI'm afraid that it might bee too slow. On the other hand, to mimic 8-bit era transition, that could be exactly the effect you are looking for!

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patterns, but this should get you started.

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patterns. You could do the same for every scanline, but I'm afraid that it might bee too slow. On the other hand, to mimic 8-bit era transition, that could be exactly the effect you are looking for!

Source Link
drxzcl
  • 1.8k
  • 15
  • 18

You can easily do regular checkerboards by using numpy to copy parts of an image (array) onto another array, like this:

# Let's define two arrays to work on. They should be replaced with your surfaces
a = numpy.ones((640,480))
b = numpy.zeros((640,480))

a[100:110,200:210] = b[100:110, 200:210]

Obviously you can mix it up, copy from multiple sources and different locations if you need it for your effects. Since everything is handled by numpy (without coming back to python after every pixel) it is quite fast.

The only limitation is that the source and destination must be the same size (or obey the broadcasting rules, but that's not what you want here).

I'm not sure how to generalize this to diamond patterns, but this should get you started.