mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

Renames hitTest to isPointInside Refactor sorting of children in nodes Fixes zPosition in sprites and hides internal methods Adds scaleX / scaleY properties R=abarth@chromium.org Review URL: https://codereview.chromium.org/1190393004.
34 lines
863 B
Dart
34 lines
863 B
Dart
part of sprites;
|
|
|
|
abstract class NodeWithSize extends Node {
|
|
Size size;
|
|
Point pivot;
|
|
|
|
NodeWithSize() {
|
|
size = Size.zero;
|
|
pivot = Point.origin;
|
|
}
|
|
|
|
NodeWithSize.withSize(Size this.size, [Point this.pivot]) {
|
|
if (pivot == null) pivot = Point.origin;
|
|
}
|
|
|
|
void applyTransformForPivot(PictureRecorder canvas) {
|
|
if (pivot.x != 0 || pivot.y != 0) {
|
|
double pivotInPointsX = size.width * pivot.x;
|
|
double pivotInPointsY = size.height * pivot.y;
|
|
canvas.translate(-pivotInPointsX, -pivotInPointsY);
|
|
}
|
|
}
|
|
|
|
bool isPointInside (Point nodePoint) {
|
|
|
|
double minX = -size.width * pivot.x;
|
|
double minY = -size.height * pivot.y;
|
|
double maxX = minX + size.width;
|
|
double maxY = minY + size.height;
|
|
return (nodePoint.x >= minX && nodePoint.x < maxX &&
|
|
nodePoint.y >= minY && nodePoint.y < maxY);
|
|
}
|
|
}
|