# WebImage

#### new WebImage(filename)

##### Parameters:

Name | Type | Description
--- | --- | ---
`filename` | string | Filepath to the image

Source:
  - graphics/webimage.js, line 19

### Extends

- Thing

### Methods

#### checkDimensions()

Reinforce the dimensions of the WebImage based on the image it displays.

Source:
  - graphics/webimage.js, line 78

#### containsPoint(x, y) → {boolean}

Checks if the passed point is contained in the WebImage.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Overrides:
  - Thing#containsPoint
Source:
  - graphics/webimage.js, line 127

##### Returns:

Whether the passed point is contained in the WebImage.

Type
  boolean

#### draw(__graphics__)

Draws the WebImage in the canvas.

##### Parameters:

Name | Type | Description
--- | --- | ---
`__graphics__` | CodeHSGraphics | Instance of the __graphics__ module.

Overrides:
  - Thing#draw
Source:
  - graphics/webimage.js, line 89

#### getAlpha(x, y) → {integer}

Get the alpha value at a given location in the image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Source:
  - graphics/webimage.js, line 215

##### Returns:

An integer between 0 and 255.

Type
  integer

#### getBlue(x, y) → {integer}

Get the blue value at a given location in the image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Source:
  - graphics/webimage.js, line 205

##### Returns:

An integer between 0 and 255.

Type
  integer

#### getBorderColor() → {Color}

Gets the border color of a Thing.

Inherited From:
  - Thing#getBorderColor
Source:
  - graphics/thing.js, line 142

##### Returns:

The color of the Thing's border.

Type
  Color

#### getBorderWidth() → {number}

Gets the width of the Thing's border.

Inherited From:
  - Thing#getBorderWidth
Source:
  - graphics/thing.js, line 163

##### Returns:

The width of the Thing's border.

Type
  number

#### getColor() → {Color}

Gets the color of a Thing.

Inherited From:
  - Thing#getColor
Source:
  - graphics/thing.js, line 118

##### Returns:

The destination y coordinate of this Thing.

Type
  Color

#### getData()

Assign the ImageData of the canvas at the position of the image, essentially assigning the ImageData. Read more at https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/getImageData

Source:
  - graphics/webimage.js, line 115

#### getGreen(x, y) → {integer}

Get the green value at a given location in the image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Source:
  - graphics/webimage.js, line 195

##### Returns:

An integer between 0 and 255.

Type
  integer

#### getHeight() → {number}

Gets the height of the WebImage.

Source:
  - graphics/webimage.js, line 144

##### Returns:

Height of the WebImage.

Type
  number

#### getPixel(x, y) → {integer}

Gets a pixel at the given x and y coordinates. Read more here: https://developer.mozilla.org/en-US/docs/Web/API/ImageData/data

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Source:
  - graphics/webimage.js, line 168

##### Returns:

An integer between 0 and 255.

Type
  integer

#### getRed(x, y) → {integer}

Get the red value at a given location in the image.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.

Source:
  - graphics/webimage.js, line 185

##### Returns:

An integer between 0 and 255.

Type
  integer

#### getType() → {type}

Returns the type of a Thing.

Inherited From:
  - Thing#getType
Source:
  - graphics/thing.js, line 73

##### Returns:

The type of the Thing.

Type
  type

#### getWidth() → {number}

Gets the width of the WebImage.

Source:
  - graphics/webimage.js, line 136

##### Returns:

Width of the WebImage.

Type
  number

#### getX() → {number}

Gets the x position of the Thing.

Inherited From:
  - Thing#getX
Source:
  - graphics/thing.js, line 190

##### Returns:

The x position of the Thing.

Type
  number

#### getY() → {number}

Gets the y position of the Thing.

Inherited From:
  - Thing#getY
Source:
  - graphics/thing.js, line 198

##### Returns:

The y position of the Thing.

Type
  number

#### hasBorder() → {boolean}

Returns if a Thing has a border.

Inherited From:
  - Thing#hasBorder
Source:
  - graphics/thing.js, line 53

##### Returns:

True if the Thing has a border.

Type
  boolean

#### isFilled() → {boolean}

Returns if a Thing is filled.

Inherited From:
  - Thing#isFilled
Source:
  - graphics/thing.js, line 33

##### Returns:

True if the Thing is filled.

Type
  boolean

#### loaded(callback)

Set a function to be called when the WebImage is loaded.

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | function | A function

Source:
  - graphics/webimage.js, line 49

#### move(dx, dy)

Changes the possition of a thing by a specified x and y amount.

##### Parameters:

Name | Type | Description
--- | --- | ---
`dx` | number | The resulting change in the Thing's x position.
`dy` | number | The resulting change in the Thing's y position.

Inherited From:
  - Thing#move
Source:
  - graphics/thing.js, line 172

#### setAlpha(x, y, val)

Set the alpha value at a given location in the image to `val`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.
`val` | integer | The desired value of the alpha component at the pixel. Must be between 0 and 255.

Source:
  - graphics/webimage.js, line 274

#### setBlue(x, y, val)

Set the blue value at a given location in the image to `val`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.
`val` | integer | The desired value of the blue component at the pixel. Must be between 0 and 255.

Source:
  - graphics/webimage.js, line 262

#### setBorder(hasBorder)

Sets a Thing object to filled. Throws an error if an argument is not passed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`hasBorder` | bool | A boolean of whether or not Thing has a border.

Inherited From:
  - Thing#setBorder
Source:
  - graphics/thing.js, line 42

#### setBorderColor(color)

Sets the border color of a Thing. Throws an error if there are fewer than 1 params or if the param is undefined.

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | Color | The resulting color of the Thing's border.

Inherited From:
  - Thing#setBorderColor
Source:
  - graphics/thing.js, line 128

#### setBorderWidth(width)

Sets the width of a Thing's border. Throws an error if there is not 1 argument.

##### Parameters:

Name | Type | Description
--- | --- | ---
`width` | number | The resulting width of the Thing's border.

Inherited From:
  - Thing#setBorderWidth
Source:
  - graphics/thing.js, line 151

#### setColor(color)

Sets the color of a Thing. Throws an error if there are fewer than 1 params or if the param is undefined.

##### Parameters:

Name | Type | Description
--- | --- | ---
`color` | Color | The resulting color of Thing.

Inherited From:
  - Thing#setColor
Source:
  - graphics/thing.js, line 104

#### setFilled(filled)

Sets a Thing object to filled. Throws an error if an argument is not passed.

##### Parameters:

Name | Type | Description
--- | --- | ---
`filled` | bool | A boolean of whether or not Thing is filled.

Inherited From:
  - Thing#setFilled
Source:
  - graphics/thing.js, line 22

#### setGreen(x, y, val)

Set the green value at a given location in the image to `val`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.
`val` | integer | The desired value of the green component at the pixel. Must be between 0 and 255.

Source:
  - graphics/webimage.js, line 251

#### setImage(filename)

Set the image of the WebImage.

##### Parameters:

Name | Type | Description
--- | --- | ---
`filename` | string | Filepath to the image

Source:
  - graphics/webimage.js, line 57

#### setPixel(x, y, component, val)

Set the `component` value at a given location in the image to `val`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.
`component` | integer | Integer representing the color value to be set. R, G, B = 0, 1, 2, respectively.
`val` | integer | The desired value of the `component` at the pixel. Must be between 0 and 255.

Source:
  - graphics/webimage.js, line 228

#### setPosition(x, y)

Sets the position of a Thing. Throws an error if there are fewer than 2 params or if they are not numbers.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The destination x coordinate of this Thing.
`y` | number | The destination y coordinate of this Thing.

Inherited From:
  - Thing#setPosition
Source:
  - graphics/thing.js, line 84

#### setRed(x, y, val)

Set the red value at a given location in the image to `val`.

##### Parameters:

Name | Type | Description
--- | --- | ---
`x` | number | The x coordinate of the point being tested.
`y` | number | The y coordinate of the point being tested.
`val` | integer | The desired value of the red component at the pixel. Must be between 0 and 255.

Source:
  - graphics/webimage.js, line 240

#### setSize(width, height)

Sets the size of the WebImage.

##### Parameters:

Name | Type | Description
--- | --- | ---
`width` | number | The desired width of the resulting WebImage.
`height` | number | The desired height of the resulting WebImage.

Source:
  - graphics/webimage.js, line 153

#### setType(type)

Sets a Thing object's type. Questionable of whether or not this method is used.

##### Parameters:

Name | Type | Description
--- | --- | ---
`type` | type | A type to set the Thing to.

Inherited From:
  - Thing#setType
Source:
  - graphics/thing.js, line 62