Skip to content

Instantly share code, notes, and snippets.

@rebolek
Created February 26, 2018 10:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rebolek/4c12acd869a222ce07022c65f8383ba6 to your computer and use it in GitHub Desktop.
Save rebolek/4c12acd869a222ce07022c65f8383ba6 to your computer and use it in GitHub Desktop.
Experiment with live resizing of draw block
Red[]
month-font: make font! [size: 160]
day-font: make font! [size: 450]
name-font: make font! [size: 120]
center-text: func [
text
font
width
/local x-size
][
x-size: first size-text make face! compose [font: (make font []) size: (as-pair width 10000) text: (text)]
width - x-size / 2
]
resize: func [block coef /local rule][
parse block rule: [
some [
ahead block! into rule
| mark: pair! (mark/1: as-pair mark/1/x * coef mark/1/y * coef)
| mark: ['arc | 'circle] (mark/3: mark/3 * coef mark/4: mark/4 * coef)
| skip
]
]
block
]
resize-font: func [font coef][
make font [size: (to integer! coef * font/size)]
]
coef: 0.1
draw-calendar: func [coef][
day: form now/day
weekday: pick system/locale/days now/weekday
draw-block: compose/deep copy/deep [
shape [
pen off
fill-pen 221.47.69
line 50x0 950x0
arc 1000x50 50 50 90 sweep
line 1000x300 0x300 0x50
arc 50x0 50 50 90 sweep
]
shape [
fill-pen 224.231.236
line 0x300 1000x300 1000x950
arc 950x1000 50 50 90 sweep
line 50x1000
arc 0x950 50 50 90 sweep
line 0x300
]
fill-pen 224.231.236
circle 200x60 40 40
circle 800x60 40 40
; fill-pen 221.47.69
fill-pen 243.170.185
translate 750x160 [
circle 0x0 20 20
circle 70x0 20 20
circle 140x00 20 20
circle 0x70 20 20
circle 70x70 20 20
circle 140x70 20 20
]
pen 224.231.236
font (resize-font month-font coef)
text 30x80 (copy/part pick system/locale/months now/month 3)
pen 102.117.127
font (resize-font day-font coef)
text (as-pair center-text day day-font 1000 250) (day)
font (resize-font name-font coef)
text (as-pair center-text weekday name-font 1000 800) (weekday)
]
resize draw-block coef
]
view [
below
slider [cal/draw: draw-calendar max 0.1 face/data]
cal: base 1000x1000
on-create [
face/draw: draw-calendar coef
]
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment