OLD | NEW |
---|---|
(Empty) | |
1 part of sprites; | |
2 | |
3 abstract class NodeWithSize extends Node { | |
4 Size size; | |
5 Point pivot; | |
6 | |
7 NodeWithSize() { | |
8 size = new Size(0.0, 0.0); | |
9 pivot = new Point(0.0, 0.0); | |
abarth-chromium
2015/06/11 00:20:20
Size.zero
Point.origin
| |
10 } | |
11 | |
12 NodeWithSize.withSize(Size size, [Point pivot]); | |
13 | |
14 void applyTransformForPivot(PictureRecorder canvas) { | |
15 if (pivot.x != 0 || pivot.y != 0) { | |
16 double pivotInPointsX = size.width * pivot.x; | |
17 double pivotInPointsY = size.height * pivot.y; | |
18 canvas.translate(-pivotInPointsX, -pivotInPointsY); | |
19 } | |
20 } | |
21 | |
22 bool hitTest (Point nodePoint) { | |
23 | |
24 double minX = -size.width * pivot.x; | |
25 double minY = -size.height * pivot.y; | |
26 double maxX = minX + size.width; | |
27 double maxY = minY + size.height; | |
28 return (nodePoint.x >= minX && nodePoint.x < maxX && | |
29 nodePoint.y >= minY && nodePoint.y < maxY); | |
30 } | |
31 } | |
OLD | NEW |