Jump to content
GreenSock

Search In
  • More options...
Find results that contain...
Find results in...
eden

Morph svg on canvas in animate cc

Recommended Posts

Hi

 

Ive just soaw new release of gsap, and update to morph svg to render mode to draw on canvas. This is wonderfull. Does that mean we can now morph shapes in animate cc as well ?

 

Best regards.

Share this post


Link to post
Share on other sites

Yes, just replace the canvas code in the draw function with the equivalent graphics code for easel.js. 

https://www.createjs.com/docs/easeljs/classes/Graphics.html

 

Although, I'm not sure if you can set an "evenodd" fill with easel.js.

 

TweenMax.to("#hippo", 2, {
	morphSVG:{
		shape:"#circle", 
		render:draw
	}
});

function draw(rawPath, target) {  
  var l, segment, j, i;
  ctx.clearRect(0, 0, vw, vh);
  ctx.beginPath();
  for (j = 0; j < rawPath.length; j++) {
    segment = rawPath[j];
    l = segment.length;
    ctx.moveTo(segment[0], segment[1]);
    for (i = 2; i < l; i+=6) {
      ctx.bezierCurveTo(segment[i], segment[i+1], segment[i+2], segment[i+3], segment[i+4], segment[i+5]);
    }
    if (segment.closed) {
      ctx.closePath();
    }
  }
  ctx.fill("evenodd");
}

 

  • Like 2

Share this post


Link to post
Share on other sites

Thank You for the reply.

 

Will try to do that. Seeing You sugested the draw by function, im asuming this will not work by simpy drawning a shape from animate interface and pas that as a variable to draw function, corect ?

Share this post


Link to post
Share on other sites

Correct. GSAP cannot animate the shape for you.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.

×