Options
All
  • Public
  • Public/Protected
  • All
Menu

Class MaxRectsPacker<T>

Type parameters

Hierarchy

  • MaxRectsPacker

Index

Constructors

Properties

Accessors

Methods

Object literals

Constructors

constructor

  • new MaxRectsPacker(width?: number, height?: number, padding?: number, options?: IOption): MaxRectsPacker
  • Creates an instance of MaxRectsPacker.

    memberof

    MaxRectsPacker

    Parameters

    • Default value width: number = EDGE_MAX_VALUE

      of the output atlas (default is 4096)

    • Default value height: number = EDGE_MAX_VALUE

      of the output atlas (default is 4096)

    • Default value padding: number = 0

      between glyphs/images (default is 0)

    • Default value options: IOption = {}

    Returns MaxRectsPacker

Properties

bins

bins: Bin<T>[]

The Bin array added to the packer

type

{Bin[]}

memberof

MaxRectsPacker

height

height: number

of the output atlas (default is 4096)

padding

padding: number

between glyphs/images (default is 0)

width

width: number

of the output atlas (default is 4096)

Accessors

currentBinIndex

  • get currentBinIndex(): number
  • Return current functioning bin index, perior to this wont accept any new elements

    readonly
    type

    {number}

    memberof

    MaxRectsPacker

    Returns number

dirty

  • get dirty(): boolean
  • Returns dirty status of all child bins

    readonly
    type

    {boolean}

    memberof

    MaxRectsPacker

    Returns boolean

rects

  • get rects(): T[]
  • Return all rectangles in this packer

    readonly
    type

    {T[]}

    memberof

    MaxRectsPacker

    Returns T[]

Methods

add

  • add(width: number, height: number, data: any): T
  • add(rect: T): T
  • Add a bin/rectangle object with data to packer

    memberof

    MaxRectsPacker

    Parameters

    • width: number

      of the input bin/rectangle

    • height: number

      of the input bin/rectangle

    • data: any

      custom data object

    Returns T

  • Add a bin/rectangle object extends IRectangle to packer

    template

    T Generic type extends IRectangle interface

    memberof

    MaxRectsPacker

    Parameters

    • rect: T

      the rect object add to the packer bin

    Returns T

addArray

  • addArray(rects: T[]): void
  • Add an Array of bins/rectangles to the packer.

    Javascript: Any object has property: { width, height, ... } is accepted.

    Typescript: object shall extends MaxrectsPacker.IRectangle.

    note: object has hash property will have more stable packing result

    memberof

    MaxRectsPacker

    Parameters

    • rects: T[]

      Array of bin/rectangles

    Returns void

load

  • load(bins: IBin[]): void
  • Load bins to the packer, overwrite exist bins

    memberof

    MaxRectsPacker

    Parameters

    • bins: IBin[]

      MaxRectsBin objects

    Returns void

next

  • next(): number
  • Stop adding new element to the current bin and return a new bin.

    note: After calling next() all elements will no longer added to previous bins.

    memberof

    MaxRectsPacker

    Returns number

repack

  • repack(quick?: boolean): void
  • Repack all elements inside bins

    memberof

    MaxRectsPacker

    Parameters

    • Default value quick: boolean = true

    Returns void

reset

  • reset(): void
  • Reset entire packer to initial states, keep settings

    memberof

    MaxRectsPacker

    Returns void

save

Object literals

options

options: object

Options for MaxRect Packer

property

{boolean} options.smart Smart sizing packer (default is true)

property

{boolean} options.pot use power of 2 sizing (default is true)

property

{boolean} options.square use square size (default is false)

property

{boolean} options.allowRotation allow rotation packing (default is false)

property

{boolean} options.tag allow auto grouping based on rect.tag (default is false)

property

{boolean} options.exclusiveTag tagged rects will have dependent bin, if set to false, packer will try to put tag rects into the same bin (default is true)

property

{boolean} options.border atlas edge spacing (default is 0)

property

{PACKING_LOGIC} options.logic MAX_AREA or MAX_EDGE based sorting logic (default is MAX_EDGE)

export
interface

Option

allowRotation

allowRotation: false = false

border

border: number = 0

exclusiveTag

exclusiveTag: true = true

logic

logic: MAX_EDGE = PACKING_LOGIC.MAX_EDGE

pot

pot: true = true

smart

smart: true = true

square

square: false = false

tag

tag: false = false

Generated using TypeDoc