// widget_animaterotation.ysl2
template "widget[@type='AnimateRotation']", mode="widget_class"{
class AnimateRotationWidget extends Widget{
widget_center = undefined;
// change animation properties
for(let child of this.element.children){
if(child.nodeName == "animateTransform"){
child.setAttribute("dur", this.speed+"s");
child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
child.setAttribute("to", "360 "+this.widget_center[0]+" "+this.widget_center[1]);
child.setAttribute("dur", (-1)*this.speed+"s");
child.setAttribute("from", "360 "+this.widget_center[0]+" "+this.widget_center[1]);
child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
child.setAttribute("to", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
let widget_pos = this.element.getBBox();
this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)];
template "widget[@type='AnimateRotation']", mode="widget_defs" {