diff options
| author | Julie Lala <jules@okfoc.us> | 2014-04-15 20:15:31 -0400 |
|---|---|---|
| committer | Julie Lala <jules@okfoc.us> | 2014-04-15 20:15:31 -0400 |
| commit | 1e0cefea2daa2f757e9bd8c824c75b77c368ca07 (patch) | |
| tree | 265c3576590c267da3437d092569c2b442d2178f /assets/javascripts/rectangles/draw.js | |
| parent | 28da2a26238ff76f87f4e086a9832a5478c35b23 (diff) | |
| parent | 9c3c0151cb2b0a824f184501ea2672ef9e87a993 (diff) | |
merge
Diffstat (limited to 'assets/javascripts/rectangles/draw.js')
| -rw-r--r-- | assets/javascripts/rectangles/draw.js | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/assets/javascripts/rectangles/draw.js b/assets/javascripts/rectangles/draw.js new file mode 100644 index 0000000..560c281 --- /dev/null +++ b/assets/javascripts/rectangles/draw.js @@ -0,0 +1,48 @@ +function clear_canvas(){ + ctx.fillStyle = "#fff" + ctx.fillRect(0,0,w,h) +} +function draw_ruler(){ + ctx.strokeStyle = "rgba(80,80,80,0.5)" + ctx.lineWidth = 1 + var len = 5 + for (var i = 0.5; i < w; i += 10) { + line(i, 0, i, len) + line(0, i, len, i) + } +} +function line (x,y,a,b,translation){ + if (translation) { + x += translation.a + a += translation.a + y += translation.b + b += translation.b + } + ctx.beginPath() + ctx.moveTo(x,y) + ctx.lineTo(a,b) + ctx.stroke() +} +function draw_regions(regions){ + for (var i = 0; i < regions.length; i++) { + if (regions[i].dupe) continue + ctx.fillStyle = colors[i % colors.length] + regions[i].fill().stroke_sides() + } +} +function draw_mouse(mouse){ + ctx.fillStyle = "rgba(255,0,0,0.4)"; + ctx.beginPath(); + ctx.arc(mouse.x.b, mouse.y.b, 5, 0, 2*Math.PI, false); + ctx.fill(); + + if (mouse.width() != 0 && mouse.height() != 0) { + if (clipper.dragging) { + mouse.stroke() + } + else { + ctx.fillStyle = "rgba(255,255,0,0.5)" + mouse.clone().translate().fill() + } + } +} |
