Skip to content

Instantly share code, notes, and snippets.

@blad
Last active August 22, 2020 20:43
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 blad/e014ad6cf48de4ad9aa8e98475660184 to your computer and use it in GitHub Desktop.
Save blad/e014ad6cf48de4ad9aa8e98475660184 to your computer and use it in GitHub Desktop.
Ronin: Petal Composite
(clear)
(def c:x 300)
(def c:y 300)
(def c:r 200)
(def petal-color (gradient (line 160 165 299 297) ("gold" "goldenrod")))
; Draw Background:
(fill (get-frame) (gradient (line 301 300 301 5) ("#333" "#222")))
(fill
(circle c:x c:y c:r) "#72dec2")
(defn draw-petal ()
(
(transform:push)
(transform:move 0
(sub 0 c:r))
; Arc Lower Petal
(fill
(arc c:x c:y 200
(rad 90)
(rad 150)) petal-color)
(transform:move
(sub 0 c:r) c:r)
; Arc Upper Petal
(fill
(arc c:x c:y 200
(rad 300)
(rad 360)) petal-color)
(transform:pop)
; Arc Matching Circle Radius
(fill
(arc c:x c:y 200
(rad 210)
(rad 240)) petal-color)
; Inner Petal Fill
(def d1
(mul c:r
(cos
(rad 30))))
(def d2
(mul c:r
(sin
(rad 30))))
(def y1
(sub c:y d2))
(def x1
(sub c:x d1))
(def x2
(sub c:x d2))
(def y2
(sub c:y d1))
(fill
(poly
(pos c:x c:y)
(pos x1 y1)
(pos x2 y2)) petal-color)
; Fill Borders Caused by Unexact Dimensions:
(stroke
(line x1 y1 c:x c:y) petal-color 1)
(stroke
(line x2 y2 c:x c:y) petal-color 1)
(stroke
(line x1 y1 x2 y2) petal-color 1)))
;; Draw Petals
(draw-petal)
(transform:move c:x c:y)
(transform:rotate (rad 90))
(transform:move (sub 0 c:x) (sub 0 c:y))
(draw-petal)
(transform:move c:x c:y)
(transform:rotate (rad 90))
(transform:move (sub 0 c:x) (sub 0 c:y))
(draw-petal)
(transform:move c:x c:y)
(transform:rotate (rad 90))
(transform:move (sub 0 c:x) (sub 0 c:y))
(draw-petal)
(transform:reset)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment