mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-03 04:18:25 +08:00
Move files to src and comply with the dart package layout convention (#621)
* 👌 Use `Offset` type directly in `JoystickAction.update` calculations (#631) * Move files to src and comply with the dart package layout convention * Fixing widgets example Co-authored-by: Serge Matveenko <lig@countzero.co> Co-authored-by: Erick Zanardo <erickzanardoo@gmail.com>
This commit is contained in:
20
lib/src/extensions/size.dart
Normal file
20
lib/src/extensions/size.dart
Normal file
@ -0,0 +1,20 @@
|
||||
import 'dart:math';
|
||||
import 'dart:ui';
|
||||
|
||||
import 'vector2.dart';
|
||||
|
||||
export 'dart:ui' show Size;
|
||||
|
||||
extension SizeExtension on Size {
|
||||
/// Creates an [Offset] from the [Size]
|
||||
Offset toOffset() => Offset(width, height);
|
||||
|
||||
/// Creates a [Vector2] from the [Size]
|
||||
Vector2 toVector2() => Vector2(width, height);
|
||||
|
||||
/// Creates a [Point] from the [Size]
|
||||
Point toPoint() => Point(width, height);
|
||||
|
||||
/// Creates a [Rect] from the [Size]
|
||||
Rect toRect() => Rect.fromLTWH(0, 0, width, height);
|
||||
}
|
||||
Reference in New Issue
Block a user