octicon-rss(16/)
You've already forked flame
mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-10 00:28:07 +08:00
Adding a new method for sprite to render it scaled easily
This commit is contained in:
octicon-git-branch(16/)
octicon-tag(16/)
octicon-diff(16/tw-mr-1) 1 changed files with 12 additions and 0 deletions
@@ -81,6 +81,18 @@ class Sprite {
|
|||||||
return new Position(src.width, src.height);
|
return new Position(src.width, src.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Renders this Sprite on the position [p], scaled by the [scale] factor provided.
|
||||||
|
///
|
||||||
|
/// It renders with src size multiplied by [scale] in both directions.
|
||||||
|
/// Anchor is on top left as default.
|
||||||
|
/// If not loaded, does nothing.
|
||||||
|
void renderScaled(Canvas canvas, Position p, [double scale = 1.0]) {
|
||||||
|
if (!this.loaded()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
renderPosition(canvas, p, size.times(scale));
|
||||||
|
}
|
||||||
|
|
||||||
void renderPosition(Canvas canvas, Position p, [Position size]) {
|
void renderPosition(Canvas canvas, Position p, [Position size]) {
|
||||||
if (!this.loaded()) {
|
if (!this.loaded()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user