Skip to content

Instantly share code, notes, and snippets.

@qtxie
Created January 29, 2021 08:29
Show Gist options
  • Save qtxie/9554322f7e90b60339048f9620f854f0 to your computer and use it in GitHub Desktop.
Save qtxie/9554322f7e90b60339048f9620f854f0 to your computer and use it in GitHub Desktop.
Red [Needs: View]
start?: no
total1: 0 total2: 0 total3: 0
n1: n2: n3: 0
NUM: 10
view [
b1: base 500x500 on-drawing [
unless start? [exit]
cmds: reduce ['pen red]
loop 10000 [
reduce/into ['line random 500x500 random 500x500] tail cmds
]
t: now/time/precise
system/view/platform/draw-face b1 cmds
total1: total1 + now/time/precise - t
n1: n1 + 1
if n1 = NUM [tx1/text: mold total1 / NUM n1: 0]
system/view/platform/redraw b2
]
b2: base 500x500 on-drawing [
unless start? [exit]
cmds: reduce ['pen green]
loop 10000 [
reduce/into ['circle random 500x500 random 300] tail cmds
]
t: now/time/precise
system/view/platform/draw-face b2 cmds
total2: total2 + now/time/precise - t
n2: n2 + 1
if n2 = NUM [tx2/text: mold total2 / NUM n2: 0]
system/view/platform/redraw b3
]
b3: base 500x500 on-drawing [
unless start? [exit]
cmds: reduce ['pen blue]
loop 10000 [
reduce/into ['triangle random 500x500 random 500x500 random 500x500] tail cmds
]
t: now/time/precise
system/view/platform/draw-face b3 cmds
total3: total3 + now/time/precise - t
n3: n3 + 1
either n3 = NUM [tx3/text: mold total3 / NUM n3: 0][
system/view/platform/redraw b1
]
]
return
tx1: base 200x25 "line" tx2: base 200x25 "circle" tx3: base 200x25 "triangle"
button "Start" [
start?: yes
total1: 0 total2: 0 total3: 0
n1: n2: n3: 0
system/view/platform/redraw b1
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment