Skip to content

Instantly share code, notes, and snippets.

@toomasv
Last active March 16, 2019 22:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toomasv/70acbae8dc9d2511df319498592c7eed to your computer and use it in GitHub Desktop.
Save toomasv/70acbae8dc9d2511df319498592c7eed to your computer and use it in GitHub Desktop.
Study of freehand drawing on area
Red [
Author: "Toomas Vooglaid"
Date: 2018-12-09
Purpose: {Study of freehand drawing on area}
]
do load-thru https://tinyurl.com/ybmvx58e ; make-transparent
img: draw 200x200 [box 0x0 199x199]
img: make-transparent img 255
style: 'thin
view [
style btn: button 80
style clr: base 20x20 on-down [
body: body-of :im/actors/on-over
body/3/3/2/5/2: body/3/3/6/4: face/color
body/3/3/4/5/2: to-tuple append load replace/all form face/color dot space 150
]
ar: area 200x200 wrap all-over cursor I-beam focus
on-down [pos: event/offset]
below
at 10x10 im: image img 0.0.0.254 cursor cross all-over
on-dbl-click [set-focus ar]
on-over [if event/down? [
switch style [
thin [im/image: draw im/image compose [pen red line (pos) (event/offset)]]
thick [im/image: draw im/image compose [pen 255.0.0.150 line-width 10 line (pos) (event/offset)]]
dotted [poke im/image event/offset red]
]
] pos: event/offset]
btn "Clear" [
im/image: draw 200x200 [box 0x0 199x199]
im/image: make-transparent im/image 255
]
btn "Thin" [style: 'thin]
btn "Thick" [style: 'thick]
btn "Dotted" [style: 'dotted]
panel [origin 0x0
clr red clr blue clr green return
clr yellow clr black clr brown return
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment