coffeescript - chaining methods and properties in coffescript -
what best method dry out or chain code using coffeescript?
canvas=$('canvas') canvas.getcontext('2d').fillstyle='rgba(255,255,255,0.7)' canvas.getcontext('2d').font = "40px verdana" canvas.getcontext('2d').filltext('alkatsa.com',canvas.width/2 - 120,canvas.height - 50)
i believe there’s no chaining of properties, of methods. i’d make variables context, width , height. make code more vertical:
canvas = $ 'canvas' {width, height} = canvas context = canvas.getcontext '2d' context.fillstyle = 'rgba(255, 255, 255, 0.7)' context.font = '40px verdana' context.filltext 'example.com', width / 2 - 120, height - 50
Comments
Post a Comment