diff options
Diffstat (limited to 'mercurial/templates/static/mercurial.js')
-rw-r--r-- | mercurial/templates/static/mercurial.js | 57 |
1 files changed, 15 insertions, 42 deletions
diff --git a/mercurial/templates/static/mercurial.js b/mercurial/templates/static/mercurial.js index 70347d7..3bc27a4 100644 --- a/mercurial/templates/static/mercurial.js +++ b/mercurial/templates/static/mercurial.js @@ -58,44 +58,25 @@ function Graph() { // Set the colour. // - // If color is a string, expect an hexadecimal RGB - // value and apply it unchanged. If color is a number, - // pick a distinct colour based on an internal wheel; - // the bg parameter provides the value that should be - // assigned to the 'zero' colours and the fg parameter - // provides the multiplier that should be applied to - // the foreground colours. - var s; - if(typeof color == "string") { - s = "#" + color; - } else { //typeof color == "number" - color %= colors.length; - var red = (colors[color][0] * fg) || bg; - var green = (colors[color][1] * fg) || bg; - var blue = (colors[color][2] * fg) || bg; - red = Math.round(red * 255); - green = Math.round(green * 255); - blue = Math.round(blue * 255); - s = 'rgb(' + red + ', ' + green + ', ' + blue + ')'; - } + // Picks a distinct colour based on an internal wheel; the bg + // parameter provides the value that should be assigned to the 'zero' + // colours and the fg parameter provides the multiplier that should be + // applied to the foreground colours. + + color %= colors.length; + var red = (colors[color][0] * fg) || bg; + var green = (colors[color][1] * fg) || bg; + var blue = (colors[color][2] * fg) || bg; + red = Math.round(red * 255); + green = Math.round(green * 255); + blue = Math.round(blue * 255); + var s = 'rgb(' + red + ', ' + green + ', ' + blue + ')'; this.ctx.strokeStyle = s; this.ctx.fillStyle = s; return s; } - this.edge = function(x0, y0, x1, y1, color, width) { - - this.setColor(color, 0.0, 0.65); - if(width >= 0) - this.ctx.lineWidth = width; - this.ctx.beginPath(); - this.ctx.moveTo(x0, y0); - this.ctx.lineTo(x1, y1); - this.ctx.stroke(); - - } - this.render = function(data) { var backgrounds = ''; @@ -112,20 +93,13 @@ function Graph() { var edges = cur[2]; var fold = false; - var prevWidth = this.ctx.lineWidth; for (var j in edges) { line = edges[j]; start = line[0]; end = line[1]; color = line[2]; - var width = line[3]; - if(width < 0) - width = prevWidth; - var branchcolor = line[4]; - if(branchcolor) - color = branchcolor; - + if (end > this.columns || start > this.columns) { this.columns += 1; } @@ -139,10 +113,9 @@ function Graph() { x1 = this.cell[0] + this.box_size * end + this.box_size / 2; y1 = this.bg[1] + this.bg_height / 2; - this.edge(x0, y0, x1, y1, color, width); + this.edge(x0, y0, x1, y1, color); } - this.ctx.lineWidth = prevWidth; // Draw the revision node in the right column |