diff options
| author | oeloeloel <[email protected]> | 2020-12-05 18:04:00 -0500 |
|---|---|---|
| committer | Amir Rajan <[email protected]> | 2020-12-06 09:50:09 -0600 |
| commit | 4349fae320b07a45c10be010a6004d19266d408d (patch) | |
| tree | 0aa6a4c01254277115230f309bd93a95932f9764 | |
| parent | c8d861dbd4551445d71bcbe6db510fb792a1895c (diff) | |
| download | dragonruby-game-toolkit-contrib-4349fae320b07a45c10be010a6004d19266d408d.tar.gz dragonruby-game-toolkit-contrib-4349fae320b07a45c10be010a6004d19266d408d.zip | |
Update readme_docs.rb
Added How to Scale a Sprite
| -rw-r--r-- | dragon/readme_docs.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/dragon/readme_docs.rb b/dragon/readme_docs.rb index 98284d6..6ac336f 100644 --- a/dragon/readme_docs.rb +++ b/dragon/readme_docs.rb @@ -975,6 +975,33 @@ do S end + def scale_sprites + <<-S +* CHEATSHEET: How to Scale a Sprite + +The ~scale_rect~ method can be used to change the scale of a sprite by a given ~ratio~. + +Optionally, you can scale the sprite around a specified anchor point. In the example below, setting both ~anchor_x~ and ~anchor_y~ to 0.5 scales the sprite proportionally on all four sides). + +See also: DOCS: GTK::Geometry#scale_rect + +#+begin_src ruby + def tick args + # x, y, w, h, path + my_sprite = [590, 310, 100, 100, 'sprites/circle.png'] + + # scale a sprite with a ratio of 2 (double the size) + # and anchor the transformation around the center of the sprite + + # ratio, anchor_x, anchor_y + my_scaled_sprite = my_sprite.scale_rect(2, 0.5, 0.5) + + args.outputs.sprites << [my_scaled_sprite, "sprites/circle.png"] + end +#+end_src +S + end + def docs_faq <<-S * Frequently Asked Questions, Comments, and Concerns |
