# Costume

Class representing a Costume. Costumes can be added to a Sprite.

## Constructor

#### new Costume(options)

constructor - Creates a Costume to be used by Sprite objects..

Source:
  - blocklike-1.0.7.js, line 131

##### Parameters:

Name | Type | Description
--- | --- | ---
`options` | `object` | options for the costume.
Name | Type | Description
--- | --- | ---
`width` | `number` | the costume width in pixels. Default is 100.
`height` | `number` | the costume height in pixels. Default is 100.
`image` | `string` | a URI (or data URI) for the costume image.
`color` | `string` | a css color string ('#ff0000', 'red')

##### Examples

    let costume = new blockLike.Costume();

    let costume = new blockLike.Costume({
      width: 50,
      height: 50,
      color: '#A2DAFF',
      image: 'https://www.blocklike.org/images/sheep_step.png'
    });

### Extends

- Look

### Methods

#### addClass(name)

addClass - adds a css class to costume.

Overrides:
  - Look#addClass
Source:
  - blocklike-1.0.7.js, line 1219

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | `string` | the css class name to add.

##### Examples

    let costume = new blockLike.Costume();

    costume.addClass('rainbow');

    let backdrop = new blockLike.Backdrop();

    backdrop.addClass('rainbow');

#### addTo(sprite)

addTo - Adds the costume to the sprite

Source:
  - blocklike-1.0.7.js, line 181

##### Parameters:

Name | Type | Description
--- | --- | ---
`sprite` | `object` | which sprite to add the costume too.

##### Example

    let sprite = new blockLike.Sprite();
    let costume = new blockLike.Costume();

    costume.addTo(sprite);

#### css(prop, value)

css - applies a CSS rule to a Costume or Backdrop.

Overrides:
  - Look#css
Source:
  - blocklike-1.0.7.js, line 1200

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`prop` | `string` |  | the css property (e.g. color)
`value` | `string` | null | the value for the css property (e.g. #ff8833)

##### Examples

    let costume = new blockLike.Costume();

    costume.css('font-size', '16px');

    let backdrop = new blockLike.Backdrop();

    backdrop.css('cursor', 'pointer');

#### hasClass(name) → {boolean}

hasClass - is the css class applied to the costume.

Overrides:
  - Look#hasClass
Source:
  - blocklike-1.0.7.js, line 1258

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | `string` | the css class name.

##### Returns:

Type:
  `boolean`

- is the css class name on the list.

##### Examples

    let costume = new blockLike.Costume();

    costume.hasClass('rainbow') ? costume.removeClass('rainbow') : costume.addClass('rainbow');

    let backdrop = new blockLike.Backdrop();

    backdrop.hasClass('rainbow') ? backdrop.removeClass('rainbow') : backdrop.addClass('rainbow');

#### inner(html)

inner - Places an HTML element inside the costume.

Source:
  - blocklike-1.0.7.js, line 253

##### Parameters:

Name | Type | Description
--- | --- | ---
`html` | `string` | the html to insert.

##### Examples

    let costume = new blockLike.Costume();

    costume.inner('<p class="big centered rainbow">:)</p>');

    costume.inner('I like text only');

#### insert(el)

insert - Places a DOM element inside the costume.

Source:
  - blocklike-1.0.7.js, line 267

##### Parameters:

Name | Type | Description
--- | --- | ---
`el` | `object` | the DOM element.

##### Example

    let costume = new blockLike.Costume();

    costume.insert(document.getElementById('my-html-creation'));

#### removeClass(name)

removeClass - removes a css class from the costume.

Overrides:
  - Look#removeClass
Source:
  - blocklike-1.0.7.js, line 1238

##### Parameters:

Name | Type | Description
--- | --- | ---
`name` | `string` | the css class name to remove.

##### Examples

    let costume = new blockLike.Costume();

    costume.hasClass('rainbow') ? costume.removeClass('rainbow') : costume.addClass('rainbow');

    let backdrop = new blockLike.Backdrop();

    backdrop.hasClass('rainbow') ? backdrop.removeClass('rainbow') : backdrop.addClass('rainbow');

#### removeFrom(sprite)

removeFrom - Removes the costume from to the sprite

Source:
  - blocklike-1.0.7.js, line 207

##### Parameters:

Name | Type | Description
--- | --- | ---
`sprite` | `object` | which sprite to remove the costume from.

##### Example

    let sprite = new blockLike.Sprite();
    let costume = new blockLike.Costume();

    costume.addTo(sprite);
    costume.removeFrom(sprite);

#### resizeToImage()

resizeToImage - sets the width and height of the costume to that of the image file.

Source:
  - blocklike-1.0.7.js, line 223

##### Example

    let costume = new blockLike.Costume({
      image: 'https://upload.wikimedia.org/wikipedia/commons/d/d3/Sheep_in_gray.svg'
    });

    costume.resizeToImage();