/usr/share/shinken/htdocs/js/shinken-canvas.js is in shinken-module-broker-webui 1.4-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | // some classic Canvas operations
function draw_arc(ctx, x, y, radius, startAngle, endAngle, clockwise, color, lineWidth, alpha){
var saved_lineWidth = ctx.lineWidth;
var saved_color = ctx.strokeStyle;
var saved_alpha = ctx.globalAlpha;
if(typeof alpha != 'undefined'){
console.log('Set alpha to'+alpha);
ctx.globalAlpha = alpha;
}
ctx.strokeStyle = color;
ctx.lineWidth = lineWidth;
ctx.beginPath();
ctx.arc(x, y, radius, startAngle, endAngle, clockwise);
ctx.stroke();
ctx.strokeStyle = saved_color;
ctx.lineWidth = saved_lineWidth;
ctx.globalAlpha = saved_alpha;
}
function fill_arc(ctx, x, y, radius, startAngle, endAngle, clockwise, color){
var saved_color = ctx.fillStyle;
ctx.fillStyle = color;
ctx.beginPath();
ctx.arc(x, y, radius, startAngle, endAngle, clockwise);
ctx.fill();
ctx.fillStyle = saved_color;
}
function draw_line(ctx, x, y, x2, y2, color, lineWidth, alpha){
var saved_lineWidth = ctx.lineWidth;
var saved_color = ctx.strokeStyle;
var saved_alpha = ctx.globalAlpha;
if(typeof alpha != 'undefined'){
console.log('Set alpha to'+alpha);
ctx.globalAlpha = alpha;
}
ctx.strokeStyle = color;
ctx.lineWidth = lineWidth;
ctx.beginPath();
ctx.moveTo(x,y);
ctx.lineTo(x2, y2);
ctx.closePath();
ctx.stroke();
ctx.strokeStyle = saved_color;
ctx.lineWidth = saved_lineWidth;
ctx.globalAlpha = saved_alpha;
}
function fill_semi_elipse(ctx, cx, cy, r, color, clock){
var saved_color = ctx.fillStyle;
ctx.fillStyle = color;
ratio = 4;
cy *= ratio;
ctx.scale(1, 1/ratio);
ctx.beginPath();
ctx.arc(cx, cy, r, 0, Math.PI, clock);
ctx.fill();
ctx.fillStyle = saved_color;
ctx.closePath();
ctx.scale(1, ratio);
}
function draw_semi_elipse(ctx, cx, cy, r, color, clock){
var saved_color = ctx.strokeStyle;
ctx.strokeStyle = color;
ctx.lineWidth = 1;
ratio = 4;
cy *= ratio;
ctx.scale(1, 1/ratio);
ctx.beginPath();
ctx.arc(cx, cy, r, 0, Math.PI, clock);
ctx.stroke();
ctx.strokeStyle = saved_color;
ctx.closePath();
ctx.scale(1, ratio);
}
function draw_text_along_arc(ctx, str, centerX, centerY, radius, angle_offset, font, fillStyle, strokeStyle, lineWidth){
ctx.save();
var angle = Math.PI * 0.25;
ctx.font = font;
ctx.fillStyle = fillStyle;
ctx.strokeStyle = strokeStyle;
ctx.lineWidth = lineWidth;
ctx.translate(centerX, centerY);
ctx.rotate(-1 * angle / 2);
ctx.rotate(-1 * (angle / str.length) / 2);
ctx.rotate(angle_offset);
ctx.rotate((2*Math.PI) / 40);
for (var n = 0; n < str.length; n++) {
// We want a total round with 40chars
ctx.rotate((2*Math.PI) / 30);
//ctx.rotate(angle / str.length);
ctx.save();
ctx.translate(0, -1 * radius);
var char = str[n];
ctx.fillText(char, 0, 0);
ctx.restore();
}
ctx.restore();
}
|