mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 19:12:31 +08:00
Adding a rotate method to Position and a drawWhere method to utils
This commit is contained in:
@ -22,4 +22,12 @@ class Position {
|
||||
double length() {
|
||||
return math.sqrt(math.pow(this.x, 2) + math.pow(this.y, 2));
|
||||
}
|
||||
|
||||
Position rotate(double angle) {
|
||||
double nx = math.cos(angle) * this.x - math.sin(angle) * this.y;
|
||||
double ny = math.sin(angle) * this.x + math.cos(angle) * this.y;
|
||||
this.x = nx;
|
||||
this.y = ny;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,6 +5,8 @@ import 'package:flutter/gestures.dart';
|
||||
import 'package:flutter/material.dart' as material;
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
import 'position.dart';
|
||||
|
||||
class Util {
|
||||
void fullScreen() {
|
||||
SystemChrome.setEnabledSystemUIOverlays([]);
|
||||
@ -46,4 +48,10 @@ class Util {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
void drawWhere(Canvas c, Position p, void Function(Canvas) fn) {
|
||||
c.translate(p.x, p.y);
|
||||
fn(c);
|
||||
c.translate(-p.x, -p.y);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user