Raphael Cheat Sheet
Full Reference
x # x position y # x position r # radius w # width h # height rx # ellipse x-axis ry # ellipse y-axis # objects circle(x,y,r) rect(x, y, w, h, r) ellipse(x, y, rx, ry) image(url, x, y, w, h) text(x, y, str) # examples (run these in the blue console) circle(200,200,30).fill('darkorange') rect(300,200,30,120,5).fill('azure') ellipse(400, 120, 30, 90).fill('olivedrab') text(100,100,'hi earth').attr 'font-size': 14 'fill': 'tomato' # paths - use svg path string format path("M10 10L90 90") # sets st = set() st.push circle(30,50,10).fill('blue') st.push circle(50,90,10).fill('red') st.translate(50,50)
Color
# 12 colored bars
a = []
for i in [1..12]
a[i] = rect 40, 40*i, 200, 10
a[i].fill getColor()
Icons
# Display all iconts
i = 0
for key, value of icon
text(i, 200, key).stroke 'aliceblue'
path(value).translate(i, 230).stroke 'aliceblue'
i += 40
CoffeeScript Cheat Sheet
Full Reference
# assignment x = 4 # functions mult = (a,b) -> a*b # arrays list = [1,2,3,4,5] # objects sh = circ: (x,y) -> circle(x,y,15) sq: (x,y) -> rect(x,y,15,15) # new square at 75, 125 sh.sq(75,125) # array comprehensions circles = (sh.circ(25*x,200) for x in [1..10])
Math
sin pi/6 # 0.49999 ~ 1/2 acos 1/2 # 1.04719 ~ pi/3 random() # generate random number, 0-1 abs -5 # 5 pow(x,3) # x^3 floor 4.5 # 4 ceil 5.2 # 6
Connect Shapes
Original
# create a shape shape(x, y, width, height) link(int, int) # Example: Create three shapes. # Link 0 to 1, and 1 to 2 shape 50, 50, 10, 10 shape 200, 150, 40, 40 shape 400, 50, 30, 30 link 0, 1 link 1, 2 # Classy, takes an object and creates # a graphical interface for its properties classy(name, object, options) # Example: Classy classy 'My Object', f: (x) -> 2*x n: 5 str: "the quick brown fox" nan: NaN blah: {car: 'buggy', horn: 'french'} huh: [4,5,'pop','bug'] elem: $('body')[0] null: null