Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: sky/examples/game/lib/node_with_size.dart

Issue 1218593002: Move sky/examples to sky/sdk/lib/example, and code changes to support that change. Fixes T277. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: sky/examples/game/lib/node_with_size.dart
diff --git a/sky/examples/game/lib/node_with_size.dart b/sky/examples/game/lib/node_with_size.dart
deleted file mode 100644
index 15503d26922b5394fb28884f3092de3c39d38f18..0000000000000000000000000000000000000000
--- a/sky/examples/game/lib/node_with_size.dart
+++ /dev/null
@@ -1,60 +0,0 @@
-part of sprites;
-
-/// The super class of any [Node] that has a size.
-///
-/// NodeWithSize adds the ability for a node to have a size and a pivot point.
-abstract class NodeWithSize extends Node {
-
- /// Changing the size will affect the size of the rendering of the node.
- ///
- /// myNode.size = new Size(1024.0, 1024.0);
- Size size;
-
- /// The normalized point which the node is transformed around.
- ///
- /// // Position myNode from is middle top
- /// myNode.pivot = new Point(0.5, 0.0);
- Point pivot;
-
- /// Creates a new NodeWithSize.
- ///
- /// The default [size] is zero and the default [pivot] point is the origin. Subclasses may change the default values.
- ///
- /// var myNodeWithSize = new NodeWithSize(new Size(1024.0, 1024.0));
- NodeWithSize([Size this.size, Point this.pivot]) {
- if (size == null) size = Size.zero;
- if (pivot == null) pivot = Point.origin;
- }
-
- /// Call this method in your [paint] method if you want the origin of your drawing to be the top left corner of the
- /// node's bounding box.
- ///
- /// If you use this method you will need to save and restore your canvas at the beginning and
- /// end of your [paint] method.
- ///
- /// void paint(RenderCanvas canvas) {
- /// canvas.save();
- /// applyTransformForPivot(canvas);
- ///
- /// // Do painting here
- ///
- /// canvas.restore();
- /// }
- void applyTransformForPivot(RenderCanvas 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);
- }
-}

Powered by Google App Engine
This is Rietveld 408576698