WebAssets

clay.base.BaseAssetsclay.web.WebAssets (Class)

Instance Members

isSynchronous(): Bool
Returns
Bool

loadImage(path: String, ?components: Int = 4, ?async: Bool = false, ?callback: Function): clay.Image
Name Type Default
path String
components Int 4
async Bool false
callback Function (optional)
Returns
clay.Image

decodePngWithPngjs(bytes: clay.buffers.Uint8Array, ?pot: Bool = true): clay.Image
Name Type Default
bytes clay.buffers.Uint8Array
pot Bool true
Returns
clay.Image

decodeImageFromElement(elem: js.html.ImageElement, ?pot: Bool = true): clay.Image

Create an image info (padded to POT) from a given Canvas or Image element.

Name Type Default
elem js.html.ImageElement
pot Bool true
Returns
clay.Image

imageFromBytes(bytes: clay.buffers.Uint8Array, ext: String, ?components: Int = 4, ?pot: Bool = true, ?callback: Function): clay.Image
Name Type Default
bytes clay.buffers.Uint8Array
ext String
components Int 4
pot Bool true
callback Function (optional)
Returns
clay.Image

imageFromBytesUsingImageElement(bytes: clay.buffers.Uint8Array, ext: String, ?components: Int = 4, ?pot: Bool = true, ?callback: Function): clay.Image
Name Type Default
bytes clay.buffers.Uint8Array
ext String
components Int 4
pot Bool true
callback Function (optional)
Returns
clay.Image

pixelsToPngData(width: Int, height: Int, pixels: clay.buffers.Uint8Array, ?callback: Function): Void

Return PNG data from the given pixels

Name Type Default
width Int
height Int
pixels clay.buffers.Uint8Array
callback Function (optional)

paddedBytesFromPixels(width: Int, height: Int, widthPadded: Int, heightPadded: Int, source: clay.buffers.Uint8Array): clay.buffers.Uint8Array

Return a padded array of bytes from raw image pixels

Name Type
width Int
height Int
widthPadded Int
heightPadded Int
source clay.buffers.Uint8Array
Returns
clay.buffers.Uint8Array

paddedBytesFromElement(width: Int, height: Int, widthPadded: Int, heightPadded: Int, source: js.html.ImageElement): clay.buffers.Uint8Array

Return a padded array of bytes from an image/canvas element.

Name Type
width Int
height Int
widthPadded Int
heightPadded Int
source js.html.ImageElement
Returns
clay.buffers.Uint8Array

new(app: clay.Clay): Void
Name Type
app clay.Clay

Private Members

POT: Bool

testedElectronPngjsAvailability: Bool

electronRemote: Dynamic

pngjs: Dynamic

bindElectronPngjs(): Void

nearestPowerOfTwo(value: Int): Int
Name Type
value Int
Returns
Int