Core.prototype.setBody()

The setBody() mothod sets immovable graphic elements such as the head and body. By default, the back layer is used.

head shoulder { }

Any graphic elements that can be set in the <svg> tag will be added to the drawing layer in the specified order. You can also add them directly to the drawing layer without using this method.

Syntax

setBody(elements)
setBody(elements, append)
setBody(elements, append, layer)

Parameters

elements
An array of graphic elements.
append (Optional)
If this argument is true, the graphic elements will be added to the drawing layer.
If this argument is false or omitted, the immovable graphic elements (except those added with setArms() or setHands() method) are removed first, then the specified graphic elements are added.
layer (Optional)
A drawing layer on which to place graphic elements.
If this argument is omitted, the graphic elements are placed on Core.prototype.back.
In either case, drawing layers that were not targeted remain unchanged.

Return value

none

Examples

const core = new jmotion.Core("#board", true);
const elements = [
    document.getElementById("head"),
    document.getElementById("shoulder"),
    document.getElementById("body"),
];
core.setBody(elements);

// core.back = {
//     "body": rect#body,
//     "head": circle#head,
//     "shoulder": line#shoulder,
// }