Core()

The Core() constructor creates a new Core object. At the same time, the following graphic elements are generated and retained internally.

graphic elementtagelement IDparent graphic element
SVG object<svg>jmotion_core_0(none)
definitional part<defs>jmotion_core_0_definitionSVG object
back layer<g>jmotion_core_0_backSVG object
middle layer<g>jmotion_core_0_middleSVG object
front layer<g>jmotion_core_0_frontSVG object
palm<rect>jmotion_core_0_handdefinitional part
ball <circle>jmotion_core_0_prop_reddefinitional part
ball <circle>jmotion_core_0_prop_limedefinitional part
ball <circle>jmotion_core_0_prop_bluedefinitional part
ball <circle>jmotion_core_0_prop_orangedefinitional part
ball <circle>jmotion_core_0_prop_graydefinitional part
ball <circle>jmotion_core_0_prop_maroondefinitional part
ball <circle>jmotion_core_0_prop_greendefinitional part
ball <circle>jmotion_core_0_prop_aquadefinitional part
ball <circle>jmotion_core_0_prop_olivedefinitional part
ball <circle>jmotion_core_0_prop_fuchsiadefinitional part
ball <circle>jmotion_core_0_prop_tealdefinitional part
ball <circle>jmotion_core_0_prop_yellowdefinitional part
ball <circle>jmotion_core_0_prop_navydefinitional part
ball <circle>jmotion_core_0_prop_silverdefinitional part
ball <circle>jmotion_core_0_prop_purpledefinitional part
ball <circle>jmotion_core_0_prop_blackdefinitional part
head<circle>jmotion_core_0_headback layer
shoulder<line>jmotion_core_0_shoulderback layer
right forearm<line>jmotion_core_0_right_0back layer
right upper arm<line>jmotion_core_0_right_1back layer
left forearm<line>jmotion_core_0_left_0back layer
left upper arm<line>jmotion_core_0_left_1back layer
right palm<use>jmotion_core_0_right_handfront layer
left palm<use>jmotion_core_0_left_handfront layer

If the same name already exists, jmotion_core_0 in the element ID is changed to jmotion_core_1, jmotion_core_2, ..., and if an existing <svg> tag is specified, it will be replaced by its ID.

Depending on the number of balls required, the balls are used in order from the first to the last. If the number of balls is greater than the list, the balls of the same color are used in order from the beginning.

Syntax

new Core()
new Core(element)
new Core(element, cancel)

Parameters

element (Optional)
An object representing an HTML tag or CSS selectors.
When a string is specified, it is considered CSS selectors and the first object matching that selectors is used.
When the <svg> tag is specified as an object, it becomes Core.prototype.svg property.
When a parent element such as <div> tag is specified as an object, a newly created <svg> tag is set to Core.prototype.svg and also added as a child element of the element.
If this argument is another element or omitted, a newly created <svg> tag is set to Core.prototype.svg, but not added to the DOM tree.
cancel (Optional)
Whether to cancel the creation of default graphic elements.
If this argument is true, the creation and setting of the graphic elements are canceled and must be set and drawn separately.
If this argument is false or omitted, the default graphic elements are kept inside.

Examples

const core = new jmotion.Core("div");

// core = {
//     "back": g#jmotion_core_0_back,
//     "defs": defs#jmotion_core_0_definition,
//     "front": g#jmotion_core_0_front,
//     "middle": g#jmotion_core_0_middle,
//     "svg": svg#jmotion_core_0,
// }