Class: Avatar
core/avatar.Avatar
Avatar class for small user graphics
Table of contents
Constructors
Properties
Methods
- createAvatarData
- createBlank
- draw
- fromGraphic
- fromText
- generateIdenticon
- isEnabled
- isValid
- loadFromFile
- show
Constructors
constructor
• new Avatar()
Properties
defs
▪ Static Readonly defs: Object = AvatarDefs
Avatar dimension constants
Type declaration
| Name | Type |
|---|---|
height |
6 |
size |
120 |
width |
10 |
Defined in
Methods
createAvatarData
▸ Static createAvatarData(data): AvatarData
Create avatar data object
Parameters
| Name | Type |
|---|---|
data |
string |
Returns
Defined in
createBlank
▸ Static createBlank(fgColor?, bgColor?): string
Create a blank avatar with specified colors
Parameters
| Name | Type | Default value |
|---|---|---|
fgColor |
number |
CGA.LIGHTGRAY |
bgColor |
number |
CGA.BLACK |
Returns
string
Defined in
draw
▸ Static draw(output, data, x, y, right?, top?): boolean
Draw avatar at absolute screen position using Graphic.draw()
Parameters
| Name | Type | Default value |
|---|---|---|
output |
IQOutput |
undefined |
data |
string |
undefined |
x |
number |
undefined |
y |
number |
undefined |
right |
boolean |
false |
top |
boolean |
false |
Returns
boolean
Defined in
fromGraphic
▸ Static fromGraphic(graphic): string
Convert a Graphic to avatar data (base64-encoded BIN) The graphic must be exactly 10x6 or will be cropped/padded
Parameters
| Name | Type |
|---|---|
graphic |
Graphic |
Returns
string
Defined in
fromText
▸ Static fromText(text, fgColor?, bgColor?): string
Create avatar from text (simple text rendering)
Parameters
| Name | Type | Default value |
|---|---|---|
text |
string |
undefined |
fgColor |
number |
CGA.WHITE |
bgColor |
number |
CGA.BLUE |
Returns
string
Defined in
generateIdenticon
▸ Static generateIdenticon(seed): string
Generate an identicon avatar from a seed string Creates a simple symmetric pattern based on the hash
Parameters
| Name | Type |
|---|---|
seed |
string |
Returns
string
Defined in
isEnabled
▸ Static isEnabled(avatar): boolean
Check if avatar data is enabled and valid
Parameters
| Name | Type |
|---|---|
avatar |
undefined | null | AvatarData |
Returns
boolean
Defined in
isValid
▸ Static isValid(data): boolean
Validate avatar data Returns true if the data is valid for use as an avatar
Parameters
| Name | Type |
|---|---|
data |
Buffer |
Returns
boolean
Defined in
loadFromFile
▸ Static loadFromFile(filename, offset?): null | string
Load avatar from a BIN file
Parameters
| Name | Type | Default value |
|---|---|---|
filename |
string |
undefined |
offset |
number |
0 |
Returns
null | string
Defined in
show
▸ Static show(output, data): boolean
Show avatar at current cursor position using console output
Parameters
| Name | Type |
|---|---|
output |
IQOutput |
data |
string |
Returns
boolean