Skip to content

Commit 17f7caf

Browse files
committed
Use properties instead of get[Property] and set[Property] in examples
1 parent 0221dd7 commit 17f7caf

12 files changed

Lines changed: 77 additions & 71 deletions

File tree

examples/Animated/animatedStar.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
var point = new Point(1024, 768).divide(2);
3030
for(var i = 0; i < 35; i++) {
3131
var vector = new Point(20 + 10 * i, 0).rotate(i * (360 / 35 * 2) * Math.sin(count / 150));
32-
var l = vector.getLength();
32+
var l = vector.length;
3333
var path = new Path();
3434
// path.strokeColor = '#000000';
3535
path.fillColor = i % 2 ? 'red' : 'black';

examples/Scripts/arcTo.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
var point = new Point(1024, 768).divide(2);
2323
for(var i = 0; i < 30; i++) {
2424
var vector = new Point(10 + 20 * i, 0).rotate(i);
25-
var l = vector.getLength();
25+
var l = vector.length;
2626
var path = new Path();
2727
path.fillColor = i % 2 ? 'red' : 'black';
2828
path.closed = true;

examples/Scripts/star.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
var point = new Point(1024, 768).divide(2);
2323
for(var i = 0; i < 30; i++) {
2424
var vector = new Point(1 + 10 * i, 0).rotate(i);
25-
var l = vector.getLength();
25+
var l = vector.length;
2626
var path = new Path();
2727
// path.strokeColor = '#000000';
2828
path.fillColor = i % 2 ? 'red' : 'black';

examples/Scripts/temp.html

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,21 @@
1818
var count = 0;
1919
var doc;
2020
window.onload = function() {
21-
var canvas = document.getElementById('canvas');
22-
doc = new Doc(canvas);
23-
var rect = new Rectangle([50, 50], [200, 100])
24-
var path = new Path.RoundRectangle(rect, 200);
25-
path.strokeColor = 'black';
26-
console.log(path);
27-
doc.children.push(path);
28-
29-
// var path = new Path.Rectangle(rect);
21+
var point = new Point(10, 0);
22+
point.length = 100;
23+
console.log(point);
24+
// var canvas = document.getElementById('canvas');
25+
// doc = new Doc(canvas);
26+
// var rect = new Rectangle([50, 50], [200, 100])
27+
// var path = new Path.RoundRectangle(rect, 200);
3028
// path.strokeColor = 'black';
29+
// console.log(path);
3130
// doc.children.push(path);
32-
doc.redraw();
31+
//
32+
// // var path = new Path.Rectangle(rect);
33+
// // path.strokeColor = 'black';
34+
// // doc.children.push(path);
35+
// doc.redraw();
3336
}
3437
</script>
3538
</head>

examples/Tools/Circles.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424

2525
var tool = new Tool({
2626
onMouseDrag: function(event) {
27-
if(event.getCount() != 1)
27+
if(event.count != 1)
2828
doc.children.pop();
29-
var distance = event.getDownPoint().subtract(event.getPoint()).getLength();
30-
var path = new Path.Circle(event.getDownPoint(), distance);
29+
var distance = event.downPoint.subtract(event.point).length;
30+
var path = new Path.Circle(event.downPoint, distance);
3131
path.strokeColor = 'black';
3232
path.fillColor = 'white';
3333
doc.children.push(path);
3434
}
3535
});
36-
tool.setDocument(doc);
36+
tool.document = doc;
3737
}
3838
</script>
3939
</head>

examples/Tools/Clouds.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,18 @@
2626
onMouseDown: function(event) {
2727
path = new Path();
2828
path.strokeColor = 'black';
29-
path.add(event.getPoint());
29+
path.strokeWidth = 5;
30+
path.strokeJoin = 'round';
31+
path.strokeCap = 'round';
32+
path.add(event.point);
3033
doc.children.push(path);
3134
},
3235
onMouseDrag: function(event) {
33-
path.arcTo(event.getPoint(), true);
36+
path.arcTo(event.point, true);
3437
}
3538
});
36-
tool.setDocument(doc);
37-
tool.setMinDistance(30);
39+
tool.document = doc;
40+
tool.minDistance = 30;
3841
}
3942
</script>
4043
</head>

examples/Tools/Dripping Brush.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
onMouseDrag: function(event) {
3434
// If the user dragged more then minSize:
35-
if (event.getDelta().getLength() > minSize) {
35+
if (event.delta.length > minSize) {
3636
// If there is no path, make one:
3737
if (!path) {
3838
path = new Path();
@@ -41,20 +41,20 @@
4141
doc.children.push(path);
4242
}
4343

44-
var step = event.getDelta().divide(2);
45-
step.setAngle(step.getAngle() + 90);
44+
var step = event.delta.divide(2);
45+
step.angle = step.angle + 90;
4646

4747
// The top point: the middle point + the step rotated by 90 degrees:
4848
// -----*
4949
// |
5050
// ------
51-
var top = event.getMiddlePoint().add(step);
51+
var top = event.middlePoint.add(step);
5252

5353
// The bottom point: the middle point - the step rotated by 90 degrees:
5454
// ------
5555
// |
5656
// -----*
57-
var bottom = event.getMiddlePoint().subtract(step);
57+
var bottom = event.middlePoint.subtract(step);
5858

5959
path.add(top);
6060
path.insert(0, bottom);
@@ -64,7 +64,7 @@
6464

6565
// If there is currently a path, close it
6666
if (path) {
67-
path.add(event.getPoint());
67+
path.add(event.point);
6868
path.closed = true;
6969
path.smooth();
7070

@@ -77,7 +77,7 @@
7777

7878
onMouseUp: function(event) {
7979
if (path) {
80-
path.add(event.getPoint());
80+
path.add(event.point);
8181
path.closed = true;
8282
path.smooth();
8383

@@ -88,8 +88,8 @@
8888
}
8989
});
9090

91-
tool.setDocument(doc);
92-
tool.setMaxDistance(20);
91+
tool.document = doc;
92+
tool.maxDistance = 20;
9393
}
9494
</script>
9595
</head>

examples/Tools/Fancy Brush.html

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -33,43 +33,43 @@
3333
var tool = new Tool({
3434
onMouseDown: function(event) {
3535
path = new Path();
36-
path.fillColor = event.getCount() % 2 ? 'red' : 'black';
36+
path.fillColor = event.count % 2 ? 'red' : 'black';
3737
doc.children.push(path);
3838
},
3939

4040
onMouseDrag: function(event) {
4141
// If this is the first drag event,
4242
// add the strokes at the start:
43-
if (event.getCount() == 1) {
44-
addStrokes(event.getMiddlePoint(), event.getDelta().multiply(-1));
43+
if (event.count == 1) {
44+
addStrokes(event.middlePoint, event.delta.multiply(-1));
4545
} else {
46-
var step = event.getDelta().divide(2);
47-
step.setAngle(step.getAngle() + 90);
46+
var step = event.delta.divide(2);
47+
step.angle = step.angle + 90;
4848

4949
// The top point: the middle point + the step rotated by 90 degrees:
5050
// -----*
5151
// |
5252
// ------
53-
var top = event.getMiddlePoint().add(step);
53+
var top = event.middlePoint.add(step);
5454

5555
// The bottom point: the middle point - the step rotated by 90 degrees:
5656
// ------
5757
// |
5858
// -----*
59-
var bottom = event.getMiddlePoint().subtract(step);
59+
var bottom = event.middlePoint.subtract(step);
6060

6161
path.add(top);
6262
path.insert(0, bottom);
6363
}
6464
path.smooth();
6565

66-
lastPoint = event.getMiddlePoint();
66+
lastPoint = event.middlePoint;
6767
},
6868

6969
onMouseUp: function(event) {
70-
var delta = event.getPoint().subtract(lastPoint);
71-
delta.setLength(tool.getMaxDistance());
72-
addStrokes(event.getPoint(), delta);
70+
var delta = event.point.subtract(lastPoint);
71+
delta.length = tool.maxDistance;
72+
addStrokes(event.point, delta);
7373
path.closed = true;
7474
path.smooth();
7575
}
@@ -91,9 +91,9 @@
9191
}
9292
}
9393

94-
tool.setDocument(doc);
95-
tool.setFixedDistance(40);
96-
// tool.setMinDistance(values.minDistance);
94+
tool.document = doc;
95+
tool.fixedDistance = 80;
96+
// tool.minDistance = values.minDistance;
9797
}
9898
</script>
9999
</head>

examples/Tools/Grid.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@
3333
var point, path;
3434
var tool = new Tool({
3535
onMouseDown: function(event) {
36-
point = getPos(event.getPoint());
36+
point = getPos(event.point);
3737
path = new Path();
3838
path.strokeColor = 'black';
3939
path.add(point);
4040
doc.children.push(path);
4141
},
4242
onMouseDrag: function(event) {
43-
var p = getPos(event.getPoint());
43+
var p = getPos(event.point);
4444
if (!point.equals(p)) {
4545
path.add(p);
4646
point = p;
4747
}
4848
}
4949
});
50-
tool.setDocument(doc);
50+
tool.document = doc;
5151
}
5252
</script>
5353
</head>

examples/Tools/MultiLines.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,20 @@
4141
},
4242

4343
onMouseDrag: function(event) {
44-
var offset = event.getDelta();
45-
offset.setAngle(offset.getAngle() + 90);
44+
var offset = event.delta;
45+
offset.angle = offset.angle + 90;
4646
var lineSize = values.size / values.lines;
4747
for (var i = 0; i < values.lines; i++) {
4848
var path = paths[values.lines - 1 - i];
49-
offset.setLength(lineSize * i + lineSize / 2);
50-
path.add(event.getMiddlePoint().add(offset));
51-
//path.insert(0, event.getMiddlePoint().subtract(offset));
49+
offset.length = lineSize * i + lineSize / 2;
50+
path.add(event.middlePoint.add(offset));
51+
//path.insert(0, event.middlePoint.subtract(offset));
5252
path.smooth();
5353
}
5454
}
5555
});
56-
tool.setDocument(doc);
57-
tool.setFixedDistance(30);
56+
tool.document = doc;
57+
tool.fixedDistance = 30;
5858
}
5959
</script>
6060
</head>

0 commit comments

Comments
 (0)