Skip to content

Instantly share code, notes, and snippets.

@blad
Last active August 23, 2020 12:12
Show Gist options
  • Select an option

  • Save blad/bada86549b367cefd47fb82f8ac954c9 to your computer and use it in GitHub Desktop.

Select an option

Save blad/bada86549b367cefd47fb82f8ac954c9 to your computer and use it in GitHub Desktop.
Ronin: Black-Transparent-Mask
;; 1. Create Black-Transparent Mask from Black-White Image:
(open $path .15)
(defn bw-to-alpha
(p)
(p:0 p:1 p:2 (sub 255 p:0)))
(defn to-black-transparent
(pixel q)
(bw-to-alpha pixel))
(pixels to-black-transparent)
(def mask-layer (copy))
;; 2. Draw background and apply mask:
(def color-a "#72dec2")
(def color-b "#ffb545")
(def circles
(
(circle 180 96 6.40)
(circle 253 151 21.40)
(circle 207 208 29.53)
(circle 65 238 45.45)
(circle 144 395 30.41)
(circle 130 497 63.25)
(circle 257 478 41.68)
(circle 272 314 46.62)))
;; Draw Background: Gradient, Circles, Other Image, etc.
(fill
(get-frame)
(gradient
(line 385 519 167 190)
(color-a color-b)))
(each
circles
(λ (c)
(stroke (fill c color-a) color-b 20)))
;; Draw Mask on To Of Background:
(paste mask-layer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment