LIL is a Language Make games, nicely

@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.)

Example code

#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);
};

Virtual variables

  • componentId

    Type: vvar.i64

    The identifier of the shape data.

    app.shapes[@self.componentId].width: value;
  • width

    Type: vvar.f32

    How wide the shape is. Currently unused.

  • height

    Type: vvar.f32

    How tall the shape is. Currently unused.

  • x

    Type: vvar.f32

    The position along the horizontal axis.

    theShape.x: 300;
  • y

    Type: vvar.f32

    The position along the vertical axis.

    theShape.y +: 100;
  • z

    Type: vvar.f32

    The position along the direction of the depth.

    theShape.z: 0;
  • background

    Type: vvar.@rgb

    A color object representing the background color of this shape.

    theShape.background: #F00;

Member functions

  • getComponentId

    Type: fn => i64

    Accessor for the componentId vvar.

    var componentId: @self.getComponentId();
  • initialize

    Type: fn(ptr(i8),i64) => i64

    This method installs a new 2D shape into the ECS.

    Arguments
    • var.ptr(i8) name:

      The name of the new shape.

    • var.i64 parentId:

      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);
  • setWidth

    Type: fn(f32)

    Setter for the width vvar. Currently unused.

    Arguments
    • var.f32 value:

      The number in pixels for the width.

    theShape.setWidth(100);
  • getWidth

    Type: fn => f32

    Getter for the width vvar.

    if theShape.getWidth() > 200 {
    	//etc
    }
  • setHeight

    Type: fn(f32)

    Setter for the height vvar.

    Arguments
    • var.f32 value:

      The number in pixels for the height. Currently unused.

  • getHeight

    Type: fn => f32

    Getter for the height vvar.

    print theShape.getHeight();
  • setX

    Type: fn(f32)

    Setter for the x vvar.

    Arguments
    • var.f32 value:

      The number in pixels for the x coordinate.

    theShape.setX(200);
  • getX

    Type: fn => f32

    Getter for the x vvar.

    if theShape.getX() > 100 {
    	//etc
    }
  • setY

    Type: fn(f32)

    Setter for the y vvar.

    Arguments
    • var.f32 value:

      The number in pixels for the y coordinate.

    theShape.setY(0);
  • getY

    Type: fn => f32

    Getter for the y vvar.

    var currentY: theShape.getY();
  • setZ

    Type: fn(f32)

    Setter for the z vvar.

    Arguments
    • var.f32 value:

      The number in pixels for the z coordinate.

    theShape.setZ(0);
  • getZ

    Type: fn => f32

    Getter for the z vvar.

    if theShape.getZ() > 0 {
    	//etc
    }
    
  • getBackground

    Type: fn => @rgb

    Value accessor for the background vvar.

    var color: theShape.getBackground();
  • getBackgroundPointer

    Type: fn => ptr(@rgb)

    Pointer accessor for the background vvar.

    var colorPtr: theShape.getBackgroundPointer();
  • moveTo

    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.

    Arguments
    • var.f32 x:

      The number in pixels for the x coordinate.

    • var.f32 y:

      The number in pixels for the y coordinate.

    theShape.moveTo(123, 250.7)
  • lineTo

    Type: fn(f32,f32)

    Draws a line from the previous point to the given one.

    Arguments
    • var.f32 x:

      The number in pixels for the x coordinate.

    • var.f32 y:

      The number in pixels for the y coordinate.