CheatSheet for custom HTML-element mec-2

Januar 2021
Keywords: microJam, mec2, Custom Element, cheatsheet

Abstract

This Cheatsheet summarize the core functionality of the custom HTML-element mec-2. For more detail use the mec2 documentation.

Prerequisite

Use the code shown in the first code listing to implement mec-2 custom html element with attributes you desire to table 1.


Table 1: Attributes of the mec-2 element

Attribute Type Impact
width string width of the element in px
height string height of the element in px
x0 string x-origin of the model
y0 string y-origin of the model
grid boolean show grid in background
cartesian boolean whether cartesian is true or not
darkmode boolean whether dark mode is set or not
gravity boolean activate gravity
pausing boolean pause the model
hidenodes boolean hide nodes
constraintlabels boolean show labels of constraints
loadlabels boolean show labels of loads
nodelabels boolean show labels of nodes

Nodes

Create a node by giving the required properties. Don't forget to put the propertie key into quotation marks.


Table 2: Node properties

Required properties Type of value Comment
id string the name of the node
x number x-coordinate
y number y-coordinate
Optional properties Type of value Comment
base string for fix node
idloc number position of string

Constraints

The constraint defines the relationship between two nodes. i.e. in order to define a constraint, two nodes must first of all be defined.


Table 3: Constrait properties

Required properties Type of value Comment
id string the name of the constraint
p1 string first point
p2 string second point
len object it must be specified whether the length between two nodes is variable or constant
ori object it must be specified whether the orientation (angle) between two nodes is variable or constant
Optional properties Type of value Comment
drive boolean define the movement of rotation between two nodes
reference boolean as its name indicates, it allows to define a movement while giving just the reference
sequence boolean Every segment of a drive sequence must specify its function type func, its duration dt (always positive) and its value range dz (might be negative).

Loads

Currently supported are load elements of type

Forces


Table 4: Properties for loads of type 'force'

Required properties Type of value Comment
id string the name of the node
type string y-coordinate
p string point of application
w0w_0 number angle of application
mode string direction



Springs


Table 5: Properties for loads of type 'spring'

Required properties Type of value Comment
id string the name of the node
type string y-coordinate
p1 string first point of application
p2 string second point of application
k number spring constante



Views

Views can be used to make different properties of the model or single elements of the model visible.


Table 6: Properties for views

Required properties Type of value Comment
show string Which property is to be shown
of string The id of the respective element
as string Which type of view is to be used
Dt number Time interval of the view to be active
Optional properties Type of value Comment
vector string to show a vector with a conforming orientation and length
trace string to show the movement of a point
info string to show an info cart
chart string to show coherences between different entities

Shapes

to stylize elements with geometric forms or images.


Table 7: Properties for shapes

Required properties Type of value Comment
type string which shake should be used
uri string the source of an image if we want to insert images from the Internet
p string point of application