# Module: GeometryDocs

Included in:
Geometry
Defined in:
dragon/geometry_docs.rb

## Overview

Copyright 2019 DragonRuby LLC MIT License geometry_docs.rb has been released under MIT (*only this file*).

## Instance Method Details

### #docs_class ⇒ Object

 11 12 13 14 15 16 17 18 # File 'dragon/geometry_docs.rb', line 11 def docs_class <<-S * DOCS: ~Geometry~ The Geometry module contains methods for calculations that are frequently used in game development. S end

### #docs_method_sort_order ⇒ Object

 7 8 9 # File 'dragon/geometry_docs.rb', line 7 def docs_method_sort_order [:docs_class, :docs_scale_rect] end

### #docs_scale_rect ⇒ Object

 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 # File 'dragon/geometry_docs.rb', line 20 def docs_scale_rect <<-S * DOCS: ~GTK::Geometry#scale_rect~ Given an array with 4 elements representing a rect [x, y, w, h], this function returns a scaled rect. It accepts three arguments: ~ratio~: the ratio by which to scale the rect. A ratio of 2 will double the dimensions of the rect while a ratio of 0.5 will halve its dimensions. ~anchor_x~ and ~anchor_y~ specify the point within the rect from which to resize it. Setting both to 0 will affect the width and height of the rect, leaving x and y unchanged. Setting both to 0.5 will scale all sides of the rect proportionally from the center. The ~scale_rect~ method can be applied directly to a sprite or other primitives. See CHEATSHEET: How to Scale a Sprite. #+begin_src ruby def tick args # x, y, w, h my_rect = [100, 100, 200, 200] # halve the dimensions of the rect: # ratio, anchor_x, anchor_y new_rect = my_rect.scale_rect(0.5, 0.5, 0.5) puts new_rect # => [150.0, 150.0, 100.0, 100.0] end #+end_src S end