@shape2d
A 2D shape is made up of a series of drawing commands, like lineTo and curveTo.
Warning: Work in Progress! (only moveTo and lineTo have been implemented so far.)
A 2D shape is made up of a series of drawing commands, like lineTo and curveTo.
Warning: Work in Progress! (only moveTo and lineTo have been implemented so far.)
#new @shape2d myStar {
x: 200;
y: 100;
background: #FD00C8;
moveTo(170.555, 162.807);
lineTo(275.903, 162.807);
lineTo(190.674, 100.885);
lineTo(223.229, 0.692535);
lineTo(138.000, 62.6149);
lineTo(52.7711, 0.692535);
lineTo(85.3257, 100.885);
lineTo(0.0968018, 162.807);
lineTo(105.445, 162.807);
lineTo(138, 263);
lineTo(170.555, 162.807);
};
Type: vvar.i64
The identifier of the shape data.
app.shapes[@self.componentId].width: value;
Type: vvar.f32
How wide the shape is. Currently unused.
Type: vvar.f32
How tall the shape is. Currently unused.
Type: vvar.f32
The position along the horizontal axis.
theShape.x: 300;
Type: vvar.f32
The position along the vertical axis.
theShape.y +: 100;
Type: vvar.f32
The position along the direction of the depth.
theShape.z: 0;
Type: vvar.@rgb
A color object representing the background color of this shape.
theShape.background: #F00;
Type: fn => i64
Accessor for the componentId vvar.
var componentId: @self.getComponentId();
Type: fn(ptr(i8),i64) => i64
This method installs a new 2D shape into the ECS.
The name of the new shape.
The id of the parent of the new shape. Defaults to 0, which is the id of the @root object.
var theShape: @shape2d { };
theShape.initialize(`myShape`, 0);
Type: fn(f32)
Setter for the width vvar. Currently unused.
The number in pixels for the width.
theShape.setWidth(100);
Type: fn => f32
Getter for the width vvar.
if theShape.getWidth() > 200 {
//etc
}
Type: fn(f32)
Setter for the height vvar.
The number in pixels for the height. Currently unused.
Type: fn => f32
Getter for the height vvar.
print theShape.getHeight();
Type: fn(f32)
Setter for the x vvar.
The number in pixels for the x coordinate.
theShape.setX(200);
Type: fn => f32
Getter for the x vvar.
if theShape.getX() > 100 {
//etc
}
Type: fn(f32)
Setter for the y vvar.
The number in pixels for the y coordinate.
theShape.setY(0);
Type: fn => f32
Getter for the y vvar.
var currentY: theShape.getY();
Type: fn(f32)
Setter for the z vvar.
The number in pixels for the z coordinate.
theShape.setZ(0);
Type: fn => f32
Getter for the z vvar.
if theShape.getZ() > 0 {
//etc
}
Type: fn => @rgb
Value accessor for the background vvar.
var color: theShape.getBackground();
Type: fn => ptr(@rgb)
Pointer accessor for the background vvar.
var colorPtr: theShape.getBackgroundPointer();
Type: fn(f32,f32)
Starts a new subpath at the specified location.
Imagine the "virtual pen" gets lifted off the surface and placed somewhere else.
The number in pixels for the x coordinate.
The number in pixels for the y coordinate.
theShape.moveTo(123, 250.7)
Type: fn(f32,f32)
Draws a line from the previous point to the given one.
The number in pixels for the x coordinate.
The number in pixels for the y coordinate.
To gain a better understanding of this class, it is recommended to look at the source code of the following file: