Last active
March 15, 2018 17:46
-
-
Save toomasv/8d297d6b65613c181be41fcf693e3655 to your computer and use it in GitHub Desktop.
Study of cubic bezier curve
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Red [ | |
Author: "Toomas Vooglaid" | |
Date: 2018-03-15 | |
Needs: 'View | |
] | |
system/view/auto-sync?: off | |
btw-points: func [pt1 pt2 rel][pt2 - pt1 * rel + pt1] | |
points: [50x200 70x100 180x100 200x200] | |
blk: copy [] i: -1 | |
foreach point points [ | |
append blk reduce [ | |
to-set-word rejoin ["lc" i: i + 1] 'circle point 2 | |
] | |
] | |
append blk compose [ | |
pen gray | |
l0: line (points) | |
pen green line-width 1 | |
l1: line | |
(p1: points/1) | |
(p2: points/2) | |
(p3: points/3) | |
c1: circle (p1) 1 c2: circle (p2) 1 c3: circle (p3) 1 | |
pen cyan | |
l2: line (p4: p1) (p5: p2) | |
c4: circle (p4) 1 c5: circle (p5) 1 | |
pen red line-width 2 | |
crv: curve (points/1) (points/1) (points/1) (points/1) | |
pen black fill-pen black line-width 1 | |
c6: circle (p6: p1) 2 | |
text 110x190 "t = " t: text 130x190 "" | |
] | |
tick: 0.0 | |
view/tight compose/deep/only append [ | |
bx: box 300x250 | |
rate 20 | |
on-time [ | |
tick: tick + 1 % 100 r: tick / 100 | |
l1/2: c1/2: btw-points points/1 points/2 r | |
l1/3: c2/2: btw-points points/2 points/3 r | |
l1/4: c3/2: btw-points points/3 points/4 r | |
l2/2: c4/2: btw-points l1/2 l1/3 r | |
l2/3: c5/2: btw-points l1/3 l1/4 r | |
c6/2: btw-points l2/2 l2/3 r | |
crv/2: points/1 crv/3: c1/2 crv/4: c4/2 crv/5: c6/2 | |
t/3: form r | |
show bx | |
] | |
draw (blk) | |
style ctr: box loose 0.0.0.254 9x9 | |
draw [fill-pen red pen red circle 4x4 2] | |
] collect [ | |
j: -1 | |
forall points [ | |
lc: to-word rejoin ["lc" j: j + 1] | |
keep reduce [ | |
'at points/1 - 4x4 'ctr | |
'on-drag compose [ | |
(to-set-path reduce ['points j + 1]) | |
(to-set-path reduce [lc 2]) | |
(to-set-path reduce ['l0 j + 2]) | |
face/offset + 4x4 | |
show bx | |
] | |
] | |
] | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment