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

Sprites::Base

Sprites::Base is the workhorse sprite class for LUTS-based plugins. It
subclasses the core Sprite (so it inherits the Animatable, Floatable and
Shaderable behaviour) and layers on a large toolkit of bitmap, colour and
positioning helpers.

sprite = Sprites::Base.new(viewport) do |s|
  s.set_bitmap("Graphics/Pictures/logo")
  s.center!(snap: true)
end

Sprites::Base.new(viewport, &block) creates the sprite, seeds its default
attributes, and yields itself to an optional configuration block.

Extra attributes

Beyond the standard sprite properties, Sprites::Base carries a set of
free-use accessors that the various plugins lean on: direction, speed,
toggle, end_x, end_y, param, skew_d, ex, ey, zx, zy, dx,
dy, finished, plus the read-only stored_bitmap. Call default!
to reset them.

Dimensions

  • sprite.width / sprite.width = val source-rect width
  • sprite.height / sprite.height = val source-rect height
  • sprite.zoom / sprite.zoom = val uniform zoom on both axes

Bitmaps

  • sprite.set_bitmap(bmp) set the bitmap from a path or a bitmap object
  • sprite.create_rect(width, height, color) set the bitmap to a solid colour rect
  • sprite.full_rect(color) fill the whole screen with a colour
  • sprite.blank_screen set a blank bitmap the size of the viewport
  • sprite.snap_screen capture a screenshot as the bitmap
  • sprite.stretch_screen(path) draw a bitmap stretched across the whole screen
  • sprite.memorize_bitmap(bmp = nil) remember the current (or given) bitmap
  • sprite.restore_bitmap restore the memorised bitmap
  • sprite.online_bitmap(url) download and apply a bitmap from a URL
  • sprite.mask(mask = nil, ox: 0, oy: 0) mask the bitmap with another bitmap
  • sprite.text_sprite(width = viewport.width, height = viewport.height) create a bitmap with the system font applied, ready for text

Colour effects

  • sprite.alpha / sprite.alpha = val the colour's alpha channel
  • sprite.swap_colors(map) swap the colour palette using a colour-map bitmap
  • sprite.avg_color(freq: 2) the average colour of the bitmap (sampling every freq pixels)
  • sprite.blur blur the sprite
  • sprite.outline(color) draw an outline
  • sprite.colorize(color, amount: 255) tint the solid pixels by amount (0–255)
  • sprite.glow(color, keep: true) draw a glow; keep: false drops the original bitmap

Positioning

  • sprite.center the [x, y] of the sprite's centre point
  • sprite.center!(snap: false) centre the sprite on itself, or on the viewport with snap: true
  • sprite.bottom the [x, y] of the bottom-centre point
  • sprite.bottom! anchor the sprite to its bottom centre
  • sprite.anchor(type) set the origin to a named anchor

Anchor types: :top_left, :top_middle, :top_right, :middle_left,
:middle, :middle_right, :bottom_left, :bottom_middle, :bottom_right.