News for hackers. Stuff that matters.
Re:Formula for love: X^2+(y-sqrt(x^2))^2=1 by ehsanul on Tuesday February 15, 2011 @05:29AM (#2220778)
With bezier curves (it's prettier) in Canvas/Coffeescript (assuming an existing global canvas context 'ctx'):

    heart = (scale,x,y)->
      ctx.beginPath()
      ctx.moveTo(x,y)
      p1 = [x-75*scale,y+20*scale]
      ctx.bezierCurveTo(x-20*scale,y-55*scale,p1[0]-50*scale,p1[1]-55*scale,p1...)
      p2 = [x,p1[1]+60*scale]
      ctx.bezierCurveTo(p1[0]+25*scale,p1[1]+22.5*scale,p2[0]-35*scale,p2[1]-40*scale,p2...)

      ctx.moveTo(x,y)
      p1 = [x+75*scale,y+20*scale]
      ctx.bezierCurveTo(x+20*scale,y-55*scale,p1[0]+50*scale,p1[1]-55*scale,p1...)
      p2 = [x,p1[1]+60*scale]
      ctx.bezierCurveTo(p1[0]-25*scale,p1[1]+22.5*scale,p2[0]+35*scale,p2[1]-40*scale,p2...)

      ctx.strokeStyle = 'rgba(255,40,20,0.7)'
      ctx.stroke()
    
    heart(1.0, 450, 250)

There are no comments on this comment yet.