( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( A simple drawing app using the canvas display ) ( ) ( This code was written by Charles Childers for use with Retro ) ( It is gifted to the public domain. In the event that your ) ( country does not allow a direct dedication to the public ) ( domain, the author voluntarily gives up all rights to the ) ( extent permitted by law. ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Array of colors, in the order we want them displayed ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) create colors ' black , ' white , ' blue , ' green , ' cyan , ' red , ' purple , ' brown , ' gray , ' darkgray , ' brightblue , ' brightgreen , ' brightcyan , ' brightred , ' magenta , ' yellow , ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Draw the menu of colors at the bottom ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) : (draw ( n- ) over 350 50 50 solidBox ; : advance) ( aa-aa ) swap 50 + swap ; : menu ( - ) 0 colors 16 for @+ execute (draw advance) next 2drop black 0 350 800 hline white 0 0 350 800 solidBox ; ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Handle clicks within the menu area ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Check to see if the click is within a given region) : region ( xul-f ) rot dup push >if pop class @ compile ; compiler: region: ( "- ) ` region -1 literal, ` =if ` drop ' compile 0 literal, ` ;; ` then ; : check ( -f ) mouse 350 >if dup 0 49 region: black dup 50 99 region: white dup 100 149 region: blue dup 150 199 region: green dup 200 249 region: cyan dup 250 299 region: red dup 300 349 region: purple dup 350 399 region: brown dup 400 449 region: gray dup 450 499 region: darkgray dup 500 549 region: brightblue dup 550 599 region: brightgreen dup 600 649 region: brightcyan dup 650 699 region: brightred dup 700 749 region: magenta dup 750 799 region: yellow then drop -1 ; ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( The main application loop ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) : (draw) click? 0; drop check 0; drop mouse pixel ; : draw clear menu black repeat (draw) again ; ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ( Set 'draw' to run on startup and save the image ) ( ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ) ' draw is boot save bye