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:#
| Name | Type | Description |
|---|---|---|
bin_bitmap_list | string[] | 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:#
| Name | Type | Description |
|---|---|---|
bits? | null | number | Each 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:#
| Name | Type | Default value | Description |
|---|---|---|---|
bitmap | Bitmap | - | 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:#
| Name | Type | Description |
|---|---|---|
w | number | Width |
h | number | Height |
xoff? | null | number | X offset |
yoff? | null | number | Y 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:#
| Name | Type | Description |
|---|---|---|
context | CanvasContext | Canvas 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:#
| Name | Type | Description |
|---|---|---|
x? | number | Multiplier in x (right) direction |
y? | number | Multiplier 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:#
| Name | Type | Description |
|---|---|---|
mode? | null | 0 | 1 | Mode |
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:#
| Name | Type | Description |
|---|---|---|
bitmap | Bitmap | The 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:#
| Name | Type | Description |
|---|---|---|
substr | string | number | Substring to be replaced |
newsubstr | string | number | New 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:#
| Name | Type | Description |
|---|---|---|
xoff? | null | number | Shadow's offset in x (right) direction |
yoff? | null | number | Shadow'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:#
| Name | Type |
|---|---|
T | null | 0 | 1 | 2 | 4 | 3 | 5 |
Parameters:#
| Name | Type | Description |
|---|---|---|
datatype? | T | Output 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:#
| Name | Type |
|---|---|
bitmap | string[] |
w | number |
h | number |
xoff | number |
yoff | number |
Returns: string[]
Defined in: bdfparser.ts:1347
__crop_string#
â–¸ Private Static__crop_string(s: string, start: number, length: number): string
Parameters:#
| Name | Type |
|---|---|
s | string |
start | number |
length | number |
Returns: string
Defined in: bdfparser.ts:1260
__enlarge_bindata#
â–¸ Private Static__enlarge_bindata(bindata: string[], x?: null | number, y?: null | number): string[]
Parameters:#
| Name | Type |
|---|---|
bindata | string[] |
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:#
| Name | Type |
|---|---|
list1 | string[] |
list2 | string[] |
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:#
| Name | Type |
|---|---|
s1 | string |
s2 | string |
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:#
| Name | Type | Default value | Description |
|---|---|---|---|
bitmaplist | Bitmap[] | - | 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