Skip to content

Commit

Permalink
Require SDK 1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Omoto committed Nov 28, 2014
1 parent 55c70cf commit fb01582
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 32 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,7 @@
# v0.1.0+2 (2014-11-28)

- Require SDK 1.8

# v0.1.0+1 (2014-08-20)

- New Color.fromFloat constructor.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -14,5 +14,5 @@ GitHub: [https://github.com/FedeOmoto/pixi_examples/tree/master/web/12_spine/](h

## Docs

[http://www.dartdocs.org/documentation/spine/0.1.0+1/](http://www.dartdocs.org/documentation/spine/0.1.0+1/)
[http://www.dartdocs.org/documentation/spine/0.1.0+2/](http://www.dartdocs.org/documentation/spine/0.1.0+2/)

18 changes: 10 additions & 8 deletions lib/src/attachments/mesh_attachment.dart
Expand Up @@ -59,8 +59,8 @@ class MeshAttachment extends Attachment {
int verticesLength = vertices.length;
int worldVerticesLength = (verticesLength / 2 * 5).toInt();

if (_worldVertices == null || _worldVertices.length != worldVerticesLength)
{
if (_worldVertices == null ||
_worldVertices.length != worldVerticesLength) {
_worldVertices = new List<double>(worldVerticesLength);
}

Expand Down Expand Up @@ -98,10 +98,12 @@ class MeshAttachment extends Attachment {
var meshColor = _color;
double a = skeletonColor.a * slotColor.a * meshColor.a * 255;
double multiplier = premultipliedAlpha ? a : 255.0;
double color = Color.intToFloatColor((a.truncate() << 24) |
((skeletonColor.b * slotColor.b * meshColor.b * multiplier).truncate() << 16) |
((skeletonColor.g * slotColor.g * meshColor.g * multiplier).truncate() << 8) |
(skeletonColor.r * slotColor.r * meshColor.r * multiplier).truncate());
double color =
Color.intToFloatColor(
(a.truncate() << 24) |
((skeletonColor.b * slotColor.b * meshColor.b * multiplier).truncate() << 16) |
((skeletonColor.g * slotColor.g * meshColor.g * multiplier).truncate() << 8) |
(skeletonColor.r * slotColor.r * meshColor.r * multiplier).truncate());

var slotVertices = slot.attachmentVertices;

Expand All @@ -118,8 +120,8 @@ class MeshAttachment extends Attachment {
for (int v = 0,
w = 0,
n = _worldVertices.length; w < n; v += 2, w += 5) {
double vx = vertices[v];
double vy = vertices[v + 1];
num vx = vertices[v];
num vy = vertices[v + 1];
_worldVertices[w] = vx * m00 + vy * m01 + x;
_worldVertices[w + 1] = vx * m10 + vy * m11 + y;
_worldVertices[w + 2] = color;
Expand Down
41 changes: 28 additions & 13 deletions lib/src/attachments/region_attachment.dart
Expand Up @@ -85,17 +85,29 @@ class RegionAttachment extends Attachment {
if (_region.rotate) {
localX += _region.offsetX / _region.originalWidth * width;
localY += _region.offsetY / _region.originalHeight * height;
localX2 -= (_region.originalWidth - _region.offsetX -
_region.packedHeight) / _region.originalWidth * width;
localY2 -= (_region.originalHeight - _region.offsetY -
_region.packedWidth) / _region.originalHeight * height;
localX2 -= (_region.originalWidth -
_region.offsetX -
_region.packedHeight) /
_region.originalWidth *
width;
localY2 -= (_region.originalHeight -
_region.offsetY -
_region.packedWidth) /
_region.originalHeight *
height;
} else {
localX += _region.offsetX / _region.originalWidth * width;
localY += _region.offsetY / _region.originalHeight * height;
localX2 -= (_region.originalWidth - _region.offsetX - _region.packedWidth)
/ _region.originalWidth * width;
localY2 -= (_region.originalHeight - _region.offsetY -
_region.packedHeight) / _region.originalHeight * height;
localX2 -= (_region.originalWidth -
_region.offsetX -
_region.packedWidth) /
_region.originalWidth *
width;
localY2 -= (_region.originalHeight -
_region.offsetY -
_region.packedHeight) /
_region.originalHeight *
height;
}

localX *= scaleX;
Expand Down Expand Up @@ -164,10 +176,13 @@ class RegionAttachment extends Attachment {
var regionColor = _color;
double a = skeletonColor.a * slotColor.a * regionColor.a * 255;
double multiplier = premultipliedAlpha ? a : 255.0;
double color = Color.intToFloatColor((a.truncate() << 24) |
((skeletonColor.b * slotColor.b * regionColor.b * multiplier).truncate() << 16)
| ((skeletonColor.g * slotColor.g * regionColor.g * multiplier).truncate() << 8)
| (skeletonColor.r * slotColor.r * regionColor.r * multiplier).truncate());
double color =
Color.intToFloatColor(
(a.truncate() << 24) |
((skeletonColor.b * slotColor.b * regionColor.b * multiplier).truncate() <<
16) |
((skeletonColor.g * slotColor.g * regionColor.g * multiplier).truncate() << 8) |
(skeletonColor.r * slotColor.r * regionColor.r * multiplier).truncate());

var bone = slot.bone;
double x = skeleton.position.x + bone.worldX,
Expand Down Expand Up @@ -203,7 +218,7 @@ class RegionAttachment extends Attachment {
_vertices[C4] = color;
}

List<double> get getWorldVertices => _vertices;
List<double> get worldVertices => _vertices;

List<double> get getOffset => _offset;

Expand Down
19 changes: 11 additions & 8 deletions lib/src/attachments/skinned_mesh_attachment.dart
Expand Up @@ -60,8 +60,8 @@ class SkinnedMeshAttachment extends Attachment {
int verticesLength = regionUVs.length;
int worldVerticesLength = (verticesLength / 2 * 5).toInt();

if (_worldVertices == null || _worldVertices.length != worldVerticesLength)
{
if (_worldVertices == null ||
_worldVertices.length != worldVerticesLength) {
_worldVertices = new List<double>(worldVerticesLength);
}

Expand Down Expand Up @@ -99,10 +99,13 @@ class SkinnedMeshAttachment extends Attachment {
var regionColor = _color;
double a = skeletonColor.a * meshColor.a * regionColor.a * 255;
double multiplier = premultipliedAlpha ? a : 255.0;
double color = Color.intToFloatColor((a.truncate() << 24) |
((skeletonColor.b * meshColor.b * regionColor.b * multiplier).truncate() << 16)
| ((skeletonColor.g * meshColor.g * regionColor.g * multiplier).truncate() << 8)
| (skeletonColor.r * meshColor.r * regionColor.r * multiplier).truncate());
double color =
Color.intToFloatColor(
(a.truncate() << 24) |
((skeletonColor.b * meshColor.b * regionColor.b * multiplier).truncate() <<
16) |
((skeletonColor.g * meshColor.g * regionColor.g * multiplier).truncate() << 8) |
(skeletonColor.r * meshColor.r * regionColor.r * multiplier).truncate());

double x = skeleton.position.x,
y = skeleton.position.y;
Expand Down Expand Up @@ -162,7 +165,7 @@ class SkinnedMeshAttachment extends Attachment {
}
}

List<double> get getWorldVertices => _worldVertices;
List<double> get worldVertices => _worldVertices;

Color get getColor => _color;
Color get color => _color;
}
4 changes: 2 additions & 2 deletions pubspec.yaml
@@ -1,10 +1,10 @@
name: spine
version: 0.1.0+1
version: 0.1.0+2
author: Federico Omoto <federico.omoto@gmail.com>
description: A Dart implementation of the Esoteric Software Spine runtime.
homepage: https://github.com/FedeOmoto/spine
environment:
sdk: '>=1.5.8 <1.7.0'
sdk: '>=1.8.0 <2.0.0'
dependencies:
path: '>=1.3.0 <1.4.0'
vector_math: '>=1.4.3 <1.5.0'

0 comments on commit fb01582

Please sign in to comment.