svghmi/widget_animaterotation.ysl2
branchsvghmi
changeset 3241 fe945f1f48b7
parent 3232 7bdb766c2a4d
equal deleted inserted replaced
3238:8a9d4c794cba 3241:fe945f1f48b7
     1 // widget_animaterotation.ysl2
     1 // widget_animaterotation.ysl2
       
     2 
       
     3 widget_desc("AnimateRotation") {
       
     4     longdesc
       
     5     ||
       
     6     AnimateRotation - DEPRECATED, do not use.
       
     7     Doesn't follow WYSIWYG principle, and forces user to add animateTransform tag in SVG (using inkscape XML editor for exemple)
       
     8     ||
       
     9 
       
    10     shortdesc > AnimateRotation - DEPRECATED
       
    11 
       
    12     path name="speed" accepts="HMI_INT,HMI_REAL" > speed
       
    13     
       
    14 }
     2 
    15 
     3 widget_class("AnimateRotation") {
    16 widget_class("AnimateRotation") {
     4     ||
    17     ||
     5         frequency = 5;
    18         frequency = 5;
     6         speed = 0;
    19         speed = 0;
    13             this.request_animate();
    26             this.request_animate();
    14         }
    27         }
    15 
    28 
    16         animate(){
    29         animate(){
    17            // change animation properties
    30            // change animation properties
       
    31            // TODO : rewrite with proper es6
    18            for(let child of this.element.children){
    32            for(let child of this.element.children){
    19                 if(child.nodeName == "animateTransform"){
    33                 if(child.nodeName == "animateTransform"){
    20                     if(this.speed > 0){
    34                     if(this.speed > 0){
    21                         child.setAttribute("dur", this.speed+"s");
    35                         child.setAttribute("dur", this.speed+"s");
    22                         child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
    36                         child.setAttribute("from", "0 "+this.widget_center[0]+" "+this.widget_center[1]);
    40             this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)];
    54             this.widget_center = [(widget_pos.x+widget_pos.width/2), (widget_pos.y+widget_pos.height/2)];
    41         }
    55         }
    42     ||
    56     ||
    43 }
    57 }
    44 
    58 
    45 
       
    46 widget_defs("AnimateRotation") {
       
    47     param "hmi_element";
       
    48     |,
       
    49 }