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

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

Issue 1212073002: Improved documentation for SkyGames and support for rotated textures (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
« no previous file with comments | « sky/examples/game/lib/spritesheet.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/examples/game/lib/texture.dart
diff --git a/sky/examples/game/lib/texture.dart b/sky/examples/game/lib/texture.dart
index 684fdd2b3b66a15123c99e40af395cd7caa4617f..82c822a62cabc93b786fe3ffcb5deb7941f1f290 100644
--- a/sky/examples/game/lib/texture.dart
+++ b/sky/examples/game/lib/texture.dart
@@ -1,17 +1,56 @@
part of sprites;
+/// A texture represents a rectangular area of an image and is typically used to draw a sprite to the screen.
+///
+/// Normally you get a reference to a texture from a [SpriteSheet], but you can also create one from an [Image].
class Texture {
+ /// The image that this texture is a part of.
+ ///
+ /// var textureImage = myTexture.image;
final Image image;
+
+ /// The logical size of the texture, before being trimmed by the texture packer.
+ ///
+ /// var textureSize = myTexture.size;
final Size size;
+
+ /// The name of the image acts as a tag when acquiring a reference to it.
+ ///
+ /// myTexture.name = "new_texture_name";
String name;
+
+ /// The texture was rotated 90 degrees when being packed into a sprite sheet.
+ ///
+ /// if (myTexture.rotated) drawRotated();
final bool rotated;
+
+ /// The texture was trimmed when being packed into a sprite sheet.
+ ///
+ /// bool trimmed = myTexture.trimmed
final bool trimmed;
- Rect frame;
- Rect spriteSourceSize;
+ /// The frame of the trimmed texture inside the image.
+ ///
+ /// Rect frame = myTexture.frame;
+ final Rect frame;
+
+ /// The offset and size of the trimmed texture inside the image.
+ ///
+ /// Position represents the offset from the logical [size], the size of the rect represents the size of the trimmed
+ /// texture.
+ ///
+ /// Rect spriteSourceSize = myTexture.spriteSourceSize;
+ final Rect spriteSourceSize;
+ /// The default pivot point for this texture. When creating a [Sprite] from the texture, this is the pivot point that
+ /// will be used.
+ ///
+ /// myTexture.pivot = new Point(0.5, 0.5);
Point pivot;
+ /// Creates a new texture from an [Image] object.
+ ///
+ /// var myTexture = new Texture(myImage);
Texture(Image image) :
size = new Size(image.width.toDouble(), image.height.toDouble()),
image = image,
@@ -26,8 +65,9 @@ class Texture {
this.spriteSourceSize, this.pivot) {
}
- Texture textureFromRect(Rect rect, Point offset, bool rotated) {
- // TODO: Implement this
- return null;
- }
+// Texture textureFromRect(Rect rect, [String name = null]) {
+// assert(rect != null);
+// Rect frame = new Rect.fromLTRB();
+// return new Texture._fromSpriteFrame(image, name, rect.size, false, false, );
+// }
}
« no previous file with comments | « sky/examples/game/lib/spritesheet.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698