Core()
The Core() constructor creates a new Core object. At the same time, the following graphic elements are generated and retained internally.
graphic element | tag | element ID | parent graphic element |
---|---|---|---|
SVG object | <svg> | jmotion_core_0 | (none) |
definitional part | <defs> | jmotion_core_0_definition | SVG object |
back layer | <g> | jmotion_core_0_back | SVG object |
middle layer | <g> | jmotion_core_0_middle | SVG object |
front layer | <g> | jmotion_core_0_front | SVG object |
palm | <rect> | jmotion_core_0_hand | definitional part |
ball ● | <circle> | jmotion_core_0_prop_red | definitional part |
ball ● | <circle> | jmotion_core_0_prop_lime | definitional part |
ball ● | <circle> | jmotion_core_0_prop_blue | definitional part |
ball ● | <circle> | jmotion_core_0_prop_orange | definitional part |
ball ● | <circle> | jmotion_core_0_prop_gray | definitional part |
ball ● | <circle> | jmotion_core_0_prop_maroon | definitional part |
ball ● | <circle> | jmotion_core_0_prop_green | definitional part |
ball ● | <circle> | jmotion_core_0_prop_aqua | definitional part |
ball ● | <circle> | jmotion_core_0_prop_olive | definitional part |
ball ● | <circle> | jmotion_core_0_prop_fuchsia | definitional part |
ball ● | <circle> | jmotion_core_0_prop_teal | definitional part |
ball ● | <circle> | jmotion_core_0_prop_yellow | definitional part |
ball ● | <circle> | jmotion_core_0_prop_navy | definitional part |
ball ● | <circle> | jmotion_core_0_prop_silver | definitional part |
ball ● | <circle> | jmotion_core_0_prop_purple | definitional part |
ball ● | <circle> | jmotion_core_0_prop_black | definitional part |
head | <circle> | jmotion_core_0_head | back layer |
shoulder | <line> | jmotion_core_0_shoulder | back layer |
right forearm | <line> | jmotion_core_0_right_0 | back layer |
right upper arm | <line> | jmotion_core_0_right_1 | back layer |
left forearm | <line> | jmotion_core_0_left_0 | back layer |
left upper arm | <line> | jmotion_core_0_left_1 | back layer |
right palm | <use> | jmotion_core_0_right_hand | front layer |
left palm | <use> | jmotion_core_0_left_hand | front 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,
// }