Module: Dinraal
- Included in:
- Dinraal
- Defined in:
- app/lib/dinraal.rb
Overview
Module provides methods for manipulating shapes to DragonRuby Game Toolkit. By D Schaedler. Released under MIT License. github.com/DSchaedler/dinraal
Instance Method Summary collapse
Methods included from D_Point
point_at_distance_angle, point_difference, point_distance, point_distance_squared, point_inside_triangle?, two_point_eq
Methods included from D_Circle
Methods included from D_Vector
vector_angle, vector_cross_product, vector_dot_product, vector_normal
Methods included from D_Numeric
Methods included from D_Triangle
rectangle_inside_triangle?, triangle, triangle_bounding_box, triangle_center, triangle_inside_triangle?, triangle_outline, triangle_raster, triangle_raster_fast
Instance Method Details
#hsv_to_rgb(h, s, v) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'app/lib/dinraal.rb', line 13 def hsv_to_rgb(h, s, v) # based on conversion listed here: https://www.rapidtables.com/convert/color/hsv-to-rgb.html h = h % 360 c = v * s x = c * (1 - (((h / 60) % 2) - 1).abs) m = v - c rp, gp, bp = [ [c, x, 0], # 0 < h < 60 [x, c, 0], # 60 < h < 120 [0, c, x], # 120 < h < 180 [0, x, c], # 180 < h < 240 [x, 0, c], # 240 < h < 300 [c, 0, x] # 300 < h < 360 ][h / 60] { r: (rp + m) * 255, g: (gp + m) * 255, b: (bp + m) * 255 } end |