Home Reference Source
public class | source

Chevron

Extends:

Division → Chevron

Chevron pattern.

Constructor Summary

Public Constructor
public

constructor(direction: string, color: string, width: number, border: boolean, borderWidth: number, borderColor: string)

Creates a Chevron.

Member Summary

Public Members
public

border: *

public
public
public
public

width: *

Method Summary

Public Methods
public

draw(ctx: object)

Draws the Chevron division on a canvas.

public

Returns the proper draw function instructions for a given direction.

public

Generates the draw instructions for the fesswise and fesswiseReversed directions.

public

Generates the draw instructions for the palewise and palewiseReversed directions.

public

Generate a direction value for the Chevron.

Inherited Summary

From class Division
public

color: *

public

count: *

public

limit: *

public

seed: *

public

Public Constructors

public constructor(direction: string, color: string, width: number, border: boolean, borderWidth: number, borderColor: string) source

Creates a Chevron.

Override:

Division#constructor

Params:

NameTypeAttributeDescription
direction string

The orientation of the Pall. One of: fesswise, palewise, fesswiseReversed, palewiseReverse.

color string

A hexadecimal color string.

width number

A width value for drawing the division.

border boolean

Whether or not to draw a border around the Pall.

borderWidth number

The width of the border.

borderColor string

A hexadecimal color string.

Example:

// Creates a horizontally oriented, white Pall with a black border.
const pall = new Pall('fesswise', '#ffffff', true, 20, '#000000');

Public Members

public border: * source

public borderColor: * source

public borderWidth: * source

public direction: * source

public width: * source

Public Methods

public draw(ctx: object) source

Draws the Chevron division on a canvas.

Params:

NameTypeAttributeDescription
ctx object

An object containing a canvas context.

Example:

// Draws the Chevron division on the canvas.
const chevron = new Chevron();
chevron.draw(ctx);

public drawInstructions(direction: string): Function source

Returns the proper draw function instructions for a given direction.

Params:

NameTypeAttributeDescription
direction string

One of: 'fesswise', 'palewise', 'fesswiseReversed', 'palewiseReversed'.

Return:

Function

The draw instruction function corresponding to the direction.

Example:

// Returns drawInstructionsPalewise();
const chevron = new Chevron();
chevron.drawInstructions('palewise');

public drawInstructionsFesswise(reversed: boolean): Array source

Generates the draw instructions for the fesswise and fesswiseReversed directions.

Params:

NameTypeAttributeDescription
reversed boolean

Whether or not to return the reverse draw instructions.

Return:

Array

An array of objects containing canvas drawing instructions.

Example:

// Returns an instruction set for the fesswise direction based on the flag dimensions.
// [
//     {moveTo: [x, y]},
//     {lineTo: [x, y]},
//     {lineTo: [x, y]},
// ]
const chevron = new Chevron();
const instructions = chevron.drawInstructionsFesswise();

public drawInstructionsPalewise(reversed: boolean): Array source

Generates the draw instructions for the palewise and palewiseReversed directions.

Params:

NameTypeAttributeDescription
reversed boolean

Whether or not to return the reverse draw instructions.

Return:

Array

An array of objects containing canvas drawing instructions.

Example:

// Returns an instruction set for the palewise direction based on the flag dimensions.
// [
//     {moveTo: [x, y]},
//     {lineTo: [x, y]},
//     {lineTo: [x, y]},
// ]
const chevron = new Chevron();
const instructions = chevron.drawInstructionsPalewise();

public generateDirection(seed: number): string source

Generate a direction value for the Chevron.

Params:

NameTypeAttributeDescription
seed number

The seed number used for generated values.

Return:

string

One of: 'pallwise', 'fesswise', 'pallwiseReversed', 'fesswiseReversed'.

Example:

// Returns 'palewiseReversed'
const newChevron = new Chevron();
newPale.generateDirection(.1337)

TODO:

  • Rethink the directions, use some kind of probability or something more elegant than this.