lib/fantasy/utils.rb in fantasy-0.1.5.1 vs lib/fantasy/utils.rb in fantasy-0.1.7
- old
+ new
@@ -25,6 +25,11 @@
Gosu.draw_rect(x, y, width, stroke, color)
Gosu.draw_rect(x + (width - stroke), y, stroke, height, color)
Gosu.draw_rect(x, y + (height - stroke), width, stroke, color)
Gosu.draw_rect(x, y, stroke, height, color)
end
+
+ def self.remap(value:, from_ini:, from_end:, to_ini:, to_end:)
+ result = to_ini + (value - from_ini) * (to_end - to_ini) / (from_end - from_ini);
+ result
+ end
end