# Class: MakeupEngine

## MakeupEngine(features, finishes, makeupEngineAnalyticsnullable)

This class is part of the SDK's core functionality.
It primarily serves two key functions:
Manipulating the current output of the view throught creating, displaying, updating, hiding, and removing makeup effects.
Exposure of FeatureTemplateRepository and FinishTemplateRepository deserialized from Feature.json and finishes.json files.

## Constructor

#### new MakeupEngine(features, finishes, makeupEngineAnalyticsnullable)

##### Parameters:

Name | Type | Attributes | Description
--- | --- | --- | ---
`features` | Array.<FeatureTemplate> |  | predefined feature templates repository
`finishes` | Array.<FinishTemplate> |  | predefined finish templates repository
`makeupEngineAnalytics` | SdkAnalytics | <nullable> |

Source:
  - MakeupEngine.js, line 25

### Classes

MakeupEngine

### Members

#### activeEffects :Map.<number, Effect>

##### Type:

- Map.<number, Effect>

Source:
  - MakeupEngine.js, line 47

#### finishNamesRecord :Map.<number, string>

##### Type:

- Map.<number, string>

Source:
  - MakeupEngine.js, line 43

### Methods

#### ClearMakeup()

Destroys all created makeup effects.

Source:
  - MakeupEngine.js, line 161

#### (async) CreateMakeup(featureTemplate, finishTemplate, boundingBox) → {Promise.<Effect>}

Creates makeup effect from given feature and finish templates.
Additionally, this function takes an array of floats specifying a bounding box in the following way: - Lower left x coordinate is the first element of the array - Lower left y coordinate is the second element of the array - Upper right x coordinate is the third element of the array - Upper right y coordinate is the fourth element of the array Bounding box is set in normalized image coordinates where point (0.0, 0.0) is the lower left corner of the output image while point (1.0, 1.0) is the upper right corner of the output image. This effect will be visible only when its location in the output image is inside of the bounding box. The default bounding box is contains the whole output image. If the input array has less than 4 elements, the default bounding box will be used.
Returns the promise which is resolved into the feature instance uniquely identifying the created effect.

##### Parameters:

Name | Type | Description
--- | --- | ---
`featureTemplate` | FeatureTemplate | FeatureTemplate object
`finishTemplate` | FinishTemplate | FinishTemplate object
`boundingBox` | BoundingBox | Quuartet specifying bounding box in which this effect is visible

Source:
  - MakeupEngine.js, line 72

##### Returns:

Type
  Promise.<Effect>

#### DisplayMakeup(effect)

Displays given makeup effect.

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect | makeup effect

Source:
  - MakeupEngine.js, line 94

#### GetFeatures() → {Array.<FeatureTemplate>}

Returns loaded feature template repository containing predefined features.
Each of the predefined feature templates specify a standard renderfing procedure for each of the makeup features supported by the engine.

Source:
  - MakeupEngine.js, line 193

##### Returns:

Type
  Array.<FeatureTemplate>

#### GetFinishes() → {Array.<FinishTemplate>}

Returns loaded finish template repository containing predefined finishes.
Each of the predefined finish templates specify a standard renderfing procedure for each of the finishes supported by the engine.

Source:
  - MakeupEngine.js, line 203

##### Returns:

Type
  Array.<FinishTemplate>

#### GetView()

Returns a DOM element which displays the frame.

Source:
  - MakeupEngine.js, line 183

#### HideMakeup(effect)

Hides given makeup effect.

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect | makeup effect

Source:
  - MakeupEngine.js, line 136

#### IntersectMakeup(effect, x, y)

Returns the uv area texture coordinates corresponding to position on the output view canvas that displays the makeup effect.

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect | makeup effect
`x` | number | pixel distance from the left output view canvas edge
`y` | number | pixel distance from the top output view canvas edge

Source:
  - MakeupEngine.js, line 176

#### IsMakeupDisplayed(effect) → {boolean}

Check if the provided effect is currently being displayed

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect |

Source:
  - MakeupEngine.js, line 127

##### Returns:

Type
  boolean

#### RemoveMakeup(effect)

Destroys given makeup effect.

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect | makeup effect

Source:
  - MakeupEngine.js, line 148

#### Reset()

Reinitializes face tracking.
When using the SDK on single images, this method should be called after each image has been processed.

Source:
  - MakeupEngine.js, line 212

#### (async) UpdateMakeup(effect, updateMakeupConfig) → {Promise.<Void>}

JSON Updates color and/or area parameters of the given makeup effect

##### Parameters:

Name | Type | Description
--- | --- | ---
`effect` | Effect | makeup effect
`updateMakeupConfig` | Object | options for analytics component

Source:
  - MakeupEngine.js, line 108

##### Returns:

Type
  Promise.<Void>

#### onFrameRendered(callback)

Registers a callback function which is invoked when rendering of a frame passed to FrameProvider is completed and the frame is rendered.
It is advised to use this function to synchronize passing of new frames to FrameProvider with processing of current frame.

##### Parameters:

Name | Type | Description
--- | --- | ---
`callback` | VoidFunction | Callback that will be invoked on frame completion

Source:
  - MakeupEngine.js, line 222