Skip to content

Commit 5f09d9d

Browse files
authored
Merge branch 'main' into feat/manage_sprite_batch_items_by_id
2 parents 39ebfd4 + 7ede916 commit 5f09d9d

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

packages/flame/lib/src/extensions/canvas.dart

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ extension CanvasExtension on Canvas {
3030
drawRect(rect, paint ?? BasicPalette.magenta.paint());
3131
}
3232

33+
/// Renders a line between [p1] and [p2] using the provided [paint].
34+
///
35+
/// Equivalent to [drawLine] but using [Vector2] instead of [Offset].
36+
void renderLine(Vector2 p1, Vector2 p2, Paint paint) {
37+
drawLine(p1.toOffset(), p2.toOffset(), paint);
38+
}
39+
3340
/// Utility method to render stuff on a specific place in an isolated way.
3441
///
3542
/// Some render methods don't allow to pass a vector.

packages/flame/test/extensions/canvas_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import 'dart:ui';
2+
13
import 'package:canvas_test/canvas_test.dart';
24
import 'package:flame/extensions.dart';
35
import 'package:mocktail/mocktail.dart';
@@ -18,6 +20,7 @@ void main() {
1820
canvas.translateVector(Vector2(1, 2));
1921
verify(() => canvas.translate(1, 2)).called(1);
2022
});
23+
2124
test('renderPoint', () {
2225
final canvas = MockCanvas();
2326
canvas.renderPoint(Vector2.all(10.0), size: 2);
@@ -27,6 +30,16 @@ void main() {
2730
);
2831
});
2932

33+
test('renderLine', () {
34+
final canvas = MockCanvas();
35+
final paint = Paint()..color = const Color(0xFFFF00FF);
36+
canvas.renderLine(Vector2.all(1), Vector2(3, 0), paint);
37+
expect(
38+
canvas,
39+
MockCanvas()..drawLine(const Offset(1, 1), const Offset(3, 0), paint),
40+
);
41+
});
42+
3043
test('renderAt saves, translates draws and then restores', () {
3144
final canvas = _MocktailCanvas();
3245
when(canvas.save).thenReturn(null);

packages/flame_3d/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ In order to use flame_3d, you will need to ensure a few things. Firstly, the onl
6969
have explicitly tested so far for support were Android, iOS, and macOS.
7070

7171
Then, you need to enable Impeller, if not already enabled by default. For example, for macOS, add
72-
the following to the `Info.plist` in your `macos/` directory:
72+
the following to the generated `macos/runner/Info.plist` directory:
7373

7474
```xml
7575
<dict>
@@ -82,15 +82,15 @@ the following to the `Info.plist` in your `macos/` directory:
8282
You can also run Flutter with the flag:
8383

8484
```bash
85-
flutter run --enable-impeller
85+
flutter run --enable-flutter-gpu
8686
```
8787

8888
Now everything is set up you can start doing some 3D magic! You can check out the
8989
[example](https://github.com/flame-engine/flame/tree/main/packages/flame_3d/example) to see how you
9090
can set up a simple 3D environment using Flame.
9191

92-
Also check out the [flame_3d_extras](https://github.com/luanpotter/flame_3d_extras) package for more
93-
utilities and helpers not yet merged into `flame_3d`.
92+
Also check our more advanced examples, [Collect the Donut](https://github.com/luanpotter/collect_the_donut)
93+
and [Defend the Donut](https://github.com/flame-engine/defend_the_donut).
9494

9595

9696
## Building shaders

0 commit comments

Comments
 (0)