SpriteSheet

Library to provide support for creating and splitting spritesheets.


Source: pkg/lua/lib/spritesheet.go | Import: spritesheet

Modeled after the 'To Frames' functionality in GameMaker.

Functions


sheet

sheet(count, width, height, perRow, offsets?, hsep?, vsep?) -> struct<spritesheet.Spritesheet>

Arguments

  • count int
  • width int
  • height int
  • perRow int
  • offsets struct<spritesheet.Offset>
  • hsep int
  • vsep int
Return Values

  • struct<spritesheet.Spritesheet>
offset

offset(hpixel, vpixel, hcell, vcell, index) -> struct<spritesheet.Offset>

Arguments

  • hpixel int
  • vpixel int
  • hcell int
  • vcell int
  • index int
Return Values

  • struct<spritesheet.Offset>
offset_pixel

offset_pixel(hpixel, vpixel) -> struct<spritesheet.Offset>

Arguments

  • hpixel int
  • vpixel int
Return Values

  • struct<spritesheet.Offset>
offset_cell

offset_cell(hcell, vcell) -> struct<spritesheet.Offset>

Arguments

  • hcell int
  • vcell int
Return Values

  • struct<spritesheet.Offset>
offset_index

offset_index(index) -> struct<spritesheet.Offset>

Arguments

  • index int
Return Values

  • struct<spritesheet.Offset>
to_frames

to_frames(id, name, spritesheet, nocopy?) -> []int<collection.IMAGE>

Arguments

  • id int<collection.IMAGE>
  • name string - Will be prefixed using the frame index as '%d_name'.
  • spritesheet struct<spritesheet.Spritesheet>
  • nocopy bool
Return Values

  • []int<collection.IMAGE>
to_frames_cached

to_frames_cached(id, spritesheet, nocopy?) -> []int<collection.CRATE_CACHEDIMAGE>

@blocking
Arguments

  • id int<collection.IMAGE>
  • spritesheet struct<spritesheet.Spritesheet>
  • nocopy bool
Return Values

  • []int<collection.CRATE_CACHEDIMAGE>
to_frames_into_cached

to_frames_into_cached(id, ids, spritesheet, nocopy?)

@blocking
Arguments

  • id int<collection.IMAGE>
  • ids []int<collection.CRATE_CACHEDIMAGE> - Must be the same length as the amount of frames in the spritesheet.
  • spritesheet struct<spritesheet.Spritesheet>
  • nocopy bool
Return Values

  • []int<collection.CRATE_CACHEDIMAGE>
from_frames

from_frames(ids, name, model, encoding, spritesheet) -> int<collection.IMAGE>

Arguments

  • ids []int<collection.IMAGE>
  • name string
  • model int<image.ColorModel>
  • encoding int<image.Encoding>
  • spritesheet struct<spritesheet.Spritesheet>
Return Values

  • int<collection.IMAGE>
from_frames_into

from_frames_into(ids, id, model, spritesheet)

Arguments

  • ids []int<collection.IMAGE>
  • id int<collection.IMAGE>
  • model int<image.ColorModel>
  • spritesheet struct<spritesheet.Spritesheet>
extract

extract(id, name, spritesheet_in, spritesheet_out, nocopy?) -> int<collection.IMAGE>

Note it is more efficient to exclude frames using index and count from spritesheet_in than from spritesheet_out. This prevents them from being sub-imaged completely.

Arguments

  • id int<collection.IMAGE>
  • name string
  • spritesheet_in struct<spritesheet.Spritesheet> - The spritesheet related to the source image.
  • spritesheet_out struct<spritesheet.Spritesheet> - The spritesheet related to the returned image.
  • nocopy bool
Return Values

  • int<collection.IMAGE>
extract_into

extract_into(id, idinto, spritesheet_in, spritesheet_out, nocopy?)

Note it is more efficient to exclude frames using index and count from spritesheet_in than from spritesheet_out. This prevents them from being sub-imaged completely.

Arguments

  • id int<collection.IMAGE>
  • idinto int<collection.IMAGE>
  • spritesheet_in struct<spritesheet.Spritesheet> - The spritesheet related to the source image.
  • spritesheet_out struct<spritesheet.Spritesheet> - The spritesheet related to the returned image.
  • nocopy bool

Structs


Spritesheet

Properties

  • count int
  • width int
  • height int
  • perRow int
  • offsets struct<spritesheet.Offset>
  • hsep int
  • vsep int
Offset

Properties

  • hpixel int
  • vpixel int
  • hcell int
  • vcell int
  • index int