iniquity

A re-imagining of the iconic BBS software.

View on GitHub

Class: Avatar

core/avatar.Avatar

Avatar class for small user graphics

Table of contents

Constructors

Properties

Methods

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

core/src/avatar.ts:59

Methods

createAvatarData

Static createAvatarData(data): AvatarData

Create avatar data object

Parameters

Name Type
data string

Returns

AvatarData

Defined in

core/src/avatar.ts:255


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

core/src/avatar.ts:274


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

core/src/avatar.ts:91


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

core/src/avatar.ts:156


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

core/src/avatar.ts:288


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

core/src/avatar.ts:183


isEnabled

Static isEnabled(avatar): boolean

Check if avatar data is enabled and valid

Parameters

Name Type
avatar undefined | null | AvatarData

Returns

boolean

Defined in

core/src/avatar.ts:267


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

core/src/avatar.ts:65


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

core/src/avatar.ts:230


show

Static show(output, data): boolean

Show avatar at current cursor position using console output

Parameters

Name Type
output IQOutput
data string

Returns

boolean

Defined in

core/src/avatar.ts:129