USING: arrays kernel math prettyprint sequences ui.gadgets.worlds ui.gadgets.worlds.null opengl.gl ; IN: dragon : zig ( p1 p2 -- p1 pI p2 ) [ [ first2 ] bi@ [ [ rot swap + swap ] dip - + 2 / ] 4keep [ rot + swap ] dip + + 2 / 2array ] 2keep [ swap ] dip ; : zag ( p1 p2 -- p1 pA p2 ) [ [ first2 ] bi@ [ [ rot swap + swap ] dip + - 2 / ] 4keep [ rot swap - swap ] dip + + 2 / 2array ] 2keep [ swap ] dip ; : dragon' ( p1 p2 p3 d -- seq ) dup zero? [ 2drop 2array ] [ 1 - swap dupd swap [ dupd swap ] 2dip ! p1 p2 d p2 p3 d [ zig ] 4dip [ zag ] dip ! p1 pI p2 d p2 pA p3 d [ dragon' ] 4dip dragon' ! p1 pI p2 d dragon' / p2 pA p3 d dragon' append ] if ; : dragon ( -- x ) "dragon" null-window [ GL_LINE_STRIP glBegin 100 200 [ dup 2array ] bi@ zig 2 dragon' [ first2 glVertex2d ] each glEnd ] into-window ; MAIN: dragon