Constructor Summary
Public Constructor | ||
public |
constructor(count: number, border: boolean, borderWidth: number, color: string, borderColor: string) Creates a Saltire. |
Member Summary
Public Members | ||
public |
border: * |
|
public |
borderWidth: * |
Method Summary
Public Methods | ||
public |
Draws the Saltire on the given canvas. |
|
public |
generateSaltireBorder(seed: number): object Generate border information for the Saltire. |
|
public |
generateSaltireWidth(seed: number): number Generates a percentage width for the Saltire lines based on the seed. |
Inherited Summary
From class Division | ||
public |
color: * |
|
public |
count: * |
|
public |
limit: * |
|
public |
seed: * |
|
public |
|
Public Constructors
public constructor(count: number, border: boolean, borderWidth: number, color: string, borderColor: string) source
Creates a Saltire.
Override:
Division#constructorParams:
Name | Type | Attribute | Description |
count | number | The number of Saltires in this instance. Should typically only be one. |
|
border | boolean | A boolean value to decide whether or not to draw a border based on the global seed setting. |
|
borderWidth | number | A number value to use when generating border width. This number is used in addition to the randomly generated border width determined by the seed. |
|
color | string | A hexadecimal color string. |
|
borderColor | string | A hexadecimal color string. |
Example:
// Instantiates a Saltire without a border.
const saltire = new Saltire();
// Instantiates a Saltire with a border.
const saltireWithBorder = new Saltire(true);
Public Methods
public draw(ctx: object) source
Draws the Saltire on the given canvas.
Params:
Name | Type | Attribute | Description |
ctx | object | A canvas Context. |
Example:
// Draws a Saltire on the canvas.
const saltire = new Saltire();
saltire.drawSaltire(ctx);
public generateSaltireBorder(seed: number): object source
Generate border information for the Saltire.
Params:
Name | Type | Attribute | Description |
seed | number | A pseudo-random string generated based on a string value. |
Example:
// Returns an object with width and color keys.
const border = this.generateSaltireBorder(.123747918512398745);
See:
- {@link module:flag-generator/utilities~generateSeed|generateSeed()} for more info about the seed.
public generateSaltireWidth(seed: number): number source
Generates a percentage width for the Saltire lines based on the seed.
Params:
Name | Type | Attribute | Description |
seed | number | A pseudo-random string generated based on a string value. |
Example:
// Returns 81, meaning 81%
saltire.generateWidth(0.8112494706388412);
See:
- {@link module:flag-generator/utilities~generateSeed|generateSeed()} for more info about the seed.