# sm.color.new

Creates a new color object from another color object.

**Kind:** Function

**Environments:** Game, Terrain

## Game

### Game overload 1

``` { .lua .api-signature }
sm.color.new( color )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.color.md#new-color)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `color` | [Color](../Game-Script-Environment/Userdata/Color.md) | The color to copy. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Game-Script-Environment/Userdata/Color.md) | The created color. |

### Game overload 2

``` { .lua .api-signature }
sm.color.new( r, g, b, a? )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.color.md#new-number-number-number-number-optional)

Creates a new color object from R, G, B, A.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `r` | number | The red value. |
| `g` | number | The green value. |
| `b` | number | The blue value. |
| `a` *(optional)* | number | The alpha value. Defaults to 1.0. (Optional) |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Game-Script-Environment/Userdata/Color.md) | The created color. |

### Game overload 3

``` { .lua .api-signature }
sm.color.new( hexStr )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.color.md#new-string)

Creates a new color object from a hex string `"RRGGBBAA"`.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `hexStr` | string | The hex string. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Game-Script-Environment/Userdata/Color.md) | The created color. |

### Game overload 4

``` { .lua .api-signature }
sm.color.new( hexInt )
```

[Open the full Game reference](../Game-Script-Environment/Static-Functions/sm.color.md#new-integer)

Creates a new color object from a hex value `0xRRGGBBAA`.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `hexInt` | integer | The hex value. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Game-Script-Environment/Userdata/Color.md) | The created color. |

## Terrain

### Terrain overload 1

``` { .lua .api-signature }
sm.color.new( color )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.color.md#new-color)

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `color` | [Color](../Terrain-Script-Environment/Userdata/Color.md) | The color to copy. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Terrain-Script-Environment/Userdata/Color.md) | The created color. |

### Terrain overload 2

``` { .lua .api-signature }
sm.color.new( r, g, b, a? )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.color.md#new-number-number-number-number-optional)

Creates a new color object from R, G, B, A.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `r` | number | The red value. |
| `g` | number | The green value. |
| `b` | number | The blue value. |
| `a` *(optional)* | number | The alpha value. Defaults to 1.0. (Optional) |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Terrain-Script-Environment/Userdata/Color.md) | The created color. |

### Terrain overload 3

``` { .lua .api-signature }
sm.color.new( hexStr )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.color.md#new-string)

Creates a new color object from a hex string `"RRGGBBAA"`.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `hexStr` | string | The hex string. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Terrain-Script-Environment/Userdata/Color.md) | The created color. |

### Terrain overload 4

``` { .lua .api-signature }
sm.color.new( hexInt )
```

[Open the full Terrain reference](../Terrain-Script-Environment/Static-Functions/sm.color.md#new-integer)

Creates a new color object from a hex value `0xRRGGBBAA`.

**Parameters:**

| Name | Type | Description |
| --- | --- | --- |
| `hexInt` | integer | The hex value. |

**Returns:**

| Type | Description |
| --- | --- |
| [Color](../Terrain-Script-Environment/Userdata/Color.md) | The created color. |
