c# - Center drawn Ellipse origin -
i'm trying make simple animation circle expanding , fading away, problem have is expanding top left , want expand center, iv'e tried setting rendertransformorigin (0.5, 0.5) still don't works.
this code:
ellipse impact = new ellipse(); impact.width = 50; impact.height = 50; impact.strokethickness = 1.5f; impact.rendertransformorigin = new point(0.5, 0.5); maincanvas.children.add(impact); storyboard story = new storyboard(); doubleanimation anim = new doubleanimation(0, 60, timespan.fromseconds(0.9)); doubleanimation anim2 = new doubleanimation(0, 60, timespan.fromseconds(0.9)); doubleanimation anim3 = new doubleanimation(1, 0, timespan.fromseconds(0.9)); storyboard.settargetproperty(anim, new propertypath("(ellipse.height)")); storyboard.settargetproperty(anim2, new propertypath("(ellipse.width)")); storyboard.settargetproperty(anim3, new propertypath("(ellipse.opacity)")); story.children.add(anim); story.children.add(anim2); story.children.add(anim3); impact.beginstoryboard(story);
setting rendertransformorigin
property without setting rendertransform
has no effect.
what want animate path ellipsegeometry
instead of ellipse:
var impact = new path { data = new ellipsegeometry(new point(25, 25), 25, 25), strokethickness = 1.5, stroke = brushes.black }; maincanvas.children.add(impact); storyboard story = new storyboard(); doubleanimation anim1 = new doubleanimation(0, 30, timespan.fromseconds(0.9)); doubleanimation anim2 = new doubleanimation(0, 30, timespan.fromseconds(0.9)); doubleanimation anim3 = new doubleanimation(1, 0, timespan.fromseconds(0.9)); storyboard.settargetproperty(anim1, new propertypath("data.radiusx")); storyboard.settargetproperty(anim2, new propertypath("data.radiusy")); storyboard.settargetproperty(anim3, new propertypath("opacity")); story.children.add(anim1); story.children.add(anim2); story.children.add(anim3); impact.beginstoryboard(story);
you may adjust ellipsegoemetry's center , radius achieve desired effect. not clear why circle starts radius of 25, animated 0 30.
Comments
Post a Comment