Class: Bitmap#

Bitmap object

see online docs: https://font.tomchen.org/bdfparser_js/bitmap

Hierarchy#

  • Bitmap

Constructors#

constructor#

+ new Bitmap(bin_bitmap_list: string[]): Bitmap

Initialize a Bitmap object. Load binary bitmap data (array of strings).

see online docs: https://font.tomchen.org/bdfparser_js/bitmap

Parameters:#

NameTypeDescription
bin_bitmap_liststring[]Binary bitmap data

Returns: Bitmap

Defined in: bdfparser.ts:1188

Properties#

bindata#

bindata: string[]

Defined in: bdfparser.ts:1188

Methods#

bytepad#

bytepad(bits?: null | number): Bitmap

Pad each line (row) to multiple of 8 (or other numbers) bits/pixels, with '0's.

Do this before using the bitmap for a glyph in a BDF font.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#bytepad

Parameters:#

NameTypeDescription
bits?null | numberEach line should be padded to multiple of how many bits/pixels

Returns: Bitmap

The Bitmap object itself, which now has the altered bitmap as its .bindata

Defined in: bdfparser.ts:1734


clone#

clone(): Bitmap

Get a deep copy / clone of the Bitmap object.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#clone

Returns: Bitmap

A deep copy of the original Bitmap object

Defined in: bdfparser.ts:1256


concat#

concat(bitmap: Bitmap, options?: { align?: undefined | null | 0 | 1 ; direction?: undefined | null | 0 | 1 | -1 | 2 ; offset?: undefined | null | number }): Bitmap

Concatenate another Bitmap objects to the current one.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#concat

Parameters:#

NameTypeDefault valueDescription
bitmapBitmap-Bitmap to concatenate
options{ align?: undefined | null | 0 | 1 ; direction?: undefined | null | 0 | 1 | -1 | 2 ; offset?: undefined | null | number }...-

Returns: Bitmap

The Bitmap object itself, which now has the combined bitmap as its .bindata

Defined in: bdfparser.ts:1538


crop#

crop(w: number, h: number, xoff?: null | number, yoff?: null | number): Bitmap

Crop and/or extend the bitmap.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#crop

Parameters:#

NameTypeDescription
wnumberWidth
hnumberHeight
xoff?null | numberX offset
yoff?null | numberY offset

Returns: Bitmap

The Bitmap object itself, which now has only the specified area as its .bindata

Defined in: bdfparser.ts:1380


draw2canvas#

draw2canvas(context: CanvasContext, pixelcolors?: null | Record<0 | 1 | 2, null | string>): Bitmap

Draw the bitmap to HTML canvas

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#draw2canvas

Parameters:#

NameTypeDescription
contextCanvasContextCanvas 2D context (canvas.getContext("2d"))
pixelcolors?null | Record<0 | 1 | 2, null | string>Object mapping '0'/'1'/'2' in the bitmap data to color

Returns: Bitmap

The Bitmap object itself

Defined in: bdfparser.ts:1806


enlarge#

enlarge(x?: number, y?: number): Bitmap

Enlarge a Bitmap object, by multiplying every pixel in x (right) direction and in y (top) direction.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#enlarge

Parameters:#

NameTypeDescription
x?numberMultiplier in x (right) direction
y?numberMultiplier in y (top) direction

Returns: Bitmap

The Bitmap object itself, which now has the enlarged bitmap as its .bindata

Defined in: bdfparser.ts:1593


glow#

glow(mode?: null | 0 | 1): Bitmap

Add glow effect to the shape in the bitmap.

The glowing area is one pixel up, right, bottom and left to the original pixels (corners will not be filled in default mode 0 but will in mode 1), and will be filled by '2's.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#glow

Parameters:#

NameTypeDescription
mode?null | 0 | 1Mode

Returns: Bitmap

The Bitmap object itself, which now has a bitmap of the original shape with glow effect as the Bitmap object's .bindata

Defined in: bdfparser.ts:1690


height#

height(): number

Get the height of the bitmap.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#height

Returns: number

Height of the bitmap

Defined in: bdfparser.ts:1245


overlay#

overlay(bitmap: Bitmap): Bitmap

Overlay another bitmap over the current one.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#overlay

Parameters:#

NameTypeDescription
bitmapBitmapThe incoming bitmap to overlay over the current one

Returns: Bitmap

The Bitmap object itself, which now has the combined bitmap as its .bindata

Defined in: bdfparser.ts:1396


replace#

replace(substr: string | number, newsubstr: string | number): Bitmap

Replace a string by another in the bitmap.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#replace

Parameters:#

NameTypeDescription
substrstring | numberSubstring to be replaced
newsubstrstring | numberNew substring as the replacement

Returns: Bitmap

The Bitmap object itself, which now has the altered bitmap as its .bindata

Defined in: bdfparser.ts:1608


repr#

repr(): string

Gets a programmer-readable (multi-line) string representation of the Bitmap object.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#repr

Returns: string

String representation

Defined in: bdfparser.ts:1223


shadow#

shadow(xoff?: null | number, yoff?: null | number): Bitmap

Add shadow to the shape in the bitmap.

The shadow will be filled by '2's.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#shadow

Parameters:#

NameTypeDescription
xoff?null | numberShadow's offset in x (right) direction
yoff?null | numberShadow's offset in y (top) direction

Returns: Bitmap

The Bitmap object itself, which now has a bitmap of the original shape with its shadow as the Bitmap object's .bindata

Defined in: bdfparser.ts:1646


toString#

toString(): string

Gets a human-readable (multi-line) string representation of the Bitmap object.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#tostring

Returns: string

String representation

Defined in: bdfparser.ts:1208


todata#

todata<T>(datatype?: T): TodataFuncRetType<T>

Get the bitmap's data in the specified type and format.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#todata

Type parameters:#

NameType
Tnull | 0 | 1 | 2 | 4 | 3 | 5

Parameters:#

NameTypeDescription
datatype?TOutput data type

Returns: TodataFuncRetType<T>

Bitmap data in the specified type (list or string) and format

Defined in: bdfparser.ts:1754


width#

width(): number

Get the width of the bitmap.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#width

Returns: number

Width of the bitmap

Defined in: bdfparser.ts:1234


__crop_bitmap#

Private Static__crop_bitmap(bitmap: string[], w: number, h: number, xoff: number, yoff: number): string[]

Parameters:#

NameType
bitmapstring[]
wnumber
hnumber
xoffnumber
yoffnumber

Returns: string[]

Defined in: bdfparser.ts:1347


__crop_string#

Private Static__crop_string(s: string, start: number, length: number): string

Parameters:#

NameType
sstring
startnumber
lengthnumber

Returns: string

Defined in: bdfparser.ts:1260


__enlarge_bindata#

Private Static__enlarge_bindata(bindata: string[], x?: null | number, y?: null | number): string[]

Parameters:#

NameType
bindatastring[]
x?null | number
y?null | number

Returns: string[]

Defined in: bdfparser.ts:1556


__listofstr_offset_concat#

Private Static__listofstr_offset_concat(list1: string[], list2: string[], offset?: null | number): string[]

Parameters:#

NameType
list1string[]
list2string[]
offset?null | number

Returns: string[]

Defined in: bdfparser.ts:1306


__string_offset_concat#

Private Static__string_offset_concat(s1: string, s2: string, offset?: null | number): string

Parameters:#

NameType
s1string
s2string
offset?null | number

Returns: string

Defined in: bdfparser.ts:1279


concatall#

Staticconcatall(bitmaplist: Bitmap[], options?: { align?: undefined | null | 0 | 1 ; direction?: undefined | null | 0 | 1 | -1 | 2 ; offsetlist?: undefined | null | number[] }): Bitmap

Concatenate all Bitmap objects in an array.

see online docs: https://font.tomchen.org/bdfparser_js/bitmap#bitmapconcatall

Parameters:#

NameTypeDefault valueDescription
bitmaplistBitmap[]-List of bitmaps to concatenate
options{ align?: undefined | null | 0 | 1 ; direction?: undefined | null | 0 | 1 | -1 | 2 ; offsetlist?: undefined | null | number[] }...-

Returns: Bitmap

Bitmap object

Defined in: bdfparser.ts:1428