Skip to content

Instantly share code, notes, and snippets.

@andrewliebchen
Created June 7, 2017 05:22
Show Gist options
  • Save andrewliebchen/d42d327da2d82ca65e9c6496aede79f1 to your computer and use it in GitHub Desktop.
Save andrewliebchen/d42d327da2d82ca65e9c6496aede79f1 to your computer and use it in GitHub Desktop.
Loops!
colors = [
'red'
'blue'
'yellow'
]
checks = []
samples = []
for color, i in colors
@check = new TextLayer
text: color
fontSize: 16
y: i * 20
fontWeight: 'normal'
checks.push @check
@sample = new Layer
size: 30
x: 100
y: i * 30
backgroundColor: color
opacity: 0.2
samples.push @sample
for check, i in checks
do (i) ->
check.onClick ->
@fontWeight = if @fontWeight is 'normal' then 'bold' else 'normal'
samples[i].opacity = if samples[i].opacity is 1 then 0.2 else 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment