snowflake effects

This commit is contained in:
4am 2019-11-08 13:29:44 -05:00
parent 9a7b483769
commit 34f8a04e3b
11 changed files with 20291 additions and 17 deletions

View File

@ -1 +1 @@
RIPPLE STAR.IN SOFT.DIAGONAL STAGGERWHITE.UD RADIAL STAGGER.LR SOFT.UD HEART.IN CRYSTAL STAR.RIPPLE BIT.FIZZLE APPLE.IN MEETINTHEMIDDLE FLOWER.RAD.RIP SOFT.IRIS W.RIPPLE.BLOOM DIAGONAL MANDELBROT.IN CORNER.SUPERRIP STAR FLOWER.IN R.BY.PIXEL WAVY.IRIS APPLE SUNRISE MANDELBROT.RIP SOFT.L HEART.RIPPLE SUNSET FLOWER.RAD SLOW.STAR.IN IRIS.IN BUTTERFLYRIPPLE W.IRIS.BLOOM.IN CORNER.CIRCLE CENTER.BY.PIXEL FLOWER APPLE.RIPPLE DIAGONAL2 RIPPLE2 STAR.BLOOM PALETTE.FIZZLE RADIAL2 BUTTERFLY FLOWER.RIPPLE SPLIT.UD.INTRO WAVY.IRIS.IN R.BY.2 HALF.FIZZLE RADIAL3 HEART FLOWER.RAD.IN DIAGONAL3 MANDELBROT WAVY.RIPPLE CORNER4.OUT LATTICE BAR.DISSOLVE R.BY.PALETTE FOURSPIRAL SOFT.R IRIS CASCADE AND BUTTERFLY.IN CHECKERBOARD LR.BY.PIXEL RADIAL4 CHECKER.FIZZLE STAGGERWHITE.LR SOFT.UD.OUT ONESQUARE W.IRIS.BLOOM FIZZLE SLOW.STAR ARROW.WHITE TRI.FIZZLE SOFT.IRIS.IN DIAMOND TWOPASS.LR HALF.MOSAIC RADIAL5 ARROW FOURSQUARE BLOCK.FIZZLE DIAGONAL4 STAGGER.UD INTERLOCK.LR SOFT.UD.IN BLOCK.MOSAIC CORNER4.IN INTERLOCK.UD LITTLE.BOXES SPIRAL WAVY.CORNER [eof] # # transition effects for HGR slideshows # # Each Mega-Attract Module that is an HGR slideshow (see attract.conf) # will use a single transition effect for the length of the module. # Transition effects are loaded in the order listed in this file. Each line # of this file is a filename (not including comments, like this one). The # name of the next transition effect is stored in the global prefs, so this # file should not contain duplicates. # # Transition effects are binary files loaded at $6000 and called with # hi-res page 1 showing and the next HGR graphic already loaded at $4000. # A transition effect can use $6000-$BFFF in main memory, zero page, and # text page if needed (but preserve the screen holes). $800-$1FFF is reserved # for the slideshow data. LC RAM banks 1 and 2 are reserved for the launcher. # # Important: LC RAM bank 1 will be read/write on entry and must be read/write # on exit. If you need ROM routines, you are responsible for switching to ROM # then switching back to RAM bank 1 (read/write) before returning. #
RIPPLE STAR.IN SOFT.DIAGONAL STAGGERWHITE.UD RADIAL STAGGER.LR SOFT.UD HEART.IN CRYSTAL STAR.RIPPLE BIT.FIZZLE APPLE.IN MEETINTHEMIDDLE FLOWER.RAD.RIP SOFT.IRIS W.RIPPLE.BLOOM DIAGONAL MANDELBROT.IN CORNER.SUPERRIP STAR FLOWER.IN R.BY.PIXEL WAVY.IRIS APPLE SUNRISE MANDELBROT.RIP SOFT.L HEART.RIPPLE SUNSET FLOWER.RAD SLOW.STAR.IN IRIS.IN BUTTERFLYRIPPLE W.IRIS.BLOOM.IN CORNER.CIRCLE CENTER.BY.PIXEL SNOWFLAKE.IN FLOWER APPLE.RIPPLE DIAGONAL2 RIPPLE2 STAR.BLOOM PALETTE.FIZZLE RADIAL2 BUTTERFLY FLOWER.RIPPLE SPLIT.UD.INTRO WAVY.IRIS.IN R.BY.2 HALF.FIZZLE SNOWFLAKE.RIP RADIAL3 HEART FLOWER.RAD.IN DIAGONAL3 MANDELBROT WAVY.RIPPLE CORNER4.OUT LATTICE BAR.DISSOLVE R.BY.PALETTE FOURSPIRAL SOFT.R IRIS CASCADE SNOWFLAKE AND BUTTERFLY.IN CHECKERBOARD LR.BY.PIXEL RADIAL4 CHECKER.FIZZLE STAGGERWHITE.LR SOFT.UD.OUT ONESQUARE W.IRIS.BLOOM FIZZLE SLOW.STAR ARROW.WHITE TRI.FIZZLE SOFT.IRIS.IN DIAMOND TWOPASS.LR HALF.MOSAIC RADIAL5 ARROW FOURSQUARE BLOCK.FIZZLE DIAGONAL4 STAGGER.UD INTERLOCK.LR SOFT.UD.IN BLOCK.MOSAIC CORNER4.IN INTERLOCK.UD LITTLE.BOXES SPIRAL WAVY.CORNER [eof] # # transition effects for HGR slideshows # # Each Mega-Attract Module that is an HGR slideshow (see attract.conf) # will use a single transition effect for the length of the module. # Transition effects are loaded in the order listed in this file. Each line # of this file is a filename (not including comments, like this one). The # name of the next transition effect is stored in the global prefs, so this # file should not contain duplicates. # # Transition effects are binary files loaded at $6000 and called with # hi-res page 1 showing and the next HGR graphic already loaded at $4000. # A transition effect can use $6000-$BFFF in main memory, zero page, and # text page if needed (but preserve the screen holes). $800-$1FFF is reserved # for the slideshow data. LC RAM banks 1 and 2 are reserved for the launcher. # # Important: LC RAM bank 1 will be read/write on entry and must be read/write # on exit. If you need ROM routines, you are responsible for switching to ROM # then switching back to RAM bank 1 (read/write) before returning. #

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3
from math import sqrt, sin, cos, pi
import util
radius_x = 280//2
radius_y = 192//2
@ -20,20 +21,8 @@ for i in range(1000000):
continue
coords.append((x,y))
d = {}
unique_coords = []
for c in coords:
if not d.get(c):
unique_coords.append(c)
d[c] = 1
unique_vals = []
for x, y in unique_coords:
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
unique_coords = util.unique(coords)
unique_vals = util.vals_1bit(unique_coords)
with open("../../../src/fx/fx.hgr.iris.data.a", "w") as f:
for aval, bval in unique_vals:

View File

@ -0,0 +1,73 @@
#!/usr/bin/env python3
import PIL.Image # https://pillow.readthedocs.io/
import util
# snowflake.png is the source image. The source image MUST have a white background,
# but other colors and pixel depth are irrelevant. This one is black & white.
# Due to the Apple II pixel aspect ratio, we do a 1-time aspect-ratio-losing resize
# to squash the image to 87% height.
#
# $ gm convert snowflake.png -resize "100%x87%!" squash.png
# (Depending on your shell, you may need to escape the exclamation point. Grr.)
#
# Now we can create individual images for each "frame" of the animation, by
# resizing the (squashed) source image and putting it in a 280x192 frame.
#
# $ for w in `seq 1 500`; do \
# gm convert -size 280x192 squash.png \
# -resize "$w" \
# -background white \
# -compose Copy \
# -gravity center \
# -extent 280x192 thumb"$w".png; \
# done
#
# Depending on the source image, you may need more or fewer than 500 frames. This
# number is duplicated below in the |frames| variable. Sorry.
#
# Now we have 500 (or so) PNG images of what the HGR screen should look like at
# each stage. Despite each frame being 280x192 and in the correct aspect ratio,
# only coordinates
# - on every 3rd row
# - on even columns
# are included in the final data set.
#
# X coordinates are converted to byte+bitmask (but see notes below).
# Y coordinates are flipped (so 0,0 ends up on the bottom left) then
# divided by 3.
#
# 6502 code will be responsible for plotting each of these coordinates
# in a 2x3 block. The bitmask usually includes 2 adjacent pixels;
# the code will also plot the same 2 adjacent pixels in the next two rows.
#
# Unfortunately, since bytes are 7 pixels across, some of the 2-pixel-wide
# blocks will cross a byte boundary. To simplify the 6502 code, these are
# simply listed as separate coordinate pairs, each with a bitmask that
# includes 1 pixel instead of 2.
frames = 1000 # number of "thumbN.png" files
coords = []
for i in range(5, frames, 5):
p = PIL.Image.open("snowflake/thumb%s.png" % i)
for x in range(0, 280//2):
for y in range(0, 192//2, 2):
if p.getpixel((x,191-y))[0] != 255:
coords.append((x,y))
unique_coords = util.unique(coords)
unique_vals = util.vals_1bit(unique_coords)
with open("../../../src/fx/fx.hgr.snowflake.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
ripple_vals = util.ripple(unique_vals)
with open("../../../src/fx/fx.hgr.snowflake.ripple.data.a", "w") as f:
for aval, bval in ripple_vals:
f.write(" !byte %s,%s\n" % (aval, bval))
unique_vals.reverse()
with open("../../../src/fx/fx.hgr.snowflake.in.data.a", "w") as f:
for aval, bval in unique_vals:
f.write(" !byte %s,%s\n" % (aval, bval))

Binary file not shown.

After

Width:  |  Height:  |  Size: 308 KiB

View File

@ -7,9 +7,19 @@ def unique(coords):
d[c] = 1
return unique_coords
even_byte_bitmask = (0, 0, 1, 1, 2, 2, 3)
odd_byte_bitmask = (5, 5, 6, 6, 7, 7, 4)
def vals_1bit(unique_coords):
unique_vals = []
for x, y in unique_coords:
aval = "$" + hex(y)[2:].rjust(2, "0").upper()
bval = "%" + \
bin(x%7)[2:].rjust(3, "0") + \
bin(x//7)[2:].rjust(5, "0")
unique_vals.append((aval, bval))
return unique_vals
def vals_2bit(unique_coords):
even_byte_bitmask = (0, 0, 1, 1, 2, 2, 3)
odd_byte_bitmask = (5, 5, 6, 6, 7, 7, 4)
unique_vals = []
for x, y in unique_coords:
y = 191 - y

14
src/fx/fx.hgr.snowflake.a Normal file
View File

@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/SNOWFLAKE",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_PRECOMPUTED_1BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.snowflake.data.a"
!byte $80

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/SNOWFLAKE.IN",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_PRECOMPUTED_1BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.snowflake.in.data.a"
!byte $80

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
;license:MIT
;(c) 2019 by 4am
;
!cpu 6502
!to "build/FX/SNOWFLAKE.RIP",plain
*=$6000
!source "src/fx/fx.hgr.precomputed.1bit.a"
+FX_PRECOMPUTED_1BIT Coordinates
Coordinates
!source "src/fx/fx.hgr.snowflake.ripple.data.a"
!byte $80

File diff suppressed because it is too large Load Diff