Skip to content

Commit

Permalink
New Color.fromFloat constructor and new mutable Point class
Browse files Browse the repository at this point in the history
  • Loading branch information
Federico Omoto committed Aug 20, 2014
1 parent 80c0f14 commit 55c70cf
Show file tree
Hide file tree
Showing 11 changed files with 82 additions and 17 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,5 @@
# v0.1.0+1 (2014-08-20)

- New Color.fromFloat constructor.
- New mutable Point class.

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/](http://www.dartdocs.org/documentation/spine/0.1.0/)
[http://www.dartdocs.org/documentation/spine/0.1.0+1/](http://www.dartdocs.org/documentation/spine/0.1.0+1/)

2 changes: 1 addition & 1 deletion lib/spine.dart
Expand Up @@ -33,7 +33,6 @@
*/
library spine;

import 'dart:html';
import 'dart:math' as math;
import 'dart:typed_data';
import 'dart:async';
Expand All @@ -45,6 +44,7 @@ part 'src/utils/color.dart';
part 'src/utils/poolable.dart';
part 'src/utils/pool.dart';
part 'src/utils/enum.dart';
part 'src/utils/point.dart';
part 'src/animation/timeline.dart';
part 'src/animation/curve_timeline.dart';
part 'src/animation/rotate_timeline.dart';
Expand Down
4 changes: 2 additions & 2 deletions lib/src/attachments/mesh_attachment.dart
Expand Up @@ -108,8 +108,8 @@ class MeshAttachment extends Attachment {
if (slotVertices.length == vertices.length) vertices = slotVertices;

var bone = slot.bone;
double x = skeleton.x + bone.worldX,
y = skeleton.y + bone.worldY;
double x = skeleton.position.x + bone.worldX,
y = skeleton.position.y + bone.worldY;
double m00 = bone.m00,
m01 = bone.m01,
m10 = bone.m10,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/attachments/region_attachment.dart
Expand Up @@ -170,8 +170,8 @@ class RegionAttachment extends Attachment {
| (skeletonColor.r * slotColor.r * regionColor.r * multiplier).truncate());

var bone = slot.bone;
double x = skeleton.x + bone.worldX,
y = skeleton.y + bone.worldY;
double x = skeleton.position.x + bone.worldX,
y = skeleton.position.y + bone.worldY;
double m00 = bone.m00,
m01 = bone.m01,
m10 = bone.m10,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/attachments/skinned_mesh_attachment.dart
Expand Up @@ -104,8 +104,8 @@ class SkinnedMeshAttachment extends Attachment {
| ((skeletonColor.g * meshColor.g * regionColor.g * multiplier).truncate() << 8)
| (skeletonColor.r * meshColor.r * regionColor.r * multiplier).truncate());

double x = skeleton.x,
y = skeleton.y;
double x = skeleton.position.x,
y = skeleton.position.y;
var skeletonBones = skeleton.bones;

var ffdArray = slot.attachmentVertices;
Expand Down
7 changes: 1 addition & 6 deletions lib/src/skeleton/skeleton.dart
Expand Up @@ -41,7 +41,7 @@ class Skeleton {
final Color color;
double time;
bool flipX, flipY;
double x, y;
Point<double> position = new Point<double>(0.0, 0.0);

Skeleton(SkeletonData data)
: this.data = data,
Expand Down Expand Up @@ -375,11 +375,6 @@ class Skeleton {
});
}

void setPosition(Point<double> value) {
x = value.x;
y = value.y;
}

void update(double delta) {
time += delta;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/src/skeleton/skeleton_bounds.dart
Expand Up @@ -39,8 +39,8 @@ class SkeletonBounds {

void update(Skeleton skeleton, bool updateAabb) {
var slots = skeleton.slots;
double x = skeleton.x,
y = skeleton.y;
double x = skeleton.position.x,
y = skeleton.position.y;

_boundingBoxes.clear();
_polygonPool.freeAll(_polygons);
Expand Down
11 changes: 11 additions & 0 deletions lib/src/utils/color.dart
Expand Up @@ -61,6 +61,17 @@ class Color {
_a = other._a;
}

/// Constructs a new color from a float.
Color.fromFloat(double value) {
ByteData bd = new ByteData(4);
bd.setFloat32(0, value);

_r = bd.getUint8(0) / 255;
_g = bd.getUint8(1) / 255;
_b = bd.getUint8(2) / 255;
_a = bd.getUint8(3) / 255;
}

/// Returns a new color from a hex string with the format RRGGBBAA.
Color.hex(String hex) {
int r = int.parse(hex.substring(0, 2), radix: 16, onError: _onFormatError);
Expand Down
54 changes: 54 additions & 0 deletions lib/src/utils/point.dart
@@ -0,0 +1,54 @@
// Spine Runtimes Software License
// Version 2.2
//
// Copyright (c) 2013, Esoteric Software
// All rights reserved.
//
// You are granted a perpetual, non-exclusive, non-sublicensable and
// non-transferable license to use, install, execute and perform the Spine
// Runtimes Software (the "Software") and derivative works solely for personal or
// internal use. Without the written permission of Esoteric Software (typically
// granted by licensing Spine), you may not (a) modify, translate, adapt or
// otherwise create derivative works, improvements of the Software or develop
// new applications using the Software or (b) remove, delete, alter or obscure
// any trademarks or any copyright, trademark, patent or other intellectual
// property or proprietary rights notices on or in the Software, including any
// copy thereof. Redistributions in binary or source form must include this
// license and terms.
//
// THIS SOFTWARE IS PROVIDED BY ESOTERIC SOFTWARE "AS IS" AND ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
// EVENT SHALL ESOTERIC SOFTARE BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

part of spine;

/**
* A utility class for representing two-dimensional positions with mutable
* properties.
*/
class Point<T extends num> extends math.Point<T> {
math.Point<T> _point;

Point(T x, T y) : super(x, y) {
_point = new math.Point<T>(super.x, super.y);
}

T get x => _point.x;

void set x(T x) {
_point = new math.Point<T>(x, _point.y);
}

T get y => _point.y;

void set y(T y) {
_point = new math.Point<T>(_point.x, y);
}
}
2 changes: 1 addition & 1 deletion pubspec.yaml
@@ -1,5 +1,5 @@
name: spine
version: 0.1.0
version: 0.1.0+1
author: Federico Omoto <federico.omoto@gmail.com>
description: A Dart implementation of the Esoteric Software Spine runtime.
homepage: https://github.com/FedeOmoto/spine
Expand Down

0 comments on commit 55c70cf

Please sign in to comment.