Home Reference Source Test

Function

Static Public Summary
public

clamp(value: number, min: number, max: number): number

Clamping is the process of limiting a position to an area

public

colorStringToUint32(str: *): *

public

Decode JPEG From Stream

public

decodePNGFromStream(instream: Stream): Promise<Bitmap>

Decode PNG From Stream

public

encodeJPEGToStream(img: Bitmap, outstream: Stream, Number: Int): Promise<void>

Encode JPEG To Stream

public

encodePNGToStream(bitmap: Bitmap, outstream: Stream): Promise<void>

Encode the PNG image to output stream

public

make(w: number, h: number, options: object): Bitmap

Create a new bitmap image

public

Process Text Path

public

processTextPath(ctx: Context, text: string, x: number, y: number, fill: boolean): void

Process Text Path

public

registerFont(binaryPath: string, family: string, weight: number, style: string, variant: string): font

Register Font

Static Public

public clamp(value: number, min: number, max: number): number source

import {clamp} from 'pureimage/src/util.js'

Clamping is the process of limiting a position to an area

Params:

NameTypeAttributeDescription
value number

The value to apply the clamp restriction to

min number

Lower limit

max number

Upper limit

Return:

number

See:

public colorStringToUint32(str: *): * source

import {colorStringToUint32} from 'pureimage/src/util.js'

Params:

NameTypeAttributeDescription
str *

Return:

*

public decodeJPEGFromStream(data: Stream): Promise<Bitmap> source

import {decodeJPEGFromStream} from 'pureimage'

Decode JPEG From Stream

Decode a JPEG image from an incoming stream of data

Params:

NameTypeAttributeDescription
data Stream

A readable stream to decode JPEG data from

Return:

Promise<Bitmap>

Test:

public decodePNGFromStream(instream: Stream): Promise<Bitmap> source

import {decodePNGFromStream} from 'pureimage'

Decode PNG From Stream

Decode a PNG file from an incoming readable stream

Params:

NameTypeAttributeDescription
instream Stream

A readable stream containing raw PNG data

Return:

Promise<Bitmap>

Test:

public encodeJPEGToStream(img: Bitmap, outstream: Stream, Number: Int): Promise<void> source

import {encodeJPEGToStream} from 'pureimage'

Encode JPEG To Stream

Encode the JPEG image to output stream

Params:

NameTypeAttributeDescription
img Bitmap

An instance of Bitmap to be encoded to JPEG, img.data must be a buffer of raw JPEG data

outstream Stream

The stream to write the raw JPEG buffer to

Number Int

between 0 and 100 setting the JPEG quality

Return:

Promise<void>

Test:

public encodePNGToStream(bitmap: Bitmap, outstream: Stream): Promise<void> source

import {encodePNGToStream} from 'pureimage'

Encode the PNG image to output stream

Params:

NameTypeAttributeDescription
bitmap Bitmap

An instance of Bitmap to be encoded to PNG, bitmap.data must be a buffer of raw PNG data

outstream Stream

The stream to write the PNG file to

Return:

Promise<void>

Test:

public make(w: number, h: number, options: object): Bitmap source

import {make} from 'pureimage'

Create a new bitmap image

Params:

NameTypeAttributeDescription
w number

Image width

h number

Image height

options object

Options to be passed to Bitmap

Return:

Bitmap

public measureText(ctx: Context, text: string): object source

import {measureText} from 'pureimage/src/text.js'

Process Text Path

Params:

NameTypeAttributeDescription
ctx Context

The Context to paint on

text string

The name to give the font

Return:

object

public processTextPath(ctx: Context, text: string, x: number, y: number, fill: boolean): void source

import {processTextPath} from 'pureimage/src/text.js'

Process Text Path

Params:

NameTypeAttributeDescription
ctx Context

The Context to paint on

text string

The text to write to the given Context

x number

X position

y number

Y position

fill boolean

Indicates wether or not the font should be filled

Return:

void

public registerFont(binaryPath: string, family: string, weight: number, style: string, variant: string): font source

import {registerFont} from 'pureimage/src/text.js'

Register Font

Params:

NameTypeAttributeDescription
binaryPath string

Path to the font binary file(.eot, .ttf etc.)

family string

The name to give the font

weight number

The font weight to use

style string

Font style

variant string

Font variant

Return:

font

Font instance