Discord

Preparing your files

Please wait until the download is ready.

Luka's Scripting Utilities

Luka's Scripting Utilities

by Luka S.J.

A pack full of various scripting utilities to ease your development!

v4.1.135,194
Download144 KB

Math Helpers

LUTS::Math adds geometry helpers on top of Ruby's Math module — handy for
laying out shapes and scattering points.

  • LUTS::Math.polygon_points(n, radius:, width:, height:, angle: 0) the [x, y] coordinates of all n vertices of a regular polygon centred in a width × height area, rotated by angle degrees. Returns one pair per vertex.
  • LUTS::Math.rand_circle_coord(radius, x:) a random [x, y] point on the circumference of a circle of the given radius. Pass x: nil to also randomise the x-coordinate within the diameter.
# vertices of a hexagon inside a 128x128 box
points = LUTS::Math.polygon_points(6, radius: 60, width: 128, height: 128)
points.each { |x, y| bmp.set_pixel(x, y, Color.white) }

These pair naturally with Bitmaps::Polygon for drawing custom shapes (see
Bitmap Drawing).