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

Side by Side Diff: sky/examples/game/lib/texture.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 unified diff | Download patch
OLDNEW
(Empty)
1 part of sprites;
2
3 /// A texture represents a rectangular area of an image and is typically used to draw a sprite to the screen.
4 ///
5 /// Normally you get a reference to a texture from a [SpriteSheet], but you can also create one from an [Image].
6 class Texture {
7 /// The image that this texture is a part of.
8 ///
9 /// var textureImage = myTexture.image;
10 final Image image;
11
12 /// The logical size of the texture, before being trimmed by the texture packe r.
13 ///
14 /// var textureSize = myTexture.size;
15 final Size size;
16
17 /// The name of the image acts as a tag when acquiring a reference to it.
18 ///
19 /// myTexture.name = "new_texture_name";
20 String name;
21
22 /// The texture was rotated 90 degrees when being packed into a sprite sheet.
23 ///
24 /// if (myTexture.rotated) drawRotated();
25 final bool rotated;
26
27 /// The texture was trimmed when being packed into a sprite sheet.
28 ///
29 /// bool trimmed = myTexture.trimmed
30 final bool trimmed;
31
32 /// The frame of the trimmed texture inside the image.
33 ///
34 /// Rect frame = myTexture.frame;
35 final Rect frame;
36
37 /// The offset and size of the trimmed texture inside the image.
38 ///
39 /// Position represents the offset from the logical [size], the size of the re ct represents the size of the trimmed
40 /// texture.
41 ///
42 /// Rect spriteSourceSize = myTexture.spriteSourceSize;
43 final Rect spriteSourceSize;
44
45 /// The default pivot point for this texture. When creating a [Sprite] from th e texture, this is the pivot point that
46 /// will be used.
47 ///
48 /// myTexture.pivot = new Point(0.5, 0.5);
49 Point pivot;
50
51 /// Creates a new texture from an [Image] object.
52 ///
53 /// var myTexture = new Texture(myImage);
54 Texture(Image image) :
55 size = new Size(image.width.toDouble(), image.height.toDouble()),
56 image = image,
57 trimmed = false,
58 rotated = false,
59 frame = new Rect.fromLTRB(0.0, 0.0, image.width.toDouble(), image.height.toD ouble()),
60 spriteSourceSize = new Rect.fromLTRB(0.0, 0.0, image.width.toDouble(), image .height.toDouble()),
61 pivot = new Point(0.5, 0.5);
62
63
64 Texture._fromSpriteFrame(this.image, this.name, this.size, this.rotated, this. trimmed, this.frame,
65 this.spriteSourceSize, this.pivot) {
66 }
67
68 // Texture textureFromRect(Rect rect, [String name = null]) {
69 // assert(rect != null);
70 // Rect frame = new Rect.fromLTRB();
71 // return new Texture._fromSpriteFrame(image, name, rect.size, false, false, );
72 // }
73 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698