when flag clicked pen up clear set DIMENSIONS to 2 set X to 0 set Y to 1 set FIRST to 0 set SECOND to 1 set MAX POINTS to 300 delete all of letter delete all of Control Point delete all of xy delete all of rhs delete all of tmp delete all of cpt repeat DIMENSIONS * MAX POINTS add "0" to letter add "0" to xy end repeat 2 * DIMENSIONS * MAX POINTS add "0" to Control Point end repeat MAX POINTS add "0" to rhs add "0" to tmp end repeat DIMENSIONS add "0" to cpt end New path point x: 40 y: 20 point x: 40 y: 220 point x: 112 y: 220 point x: 120 y: 20 point x: 40 y: 20 point x: 40 y: 220 Draw Curve 4 define-atomic New path set next letter index to 0 define-atomic point x: (x arg) y: (y arg) change next letter index by 1 replace item next letter index of letter with x arg change next letter index by 1 replace item next letter index of letter with y arg define-atomic getletter dim: (dim arg) index: (index) set gl_result to item (1 + index * 2 + dim arg) of letter define-atomic setletter dim: (dim arg) index: (index) val: (val) replace item 1 + index * 2 + dim arg of letter with val define-atomic getpt first second: (fs) dim: (dim arg) index: (index) set gp_result to item (1 + index * 4 + fs * 2 + dim arg) of Control Point define-atomic setpt first second: (fs) dim: (dim arg) index: (index) val: (val) replace item 1 + index * 4 + fs * 2 + dim arg of Control Point with val define-atomic getxy dim: (dim arg) index: (index) set gxy_result to item (1 + index * 2 + dim arg) of xy define-atomic setxy dim: (dim arg) index: (index) val: (val) replace item 1 + index * 2 + dim arg of xy with val define-atomic bezier (A) (B) (C) (D) (t) (max slots) _is a power 2 set 1 D: s to max slots - 1 - t set 1 D: AB to (A * 1 D: s + B * t) / max slots set 1 D: BC to (B * 1 D: s + C * t) / max slots set 1 D: CD to (C * 1 D: s + D * t) / max slots set 1 D: ABC to (1 D: AB * 1 D: s + 1 D: BC * t) / max slots set 1 D: BCD to (1 D: BC * 1 D: s + 1 D: CD * t) / max slots set 1 D Bezier delta to 1 D: ABC - 1 D: BCD set 1 D Bezier result to (1 D: ABC * 1 D: s + 1 D: BCD * t) / max slots define-atomic curve (p1) (p2) set step to 0 repeat 512 change step by 1 set dim to X repeat DIMENSIONS getletter dim: (dim) index: (p1) set t1 to gl_result getpt first second: (FIRST) dim: (dim) index: (p1) set t2 to gp_result getpt first second: (SECOND) dim: (dim) index: (p1) set t3 to gp_result getletter dim: (dim) index: (p2) set t4 to gl_result bezier (t1) (t2) (t3) (t4) (step) 512 _is a power 2 replace item 1 + dim of cpt with 1 D Bezier result change dim by 1 end go to x: item X of cpt y: item Y of cpt end define-atomic Draw Curve (Length) set n to Length - 1 if n > 0 then go to x: item 1 of letter y: item 2 of letter pen down set dim to X repeat DIMENSIONS set i to 1 repeat n - 2 getletter dim: (dim) index: (i) set t1 to gl_result getletter dim: (dim) index: (i + 1) set t2 to gl_result replace item 1 + i of rhs with 4 * t1 + 2 * t2 change i by 1 end getletter dim: (dim) index: 0 set t1 to gl_result getletter dim: (dim) index: 1 set t2 to gl_result replace item 1 + 0 of rhs with t1 + 2 * t2 getletter dim: (dim) index: (n - 1) set t1 to gl_result replace item 1 + (n - 1) of rhs with 3 * t1 set b to 2.0 setxy dim: (dim) index: 0 val: (item (1 + 0) of rhs / b) set i to 1 repeat n - 1 replace item 1 + i of tmp with 1 / b if i < n - 1 then set t1 to 4.0 else set t1 to 2.0 end set b to t1 - item (1 + i) of tmp getxy dim: (dim) index: (i - 1) set t1 to gxy_result setxy dim: (dim) index: (i) val: ((item (1 + i) of rhs - t1) / b) change i by 1 end set i to 1 repeat n - 1 getxy dim: (dim) index: (n - i - 1) set t1 to gxy_result getxy dim: (dim) index: (n - i) set t2 to gxy_result setxy dim: (dim) index: (n - i - 1) val: (t1 - item (1 + (n - i)) of tmp * t2) change i by 1 end change dim by 1 end set i to 0 repeat Length set dim to X repeat DIMENSIONS getxy dim: (dim) index: (i) set t1 to gxy_result setpt first second: (FIRST) dim: (dim) index: (i) val: (t1) if i < n - 1 then getletter dim: (dim) index: (i + 1) set t1 to gl_result getxy dim: (dim) index: (i + 1) set t2 to gxy_result set t3 to 2 * t1 - t2 else getletter dim: (dim) index: (n) set t1 to gl_result getxy dim: (dim) index: (n - 1) set t2 to gxy_result set t3 to (t1 + t2) / 2 end setpt first second: (SECOND) dim: (dim) index: (i) val: (t3) change dim by 1 end if i > 0 then curve (i - 1) (i) end change i by 1 end pen up end