Skip to content
Permalink
Browse files

Add skeleton of Painter

  • Loading branch information
chobocho committed Nov 18, 2019
1 parent e2bb210 commit b725d797e04107d6427a405729c6947ec4281664
Showing with 48 additions and 1 deletion.
  1. +48 −1 doc/tutorial/003/src/painter.js
@@ -1,5 +1,50 @@
var cvs;
var canvas;
var painter;

function Point(x_, y_) {
this.x = x_;
this.y = y_;
}

Point.prototype.toString = function () {
return '(' + this.x + "," + this.y + ")";
}

function MouseAction(mouseUp, mouseDown, mouseMove) {
this.up = mouseUp;
this.down = mouseDown;
this.move = mouseMove;
}

function Shape(name_) {
this.name = name_;
this.point = new Point(0, 0);
this.color = 0;
this.state = 0;
this.filled = false;
this.mouseAction;
}

Shape.prototype.toString = function() {
return '(' +
'name:' + this.name + ' ' +
'Point:' + this.point.toString() +
'color:' + this.color + ' ' +
'state:' + this.state + ' ' +
'filled:' + this.filled + ' ' +
')';
}

function Painter() {
this.shape = new Shape("Point");
}

Painter.prototype.toString = function () {
return '(' +
'Shape:' + this.shape.toString() +
')';
}

function mouseListener(event) {
switch (event.type) {
@@ -26,6 +71,8 @@ function onLoadPage() {
canvas.addEventListener("mousemove", mouseListener);
canvas.addEventListener("mouseout", mouseListener);
canvas.addEventListener("mouseup", mouseListener);

painter = new Painter();
}

window.onload = onLoadPage();
window.onload = onLoadPage();

0 comments on commit b725d79

Please sign in to comment.
You can’t perform that action at this time.