svghmi/widget_circularbar.ysl2
changeset 3361 d955f2a3fabf
parent 3241 fe945f1f48b7
equal deleted inserted replaced
3360:746e3e3f6537 3361:d955f2a3fabf
     7     to value of the single accepted variable.
     7     to value of the single accepted variable.
     8 
     8 
     9     If "min" a "max" labeled texts are provided, then they are used as
     9     If "min" a "max" labeled texts are provided, then they are used as
    10     respective minimum and maximum value. Otherwise, value is expected to be
    10     respective minimum and maximum value. Otherwise, value is expected to be
    11     in between 0 and 100.
    11     in between 0 and 100.
    12 
       
    13     If "value" labeled text is found, then its content is replaced by value.
       
    14     ||
    12     ||
    15 
    13 
    16     shortdesc > Change end angle of Inkscape's arc
    14     shortdesc > Change end angle of Inkscape's arc
    17 
    15 
    18     // TODO: add min/max arguments
    16     arg name="min" count="optional" accepts="int,real" > minimum value
    19     // TODO: add printf-like format
    17     arg name="max" count="optional" accepts="int,real" > maximum value
    20 
    18 
    21     path name="value" accepts="HMI_INT,HMI_REAL" > Value to display
    19     path name="value" accepts="HMI_INT,HMI_REAL" > Value to display
    22     
    20     
    23 }
    21 }
    24 widget_class("CircularBar") {
    22 widget_class("CircularBar") {
    50                                             " 0 "+size+
    48                                             " 0 "+size+
    51                                             " 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip)));
    49                                             " 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip)));
    52         }
    50         }
    53 
    51 
    54         init() {
    52         init() {
       
    53             if(this.args.length >= 2)
       
    54                 [this.min, this.max]=this.args;
       
    55 
    55             let [start, end, cx, cy, rx, ry] = ["start", "end", "cx", "cy", "rx", "ry"].
    56             let [start, end, cx, cy, rx, ry] = ["start", "end", "cx", "cy", "rx", "ry"].
    56                 map(tag=>Number(this.path_elt.getAttribute('sodipodi:'+tag)))
    57                 map(tag=>Number(this.path_elt.getAttribute('sodipodi:'+tag)))
    57 
    58 
    58             if (ry == 0) 
    59             if (ry == 0) 
    59                 ry = rx;
    60                 ry = rx;
    72     ||
    73     ||
    73 }
    74 }
    74 
    75 
    75 widget_defs("CircularBar") {
    76 widget_defs("CircularBar") {
    76     labels("path");
    77     labels("path");
    77     optional_labels("value min max");
    78     optional_labels("min max");
    78 }
    79 }