new MemePlayer(canvas, width, height)
Enhances a canvas with meme viewing and editing capabilities.
Parameters:
| Name | Type | Description |
|---|---|---|
canvas |
HTMLCanvasElement | The canvas element to render into. |
width |
number | The width of the canvas, in pixels. |
height |
number | The height of the canvas, in pixels. |
- Source:
Methods
-
export() → {Promise.<MemeData>}
-
Exports the content of the player to a data URL.
- Source:
Returns:
- Type
- Promise.<MemeData>
-
loadTemplate(url) → {Promise.<Template>}
-
Loads a template image and starts displaying it on the canvas.
Parameters:
Name Type Description urlstring The URL of the image to display. JPG, PNG and GIF are supported image formats.
- Source:
Returns:
- Type
- Promise.<Template>
-
setHeight(height)
-
Sets the height of the canvas.
Parameters:
Name Type Description heightnumber The new height of the canvas, in pixels.
- Source:
-
setText(text)
-
Sets the meme text and re-renders the meme.
Parameters:
Name Type Description textMemeText The new meme text to render.
- Source:
-
setWidth(width)
-
Sets the width of the canvas.
Parameters:
Name Type Description widthnumber The new width of the canvas, in pixels.
- Source:
Type Definitions
-
MemeData
-
Type:
- Object
- Source:
Properties:
Name Type Description datastring The base64 encoded meme data.
contentTypestring The MIME type of the base64 encoded data. Guaranteed to be an image type, and if the loaded template was an animated GIF with multiple frames it's also guaranteed to be 'image/gif'.
-
MemeText
-
An object containing meme text to render over an image.
Type:
- Object
- Source:
Properties:
Name Type Description topObject An object representing the top line of text, if any.
Properties
Name Type Description valuestring The actual text content of the top line.
alignstring The alignment of the top line. Must be one of 'left', 'right' or 'center'.
middleObject An object representing the middle line of text, if any.
Properties
Name Type Description valuestring The actual text content of the middle line.
alignstring The alignment of the middle line. Must be one of 'left', 'right' or 'center'.
bottomObject An object representing the bottom line of text, if any.
Properties
Name Type Description valuestring The actual text content of the bottom line.
alignstring The alignment of the bottom line. Must be one of 'left', 'right' or 'center'.
