Jump to content
Search Community

Morph svg on canvas in animate cc

eden test
Moderator Tag

Warning: Please note

This thread was started before GSAP 3 was released. Some information, especially the syntax, may be out of date for GSAP 3. Please see the GSAP 3 migration guide and release notes for more information about how to update the code to GSAP 3's syntax. 

Recommended Posts

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
Link to comment
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 ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...