Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Application Scripts*/
- function init(){
- "use strict";
- var el = document.getElementById('myCanvas');
- var ctx = el.getContext('2d');
- var butLarge = document.getElementById('buttonLarge');
- var butSmall = document.getElementById('buttonSmall');
- el.width=window.innerWidth;
- el.height=window.innerHeight;
- ctx.lineWidth = 5;
- ctx.lineJoin = ctx.lineCap = 'round';
- ctx.shadowBlur = 3.5;
- ctx.shadowColor = 'rgb(0, 0, 0)';
- ctx.shadowOffsetX = (ctx.shadowOffsetX) *(.5);
- var isDrawing, points = [ ];
- el.onmousedown = function(e) {
- isDrawing = true;
- points.push({ x: e.clientX, y: e.clientY });
- };
- el.onmousemove = function(e) {
- if (!isDrawing) return;
- ctx.clearRect(0, 0, ctx.canvas.width, ctx.canvas.height);
- points.push({ x: e.clientX, y: e.clientY });
- ctx.beginPath();
- ctx.moveTo(points[0].x, points[0].y);
- ctx.lineTo(points[points.length-1].x, points[points.length-1].y); //draws line to last point
- ctx.stroke();
- };
- el.onmouseup = function() {
- isDrawing = false;
- points.length = 0;
- };
- function showCo_Ord(mm) {
- canvas_X = mm.pageX;
- canvas_Y = mm.pageY;
- window.alert("X : "+canvas_X+" Y : "+canvas_Y);
- }
- // a check to make sure that the program is responding
- butLarge.onmousedown = function() {
- ctx.lineWidth = ctx.lineWidth + 2;
- }
- butSmall.onmousedown = function() {
- ctx.lineWidth = ctx.lineWidth - 2;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement