Skip to content

Commit

Permalink
refactors renames and other stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
renancaraujo committed Dec 14, 2024
1 parent 31ce674 commit 298a781
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 19 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:math';
import 'dart:typed_data';

import 'package:flame/camera.dart';
import 'package:flame/components.dart';
Expand Down Expand Up @@ -116,13 +117,25 @@ class Bezel extends PositionComponent {
const Radius.circular(5.0),
),
))
.transform((Matrix4.identity()..rotateZ(pi / 4)).storage);
.transform(
Float64List.fromList(
(Matrix4.identity()..rotateZ(pi / 4)).storage,
),
);
connector = (Path()
..addArc(Rect.fromLTRB(-outer, -outer, outer, outer), -0.22, 0.44))
.transform((Matrix4.identity()..rotateZ(pi / 4)).storage);
.transform(
Float64List.fromList(
(Matrix4.identity()..rotateZ(pi / 4)).storage,
),
);
specularHighlight = (Path()
..addOval(Rect.fromLTWH(-radius * 0.8, -8, 16, radius * 0.3)))
.transform((Matrix4.identity()..rotateZ(pi / 4)).storage);
.transform(
Float64List.fromList(
(Matrix4.identity()..rotateZ(pi / 4)).storage,
),
);

glassPaint = Paint()..color = const Color(0x1400ffae);
rimBorderPaint = Paint()
Expand Down
9 changes: 4 additions & 5 deletions packages/flame/lib/src/components/mixins/snapshot.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/components.dart';
Expand Down Expand Up @@ -47,7 +48,7 @@ mixin Snapshot on PositionComponent {
} else {
final recorder = PictureRecorder();
final canvas = Canvas(recorder);
canvas.transform(transform.storage);
canvas.transform(Float64List.fromList(transform.storage));
canvas.drawPicture(_picture!);
final picture = recorder.endRecording();
return picture.toImageSync(width, height);
Expand All @@ -63,7 +64,7 @@ mixin Snapshot on PositionComponent {
final canvas = Canvas(recorder);
final matrix = transformMatrix.clone();
matrix.invert();
canvas.transform(matrix.storage);
canvas.transform(Float64List.fromList(matrix.storage));
super.renderTree(canvas);
_picture = recorder.endRecording();
return _picture!;
Expand All @@ -82,9 +83,7 @@ mixin Snapshot on PositionComponent {
takeSnapshot();
}
canvas.save();
canvas.transform(
transformMatrix.storage,
);
canvas.transform(Float64List.fromList(transformMatrix.storage));
canvas.drawPicture(_picture!);
canvas.restore();
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/flame/lib/src/extensions/canvas.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/palette.dart';
Expand Down Expand Up @@ -59,6 +60,6 @@ extension CanvasExtension on Canvas {

/// Use the [Transform2D] object to [transform] the canvas.
void transform2D(Transform2D transform2D) {
transform(transform2D.transformMatrix.storage);
transform(Float64List.fromList(transform2D.transformMatrix.storage));
}
}
2 changes: 1 addition & 1 deletion packages/flame/lib/src/game/notifying_vector2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,5 +185,5 @@ class NotifyingVector2 extends Vector2 with ChangeNotifier {
}

@override
Float64List get storage => super.storage.asUnmodifiableView();
Float32List get storage => super.storage.asUnmodifiableView();
}
3 changes: 2 additions & 1 deletion packages/flame/lib/src/rendering/rotate3d_decorator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/geometry.dart';
Expand Down Expand Up @@ -61,7 +62,7 @@ class Rotate3DDecorator extends Decorator {
..rotateY(angleY)
..rotateZ(angleZ)
..translate(-center.x, -center.y);
canvas.transform(matrix.storage);
canvas.transform(Float64List.fromList(matrix.storage));
draw(canvas);
canvas.restore();
}
Expand Down
3 changes: 2 additions & 1 deletion packages/flame/lib/src/rendering/shadow3d_decorator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/src/palette.dart';
Expand Down Expand Up @@ -156,7 +157,7 @@ class Shadow3DDecorator extends Decorator {

canvas.saveLayer(null, _paint!);
canvas.translate(base.x + _shift, base.y);
canvas.transform(_transformMatrix!.storage);
canvas.transform(Float64List.fromList(_transformMatrix!.storage));
draw(canvas);
canvas.restore();
draw(canvas);
Expand Down
3 changes: 2 additions & 1 deletion packages/flame/lib/src/rendering/transform2d_decorator.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/src/components/position_component.dart';
Expand All @@ -17,7 +18,7 @@ class Transform2DDecorator extends Decorator {
@override
void apply(void Function(Canvas) draw, Canvas canvas) {
canvas.save();
canvas.transform(transform2d.transformMatrix.storage);
canvas.transform(Float64List.fromList(transform2d.transformMatrix.storage));
draw(canvas);
canvas.restore();
}
Expand Down
3 changes: 2 additions & 1 deletion packages/flame/lib/src/sprite_batch.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import 'dart:collection';
import 'dart:math' show pi;
import 'dart:typed_data';
import 'dart:ui';

import 'package:flame/cache.dart';
Expand Down Expand Up @@ -431,7 +432,7 @@ class SpriteBatch {

canvas
..save()
..transform(batchItem.matrix.storage)
..transform(Float64List.fromList(batchItem.matrix.storage))
..drawRect(batchItem.destination, batchItem.paint)
..drawImageRect(
atlas,
Expand Down
1 change: 0 additions & 1 deletion packages/flame/test/components/mixins/snapshot_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flame/components.dart';
import 'package:flame/extensions.dart';
import 'package:flame/game.dart';
import 'package:flame_test/flame_test.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
Expand Down
2 changes: 1 addition & 1 deletion packages/flame/test/extensions/matrix4_test.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import 'dart:math';

import 'package:flame/extensions.dart';
import 'package:flame/extensions_matrix4.dart';
import 'package:flame_test/flame_test.dart';
import 'package:mocktail/mocktail.dart';
import 'package:test/test.dart';
Expand Down
3 changes: 2 additions & 1 deletion packages/flame_forge2d/lib/body_component.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import 'dart:ui';
import 'package:flame/components.dart' hide World;
import 'package:flame/effects.dart';
import 'package:flame/extensions.dart';
import 'package:flame/extensions_matrix4.dart';
import 'package:flame/game.dart';
import 'package:flame_forge2d/flame_forge2d.dart';
import 'package:flutter/foundation.dart';
Expand Down Expand Up @@ -101,7 +102,7 @@ class BodyComponent<T extends Forge2DGame> extends Component
_lastAngle = angle;
}
canvas.save();
canvas.transform(matrix.storage);
canvas.transform(Float64List.fromList(matrix.storage));
super.renderTree(canvas);
canvas.restore();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/flame_forge2d/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ dependencies:
flame: ^1.22.0
flutter:
sdk: flutter
forge2d: ^0.13.1
forge2d: ^0.14.0

dev_dependencies:
dartdoc: ^8.0.8
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import 'package:flame/components.dart';
import 'package:flame/components.dart' show Component;
import 'package:flame_studio/src/core/component_tree.dart';
import 'package:flutter/widgets.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
Expand Down

0 comments on commit 298a781

Please sign in to comment.