# magic-wallpaper.pf # aym3ric-at-goto10-dot-org # avoid taking acid in the toilets # # Example using colormapping and 2D grid load-opengl # load the OpenGl PF plugin 256 256 display # initialize a 512x512 window 2d # set the environment for 2D animation # start the drawing system "demo/stuff/interpol.pf" load "demo/stuff/multigrid.pf" load 0. variable! a 0. variable! b : background .1 .3 1. rgb 1. square ; # we generate a 1x1 16 steps grid = 256 X,Y coordinates 1 1 16 multigrid constant mygrid # we generate a blue gradient ( ((0. .1 .5) (0. .5 1.) 9 ) ((1. 1. 1.) (0. .5 1.) 10) ) interpol constant mypalette # the color function is a basic trig formula which result # is looked up in the colormap to determine the current color : newCOLOR unpack a @ 0.001 + dup a ! * cos dup b ! swap a @ * sin + 10. * >int abs 20 mod mypalette @color ; # the square's properties : drawSQUARE m-push dup newCOLOR unpack 2 vector trans a @ rotz b @ 0.1 * square m-pop ; # the animation function # for each step of the animation, we are drawing the background # then draw a square for each coordinates from the grid :: background mygrid ' drawSQUARE for-each ; is drawer ; interactive