// widget_circularbar.ysl2
template "widget[@type='CircularBar']", mode="widget_class"{
class CircularBarWidget extends Widget{
this.value_elt.textContent = String(value);
let [min,max,start,end] = this.range;
let [cx,cy] = this.center;
let [rx,ry] = this.proportions;
let tip = start + (end-start)*Number(value)/(max-min);
if (tip-start > Math.PI) {
this.path_elt.setAttribute('d', "M "+(cx+rx*Math.cos(start))+","+(cy+ry*Math.sin(start))+" A "+rx+","+ry+" 0 "+size+" 1 "+(cx+rx*Math.cos(tip))+","+(cy+ry*Math.sin(tip)));
let start = Number(this.path_elt.getAttribute('sodipodi:start'));
let end = Number(this.path_elt.getAttribute('sodipodi:end'));
let cx = Number(this.path_elt.getAttribute('sodipodi:cx'));
let cy = Number(this.path_elt.getAttribute('sodipodi:cy'));
let rx = Number(this.path_elt.getAttribute('sodipodi:rx'));
let ry = Number(this.path_elt.getAttribute('sodipodi:ry'));
Number(this.min_elt.textContent) :
this.args.length >= 1 ? this.args[0] : 0;
Number(this.max_elt.textContent) :
this.args.length >= 2 ? this.args[1] : 100;
this.range = [min, max, start, end];
this.proportions = [rx, ry];
template "widget[@type='CircularBar']", mode="widget_defs" {
optional_labels("value min max");