From 9ad7950e74334af175f599093ed97a5736159dd0 Mon Sep 17 00:00:00 2001 From: dev-hann Date: Sun, 16 Jan 2022 13:20:52 +0900 Subject: [PATCH 1/4] Add a GitHub Actions workflow --- .github/workflows/dart.yml | 50 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/dart.yml diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml new file mode 100644 index 0000000..a74b8ba --- /dev/null +++ b/.github/workflows/dart.yml @@ -0,0 +1,50 @@ +name: Dart + +on: + push: + branches: [master] + pull_request: + branches: [master] + schedule: + - cron: "0 7 * * 0" + +jobs: + analyze: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Check formatting + run: dart format --output=none --set-exit-if-changed . + if: always() && steps.install.outcome == 'success' + - name: Analyze code + run: dart analyze --fatal-infos + if: always() && steps.install.outcome == 'success' + + test: + needs: analyze + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + sdk: [stable, dev] + steps: + - uses: actions/checkout@v2 + - uses: dart-lang/setup-dart@v1.0 + with: + sdk: ${{ matrix.sdk }} + - id: install + name: Install dependencies + run: dart pub get + - name: Run VM tests + run: dart test --platform vm + if: always() && steps.install.outcome == 'success' From fa201a18062efa26f592ea8bc92b69d11ba2b0a1 Mon Sep 17 00:00:00 2001 From: dev-hann Date: Sun, 16 Jan 2022 13:25:39 +0900 Subject: [PATCH 2/4] Remove an unnecessary dependency --- pubspec.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/pubspec.yaml b/pubspec.yaml index 8b1ab7c..f69cafc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -7,7 +7,6 @@ homepage: https://github.com/jtakakura/spine_core/ environment: sdk: ">=2.15.1 <3.0.0" - flutter: ">=2.8.1" dev_dependencies: test: ^1.20.1 From 715eec5a511bf5dca89c3a0f9b04f173e5e43c1a Mon Sep 17 00:00:00 2001 From: dev-hann Date: Sun, 16 Jan 2022 13:43:43 +0900 Subject: [PATCH 3/4] Formatting --- lib/src/animation.dart | 42 +++++++++++++++++++------------ lib/src/animation_state.dart | 41 +++++++++++++++++++++--------- lib/src/path_constraint.dart | 30 +++++++++++----------- lib/src/texture_atlas.dart | 4 +-- lib/src/transform_constraint.dart | 3 ++- 5 files changed, 73 insertions(+), 47 deletions(-) diff --git a/lib/src/animation.dart b/lib/src/animation.dart index e8e3058..4aafafb 100644 --- a/lib/src/animation.dart +++ b/lib/src/animation.dart @@ -39,7 +39,6 @@ class Animation { void apply(Skeleton skeleton, double lastTime, double time, bool loop, List events, double alpha, MixPose pose, MixDirection direction) { - if (loop && duration != 0) { time %= duration; if (lastTime > 0) lastTime %= duration; @@ -605,8 +604,11 @@ class TwoColorTimeline extends CurveTimeline { (setupLight.g - light.g) * alpha, (setupLight.b - light.b) * alpha, (setupLight.a - light.a) * alpha); - dark!.add((setupDark!.r - dark.r) * alpha, (setupDark.g - dark.g) * alpha, - (setupDark.b - dark.b) * alpha, 0.0); + dark!.add( + (setupDark!.r - dark.r) * alpha, + (setupDark.g - dark.g) * alpha, + (setupDark.b - dark.b) * alpha, + 0.0); } return; } @@ -673,7 +675,8 @@ class AttachmentTimeline implements Timeline { AttachmentTimeline(int frameCount, this.slotIndex) : assert(slotIndex >= 0), frames = Float32List(frameCount), - attachmentNames = List.filled(frameCount, null, growable: false); + attachmentNames = + List.filled(frameCount, null, growable: false); @override int getPropertyId() => (TimelineType.Attachment.index << 24) + slotIndex; @@ -730,7 +733,8 @@ class DeformTimeline extends CurveTimeline { DeformTimeline(int frameCount, this.slotIndex, this.attachment) : assert(slotIndex >= 0), frames = Float32List(frameCount), - frameVertices = List.filled(frameCount, null, growable: false), + frameVertices = + List.filled(frameCount, null, growable: false), super(frameCount); @override @@ -770,7 +774,8 @@ class DeformTimeline extends CurveTimeline { return; } final Float32List vertices = Float32List.fromList( - ArrayUtils.copyWithNewArraySize(verticesArray, vertexCount, double.infinity)); + ArrayUtils.copyWithNewArraySize( + verticesArray, vertexCount, double.infinity)); if (vertexAttachment.bones == null) { // Unweighted vertex positions. final Float32List setupVertices = vertexAttachment.vertices!; @@ -785,14 +790,15 @@ class DeformTimeline extends CurveTimeline { return; } - Float32List vertices = Float32List.fromList( - ArrayUtils.copyWithNewArraySize(verticesArray, vertexCount, double.infinity)); + Float32List vertices = Float32List.fromList(ArrayUtils.copyWithNewArraySize( + verticesArray, vertexCount, double.infinity)); if (time >= frames[frames.length - 1]) { // Time is after last frame. final Float32List lastVertices = frameVertices[frames.length - 1]!; if (alpha == 1) { vertices = ArrayUtils.arrayCopyWithGrowth( - lastVertices, 0, vertices, 0, vertexCount, double.infinity) as Float32List; + lastVertices, 0, vertices, 0, vertexCount, double.infinity) + as Float32List; } else if (pose == MixPose.Setup) { if (vertexAttachment.bones == null) { // Unweighted vertex positions, with alpha. @@ -1029,7 +1035,8 @@ class IkConstraintTimeline extends CurveTimeline { alpha ..bendDirection = direction == MixDirection.Out ? constraint.data.bendDirection - : frames[frames.length + IkConstraintTimeline.prevBendDirection] as int; + : frames[frames.length + IkConstraintTimeline.prevBendDirection] + as int; } else { constraint.mix = constraint.mix + (frames[frames.length + IkConstraintTimeline.prevMix] - @@ -1065,10 +1072,11 @@ class IkConstraintTimeline extends CurveTimeline { ? constraint.data.bendDirection : frames[frame + IkConstraintTimeline.prevBendDirection] as int; } else { - constraint.mix = constraint.mix + (mix + - (frames[frame + IkConstraintTimeline.mix] - mix) * percent - - constraint.mix) * - alpha; + constraint.mix = constraint.mix + + (mix + + (frames[frame + IkConstraintTimeline.mix] - mix) * percent - + constraint.mix) * + alpha; if (direction == MixDirection.In) constraint.bendDirection = frames[frame + IkConstraintTimeline.prevBendDirection].toInt(); @@ -1261,7 +1269,8 @@ class PathConstraintPositionTimeline extends CurveTimeline { constraint.position = constraint.data.position + (position - constraint.data.position) * alpha; else - constraint.position = constraint.position + (position - constraint.position) * alpha; + constraint.position = + constraint.position + (position - constraint.position) * alpha; } } @@ -1320,7 +1329,8 @@ class PathConstraintSpacingTimeline extends PathConstraintPositionTimeline { constraint.spacing = constraint.data.spacing + (spacing - constraint.data.spacing) * alpha; else - constraint.spacing = constraint.spacing + (spacing - constraint.spacing) * alpha; + constraint.spacing = + constraint.spacing + (spacing - constraint.spacing) * alpha; } } diff --git a/lib/src/animation_state.dart b/lib/src/animation_state.dart index 1fb50d5..2b5c0a9 100755 --- a/lib/src/animation_state.dart +++ b/lib/src/animation_state.dart @@ -229,7 +229,8 @@ class AnimationState { if (mix > 1) mix = 1.0; } - final List events = mix < from.eventThreshold ? this.events : []; + final List events = + mix < from.eventThreshold ? this.events : []; final bool attachments = mix < from.attachmentThreshold; final bool drawOrder = mix < from.drawOrderThreshold; final double animationLast = from.animationLast; @@ -307,7 +308,8 @@ class AnimationState { if (firstFrame) timelinesRotation[i] = 0.0; if (alpha == 1) { - timeline.apply(skeleton, 0.0, time, [], 1.0, pose, MixDirection.In); + timeline.apply( + skeleton, 0.0, time, [], 1.0, pose, MixDirection.In); return; } @@ -464,7 +466,8 @@ class AnimationState { // Store the interrupted mix percentage. if (from.mixingFrom != null && from.mixDuration > 0) - current!.interruptAlpha = current.interruptAlpha * math.min(1, from.mixTime / from.mixDuration); + current!.interruptAlpha = current.interruptAlpha * + math.min(1, from.mixTime / from.mixDuration); // Reset rotation for mixing out, in case entry was mixed in. from.timelinesRotation.length = 0; @@ -575,8 +578,8 @@ class AnimationState { TrackEntry? expandToIndex(int index) { if (index < tracks.length) return tracks[index]; - tracks = ArrayUtils.ensureArrayCapacity( - tracks, index - tracks.length + 1, null); + tracks = + ArrayUtils.ensureArrayCapacity(tracks, index - tracks.length + 1, null); tracks.length = index + 1; return null; } @@ -827,29 +830,42 @@ class EventQueue { EventQueue(this.animState); void start(TrackEntry? entry) { - objects..add(EventType.Start)..add(entry); + objects + ..add(EventType.Start) + ..add(entry); animState.animationsChanged = true; } void interrupt(TrackEntry entry) { - objects..add(EventType.Interrupt)..add(entry); + objects + ..add(EventType.Interrupt) + ..add(entry); } void end(TrackEntry entry) { - objects..add(EventType.End)..add(entry); + objects + ..add(EventType.End) + ..add(entry); animState.animationsChanged = true; } void dispose(TrackEntry entry) { - objects..add(EventType.Dispose)..add(entry); + objects + ..add(EventType.Dispose) + ..add(entry); } void complete(TrackEntry entry) { - objects..add(EventType.Complete)..add(entry); + objects + ..add(EventType.Complete) + ..add(entry); } void event(TrackEntry entry, Event? event) { - objects..add(EventType.Event)..add(entry)..add(event); + objects + ..add(EventType.Event) + ..add(entry) + ..add(event); } void drain() { @@ -898,7 +914,8 @@ class EventQueue { animState.trackEntryPool.free(entry); break; case EventType.Complete: - if (entry!.onCompleteCallback != null) entry.onCompleteCallback!(entry); + if (entry!.onCompleteCallback != null) + entry.onCompleteCallback!(entry); onCompleteCallbacks .forEach((TrackEntryCallback callback) => callback(entry)); break; diff --git a/lib/src/path_constraint.dart b/lib/src/path_constraint.dart index 97ada0b..263ca00 100644 --- a/lib/src/path_constraint.dart +++ b/lib/src/path_constraint.dart @@ -78,15 +78,14 @@ class PathConstraint extends Constraint { final int boneCount = this.bones.length, spacesCount = tangents ? boneCount : boneCount + 1; final List bones = this.bones; - final Float32List spaces = - ArrayUtils.copyWithNewArraySize(this.spaces, spacesCount, double.infinity) - as Float32List; + final Float32List spaces = ArrayUtils.copyWithNewArraySize( + this.spaces, spacesCount, double.infinity) as Float32List; late Float32List lengths; final double spacing = this.spacing; if (scale || lengthSpacing) { if (scale) - lengths = ArrayUtils.copyWithNewArraySize(this.lengths, boneCount, double.infinity) - as Float32List; + lengths = ArrayUtils.copyWithNewArraySize( + this.lengths, boneCount, double.infinity) as Float32List; final int n = spacesCount - 1; for (int i = 0; i < n;) { final Bone bone = bones[i]; @@ -186,9 +185,8 @@ class PathConstraint extends Constraint { final Slot? target = this.target; double position = this.position; final Float32List spaces = this.spaces; - final Float32List out = - ArrayUtils.copyWithNewArraySize(positions, spacesCount * 3 + 2, double.infinity) - as Float32List; + final Float32List out = ArrayUtils.copyWithNewArraySize( + positions, spacesCount * 3 + 2, double.infinity) as Float32List; Float32List world; final bool closed = path.closed; int verticesLength = path.worldVerticesLength, @@ -247,7 +245,8 @@ class PathConstraint extends Constraint { prevCurve = curve; if (closed && curve == curveCount) { path - ..computeWorldVertices(target!, verticesLength - 4, 4, world, 0, 2) + ..computeWorldVertices( + target!, verticesLength - 4, 4, world, 0, 2) ..computeWorldVertices(target, 0, 4, world, 4, 2); } else path.computeWorldVertices(target!, curve * 6 + 2, 8, world, 0, 2); @@ -272,8 +271,8 @@ class PathConstraint extends Constraint { // World vertices. if (closed) { verticesLength += 2; - world = ArrayUtils.copyWithNewArraySize(this.world, verticesLength, double.infinity) - as Float32List; + world = ArrayUtils.copyWithNewArraySize( + this.world, verticesLength, double.infinity) as Float32List; path ..computeWorldVertices(target!, 2, verticesLength - 4, world, 0, 2) ..computeWorldVertices(target, 0, 2, world, verticesLength - 4, 2); @@ -282,15 +281,14 @@ class PathConstraint extends Constraint { } else { curveCount--; verticesLength -= 4; - world = ArrayUtils.copyWithNewArraySize(this.world, verticesLength, double.infinity) - as Float32List; + world = ArrayUtils.copyWithNewArraySize( + this.world, verticesLength, double.infinity) as Float32List; path.computeWorldVertices(target!, 2, verticesLength, world, 0, 2); } // Curve lengths. - final Float32List curves = - ArrayUtils.copyWithNewArraySize(this.curves, curveCount, double.infinity) - as Float32List; + final Float32List curves = ArrayUtils.copyWithNewArraySize( + this.curves, curveCount, double.infinity) as Float32List; double pathLength = 0.0; double x1 = world[0], y1 = world[1], diff --git a/lib/src/texture_atlas.dart b/lib/src/texture_atlas.dart index cf3b935..d15abcb 100644 --- a/lib/src/texture_atlas.dart +++ b/lib/src/texture_atlas.dart @@ -205,7 +205,7 @@ class TextureAtlasPage { int width = 0; int height = 0; - TextureAtlasPage(this.name): assert(name.isNotEmpty); + TextureAtlasPage(this.name) : assert(name.isNotEmpty); } class TextureAtlasRegion extends TextureRegion { @@ -217,5 +217,5 @@ class TextureAtlasRegion extends TextureRegion { int index = -1; Texture? texture; - TextureAtlasRegion(this.name): assert(name.isNotEmpty); + TextureAtlasRegion(this.name) : assert(name.isNotEmpty); } diff --git a/lib/src/transform_constraint.dart b/lib/src/transform_constraint.dart index f7d17bc..b17ce9f 100644 --- a/lib/src/transform_constraint.dart +++ b/lib/src/transform_constraint.dart @@ -285,7 +285,8 @@ class TransformConstraint extends Constraint { double rotation = bone.arotation; if (rotateMix != 0) - rotation = rotation + (target.arotation + data.offsetRotation) * rotateMix; + rotation = + rotation + (target.arotation + data.offsetRotation) * rotateMix; double x = bone.ax, y = bone.ay; if (translateMix != 0) { From 3c34056d1c3f8176c0e15e9a70d12d0ff64a9a40 Mon Sep 17 00:00:00 2001 From: dev-hann Date: Sun, 16 Jan 2022 13:57:12 +0900 Subject: [PATCH 4/4] Bump up version to 0.3.1 --- CHANGELOG.md | 6 +++++- pubspec.yaml | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2480a98..7d8d927 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,4 +8,8 @@ ## 0.3.0 -- Nullsafety support +- Nullsafety support(thanks to @signmotion) + +## 0.3.1 + +- More support for null safety(thanks to @signmotion) diff --git a/pubspec.yaml b/pubspec.yaml index f69cafc..a9f12da 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: spine_core description: The spine-core runtime provides functionality to load and manipulate Spine skeletal animation data using Dart. -version: 0.3.0 +version: 0.3.1 homepage: https://github.com/jtakakura/spine_core/ environment: