Simplify code and thereby fix graphical countdown, refs #30

This commit is contained in:
Olaf Leidinger 2017-11-03 20:32:15 +01:00
parent 6ef7a90cd3
commit da179b23ac

View File

@ -60,17 +60,14 @@ const TwoColorIcon = new Lang.Class({
cr.save(); cr.save();
// layout object in box let object_longest_edge = Math.max(orWdt, orHgt);
if (orWdt/orHgt > width/height) { let surface_shortest_edge = Math.min(width, height);
// take full width and center vertically let scaling = surface_shortest_edge / object_longest_edge;
cr.translate(0, height * 0.5); let padding_x = (width - orWdt * scaling)*0.5;
cr.scale(width/orWdt, width/orWdt); let padding_y = (height - orHgt * scaling)*0.5;
cr.translate(0, (height*width/orWdt - orHgt) * 0.5);
} else { cr.translate(padding_x, padding_y);
cr.translate(width * 0.5, 0); cr.scale(scaling, scaling);
cr.scale(height/orHgt, height/orHgt);
cr.translate((width*height/orHgt - orWdt) * 0.5, 0);
}
this._drawingObject.draw(cr, this._customStatus, this._primaryColor, this._secundaryColor); this._drawingObject.draw(cr, this._customStatus, this._primaryColor, this._secundaryColor);
@ -145,5 +142,6 @@ const Pie = {
cr.moveTo(0, 0); cr.moveTo(0, 0);
cr.arc(0, 0, r, 3 / 2 * pi, 3 / 2 * pi + 2 * pi * stat); cr.arc(0, 0, r, 3 / 2 * pi, 3 / 2 * pi + 2 * pi * stat);
cr.fill(); cr.fill();
cr.restore();
} // draw } // draw
}; // Pie }; // Pie