Diese Seite auf Deutsch

Shapes in any plane ​

A box is only the start. This recipe draws flat shapes: a wall with a round window and a cross of dark oak, a gate with a round arch, a golden star set into the floor, and a spiral staircase that winds up around its own axis. The same functions draw upright, lying or slanted – the points decide.

Functions: DRAW_BLOCK, DRAW_LINE, DRAW_RECTANGLE, DRAW_POLYGON, DRAW_ELLIPSE, DRAW_ARC and DRAW_SPIRAL, with STYLE_SOLID, STYLE_EMPTY and RENDER_CANVAS

Needs an operator

These programs call RENDER_CANVAS without input: the blocks come out of nowhere, and whatever is in the way is replaced – the gate even cuts its passage out of the wall, the star replaces the ground. That only works if the owner of the trigger block is an operator, or if the server allows it with allowBlockChanges=true in config/c0de.properties; otherwise RENDER_CANVAS raises PERMISSION_DENIED. To build from a chest instead, for every player, see A first canvas.

What you need

  • the mods c0de and c0de paint, and the first canvas as a start
  • a trigger block with a button on it, and an empty sheet for each program
  • operator rights, or allowBlockChanges on the server (see above)
  • a flat place of about 15 × 20 blocks; the staircase and the window grow up to 13 blocks high

The idea ​

A flat shape lies in a plane, and three points give that plane. A rectangle from 0,0,0 to 9,0,0 that reaches up to 0,4,0 stands upright like a wall; with 0,0,4 as its third point it lies flat like a carpet. Nothing else changes: there are no separate functions for walls and floors.

Flat shapes have two parts, each with its own style: the outline (line_style) and the area inside (fill_style). Without a line style, the outline takes the fill style. And what you draw later overwrites what is there: a window is a circle drawn into a wall.

All four programs share a little helper, solid, which turns a block id into a STYLE_SOLID, so the drawing functions don't drown in BLOCK variables.

The round window ​

c0de
PROGRAM roundwindow
NOOP
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION window
    PARAMETER r INTEGER 4
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE a STRUCT c0de_paint/cpaint/POINT
    VARIABLE b STRUCT c0de_paint/cpaint/POINT
    VARIABLE m STRUCT c0de_paint/cpaint/POINT
    VARIABLE wall TYPE c0de_paint/cpaint/STYLE
    VARIABLE rim TYPE c0de_paint/cpaint/STYLE
    VARIABLE glass TYPE c0de_paint/cpaint/STYLE
    VARIABLE frame TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    CALL solid
        PARAMETER id "stone_bricks" ;
        RESULT result wall
    CALL solid
        PARAMETER id "polished_andesite" ;
        RESULT result rim
    CALL solid
        PARAMETER id "light_blue_stained_glass" ;
        RESULT result glass
    CALL solid
        PARAMETER id "dark_oak_planks" ;
        RESULT result frame
    // the wall: a rectangle standing upright
    ASSIGN b.x 2 * r + 4 ;
    ASSIGN m.y 2 * r + 4 ;
    CALL c0de_paint/cpaint/DRAW_RECTANGLE
        PARAMETER canvas c ;
        PARAMETER a a ;
        PARAMETER b b ;
        PARAMETER c m ;
        PARAMETER fill_style wall ;
    // the window: a circle in the same plane
    ASSIGN m.x r + 2 ;
    ASSIGN m.y r + 2 ;
    ASSIGN a.x 2 * r + 2 ;
    ASSIGN a.y r + 2 ;
    ASSIGN b.x r + 2 ;
    ASSIGN b.y 2 * r + 2 ;
    CALL c0de_paint/cpaint/DRAW_ELLIPSE
        PARAMETER canvas c ;
        PARAMETER center m ;
        PARAMETER a a ;
        PARAMETER b b ;
        PARAMETER line_style rim ;
        PARAMETER fill_style glass ;
    // the cross of the window frame
    ASSIGN a.x 3 ;
    ASSIGN b.x 2 * r + 1 ;
    ASSIGN b.y r + 2 ;
    CALL c0de_paint/cpaint/DRAW_LINE
        PARAMETER canvas c ;
        PARAMETER from a ;
        PARAMETER to b ;
        PARAMETER style frame ;
    ASSIGN a.x r + 2 ;
    ASSIGN a.y 3 ;
    ASSIGN b.x r + 2 ;
    ASSIGN b.y 2 * r + 1 ;
    CALL c0de_paint/cpaint/DRAW_LINE
        PARAMETER canvas c ;
        PARAMETER from a ;
        PARAMETER to b ;
        PARAMETER style frame ;
    // build it 2 blocks east of the trigger block
    ASSIGN at.x PID.x + 2 ;
    ASSIGN at.y PID.y ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION

Building and running it ​

  1. Place the trigger block where the wall should start, and put the button on it.
  2. Set the trigger block to roundwindow and window, and press the button.

A wall of stone bricks, 13 blocks wide and 13 high, rises from 2 to 14 blocks east of the trigger block, in its row. In its middle sits a round window of light blue glass with a rim of polished andesite, 9 blocks across, divided by a cross of dark oak planks.

the wall of stone bricks, 13 × 13 blocks, with the round window of light blue glass in its middle, framed by polished andesite and divided by a cross of dark oak planks, the trigger block with its button in front of its west end

How it works ​

  • Upright, because of the points. DRAW_RECTANGLE gets a at 0,0,0 and b at 2r + 4,0,0, one side along the ground; c at 0,2r + 4,0 lies straight above a, so the other side runs up. The z of all points is 0: everything lies in one upright plane.
  • The circle. DRAW_ELLIPSE takes a center and two points: the distance of a is the first radius, the distance of b from the line through center and a the second one. Both are r, so it is a circle. b above the center also puts the circle into the plane of the wall.
  • Outline and area. The rim gets line_style rim, the inside fill_style glass. They overwrite the bricks of the wall – drawing order matters.
  • The cross. DRAW_LINE draws from from to to, here once across and once up the window. A line can go in any direction; its voxels connect through edges and corners.
  • Variables are reused. a, b and m are only values: after the rectangle, the program sets their elements anew for the circle and the lines. The canvas has already stored the shapes.
  • The size. r has the default value 4. A different radius needs only an INTEGER variable item r in the trigger block: wall, window and cross grow with it.

The arched gate ​

Next comes a wall with a gate: a passage cut out with air, and a round arch on top of it.

c0de
PROGRAM archgate
NOOP
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION gate
    PARAMETER r INTEGER 3
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE a STRUCT c0de_paint/cpaint/POINT
    VARIABLE b STRUCT c0de_paint/cpaint/POINT
    VARIABLE m STRUCT c0de_paint/cpaint/POINT
    VARIABLE wall TYPE c0de_paint/cpaint/STYLE
    VARIABLE arch TYPE c0de_paint/cpaint/STYLE
    VARIABLE air TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    CALL solid
        PARAMETER id "cobblestone" ;
        RESULT result wall
    CALL solid
        PARAMETER id "chiseled_stone_bricks" ;
        RESULT result arch
    CALL c0de_paint/cpaint/STYLE_EMPTY
        RESULT result air
    // the wall, upright, 2 blocks wider than the arch
    ASSIGN b.x 2 * r + 4 ;
    ASSIGN m.y r + 4 ;
    CALL c0de_paint/cpaint/DRAW_RECTANGLE
        PARAMETER canvas c ;
        PARAMETER a a ;
        PARAMETER b b ;
        PARAMETER c m ;
        PARAMETER fill_style wall ;
    // the passage: 3 high, filled with air
    ASSIGN a.x 3 ;
    ASSIGN b.x 2 * r + 1 ;
    ASSIGN m.y 2 ;
    CALL c0de_paint/cpaint/DRAW_RECTANGLE
        PARAMETER canvas c ;
        PARAMETER a a ;
        PARAMETER b b ;
        PARAMETER c m ;
        PARAMETER fill_style air ;
    // the arch: half an ellipse on top
    ASSIGN m.x r + 2 ;
    ASSIGN m.y 2 ;
    ASSIGN a.x 2 * r + 2 ;
    ASSIGN a.y 2 ;
    ASSIGN b.x r + 2 ;
    ASSIGN b.y r + 2 ;
    CALL c0de_paint/cpaint/DRAW_ARC
        PARAMETER canvas c ;
        PARAMETER center m ;
        PARAMETER a a ;
        PARAMETER b b ;
        PARAMETER start 0 ;
        PARAMETER end 180 ;
        PARAMETER line_style arch ;
        PARAMETER fill_style air ;
    ASSIGN at.x PID.x + 2 ;
    ASSIGN at.y PID.y ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION

Move the trigger block to a free place, set it to archgate and gate, and press the button. A cobblestone wall, 11 blocks wide and 8 high, stands 2 blocks east of the trigger block. Its gate is 5 blocks wide and 5 high in the middle, framed by an arch of chiseled stone bricks.

  • Cutting out. The passage is a second rectangle with STYLE_EMPTY. Its voxels are set to air, so they overwrite the cobblestone, and in the world they remove whatever is there.
  • Half a circle. DRAW_ARC draws the part of an ellipse from start to end, in degrees, counted from a towards b. From 0 to 180 is the upper half: a lies east of the center, b above it.
  • The arch and the opening. The line of the arc is the arch of chiseled stone bricks. Its fill_style air is the pie slice inside the arc, which opens the gate up to the arch. It starts at the top of the passage, so both openings meet.

A star in the floor ​

A star is a polygon with 10 corners: 5 tips and 5 notches between them. The program computes them with COS and SIN on a circle and lays the star flat into the ground.

c0de
PROGRAM floorstar
NOOP
INCLUDE c0de/math
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION star
    PARAMETER r INTEGER 8
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE p STRUCT c0de_paint/cpaint/POINT
    VARIABLE corners ARRAY STRUCT c0de_paint/cpaint/POINT
    VARIABLE gold TYPE c0de_paint/cpaint/STYLE
    VARIABLE white TYPE c0de_paint/cpaint/STYLE
    VARIABLE light TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    VARIABLE angle FLOAT
    VARIABLE radius FLOAT
    VARIABLE f FLOAT
    CALL solid
        PARAMETER id "gold_block" ;
        RESULT result gold
    CALL solid
        PARAMETER id "white_concrete" ;
        RESULT result white
    CALL solid
        PARAMETER id "sea_lantern" ;
        RESULT result light
    // 10 corners: tips and notches take turns
    FOR i INTEGER 0 ; 9 ;
    BEGIN
        ASSIGN radius r ;
        IF i \ 2 = 1 ;
        BEGIN
            ASSIGN radius r * 2 / 5 ;
        END IF
        ASSIGN angle ( i / 5 - 0.5 ) * c0de/math/PI ;
        CALL c0de/math/COS
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.x
        CALL c0de/math/SIN
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.z
        ASSIGN corners[i] p ;
    END FOR
    CALL c0de_paint/cpaint/DRAW_POLYGON
        PARAMETER canvas c ;
        PARAMETER points corners ;
        PARAMETER line_style gold ;
        PARAMETER fill_style white ;
    // a lamp in the middle
    ASSIGN p.x 0 ;
    ASSIGN p.z 0 ;
    CALL c0de_paint/cpaint/DRAW_BLOCK
        PARAMETER canvas c ;
        PARAMETER point p ;
        PARAMETER style light ;
    // into the floor, its middle r + 2 blocks east
    ASSIGN at.x PID.x + r + 2 ;
    ASSIGN at.y PID.y - 1 ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION

Set the trigger block to floorstar and star and press the button. A star of white concrete with a golden outline replaces the ground east of the trigger block, its middle 10 blocks away, with a sea lantern in its center. Its tips are 8 blocks from the middle, and one of them points north.

the five-pointed star set into the grass, white concrete with a rim of gold blocks and a sea lantern in its middle, seen from above, the trigger block 2 blocks west of its western tip
  • The corners. The loop goes round the circle in steps of 36°, which is c0de/math/PI / 5. The even corners are tips with the radius r, the odd ones notches with 2/5 of it. COS gives the share in x, SIN the share in z, and ROUND makes whole voxels of them. The - 0.5 turns the first tip north.
  • An ARRAY of POINTs. ASSIGN corners[i] p ; appends a copy of p to the array, so p can be reused for the next corner.
  • Lying flat. All corners have y 0, so DRAW_POLYGON finds a horizontal plane. The polygon closes itself from the last corner back to the first.
  • One voxel. DRAW_BLOCK sets a single voxel: the sea lantern in the middle, drawn last, so it overwrites the concrete.
  • Into the ground. RENDER_CANVAS puts the voxel 0,0,0 one block below the trigger block, so the star replaces the ground and lies level with it.

The spiral staircase ​

A spiral staircase is a single call: DRAW_SPIRAL draws a spiral up an axis, and its fill style fills the steps between the axis and the spiral.

c0de
PROGRAM spiralstairs
NOOP
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION stairs
    PARAMETER r INTEGER 3
    PARAMETER h INTEGER 12
    PARAMETER elevation FLOAT 0.5
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE m STRUCT c0de_paint/cpaint/POINT
    VARIABLE east STRUCT c0de_paint/cpaint/POINT
    VARIABLE south STRUCT c0de_paint/cpaint/POINT
    VARIABLE edge TYPE c0de_paint/cpaint/STYLE
    VARIABLE steps TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    CALL solid
        PARAMETER id "spruce_planks" ;
        RESULT result edge
    CALL solid
        PARAMETER id "oak_planks" ;
        RESULT result steps
    ASSIGN east.x r ;
    ASSIGN south.z r ;
    CALL c0de_paint/cpaint/DRAW_SPIRAL
        PARAMETER canvas c ;
        PARAMETER center m ;
        PARAMETER a east ;
        PARAMETER b south ;
        PARAMETER direction "+y" ;
        PARAMETER elevation elevation ;
        PARAMETER h h ;
        PARAMETER line_style edge ;
        PARAMETER fill_style steps ;
    // the axis r + 2 blocks east of the trigger block
    ASSIGN at.x PID.x + r + 2 ;
    ASSIGN at.y PID.y ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION

Set the trigger block to spiralstairs and stairs and press the button. The staircase winds up around an axis 5 blocks east of the trigger block: steps of oak planks with an edge of spruce planks, 7 blocks across and 12 high. It starts east of the axis and turns clockwise, to the south first, one and a half times round.

the spiral staircase of oak planks with an edge of spruce planks, 12 blocks high, winding clockwise around its central column, a player on one of its upper steps
  • The circle of the spiral. center, a and b work as in DRAW_ELLIPSE: the spiral starts at a, east of the axis, and turns towards b, to the south. direction "+y" lets it rise. The circle lies across the direction: all three points have y 0.
  • elevation says how many layers each voxel of the spiral lies above the one before, rounded down. 0.5 rises every second voxel: every step is two blocks long at the edge, and every step is one block higher than the one before – you can walk up.
  • h is the height in layers: the spiral ends below layer 12, like a cylinder of the height 12.
  • Line and fill. The line is the spiral itself, the outer edge of the steps. The fill is the ramp from the axis to the spiral, and the axis is drawn in every layer: the central column of the staircase.

Try it yourself ​

  1. Make the staircase steeper: what happens with an elevation of 1, and what with 2?
Solution

No new code: put a FLOAT variable item elevation into the trigger block. With 1, every voxel of the edge is one layer higher than the one before; the steps are only one block long at the edge, but you can still walk up, and 12 layers are only three quarters of a turn. With 2, every voxel climbs two layers, so there is a gap of one layer between the steps – a decoration, but no staircase any more.

  1. Stand the star upright, like a star on a wall, with its tip up.
Solution

Only the plane changes: the corners get y instead of z. The + 0.5 turns the first tip up, and RENDER_CANVAS lifts the star by r, so its lower tips stay above the ground.

c0de
PROGRAM wallstar
NOOP
INCLUDE c0de/math
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION star
    PARAMETER r INTEGER 8
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE p STRUCT c0de_paint/cpaint/POINT
    VARIABLE corners ARRAY STRUCT c0de_paint/cpaint/POINT
    VARIABLE gold TYPE c0de_paint/cpaint/STYLE
    VARIABLE white TYPE c0de_paint/cpaint/STYLE
    VARIABLE light TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    VARIABLE angle FLOAT
    VARIABLE radius FLOAT
    VARIABLE f FLOAT
    CALL solid
        PARAMETER id "gold_block" ;
        RESULT result gold
    CALL solid
        PARAMETER id "white_concrete" ;
        RESULT result white
    CALL solid
        PARAMETER id "glowstone" ;
        RESULT result light
    // 10 corners: tips and notches take turns
    FOR i INTEGER 0 ; 9 ;
    BEGIN
        ASSIGN radius r ;
        IF i \ 2 = 1 ;
        BEGIN
            ASSIGN radius r * 2 / 5 ;
        END IF
        ASSIGN angle ( i / 5 + 0.5 ) * c0de/math/PI ;
        CALL c0de/math/COS
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.x
        CALL c0de/math/SIN
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.y
        ASSIGN corners[i] p ;
    END FOR
    CALL c0de_paint/cpaint/DRAW_POLYGON
        PARAMETER canvas c ;
        PARAMETER points corners ;
        PARAMETER line_style gold ;
        PARAMETER fill_style white ;
    // a lamp in the middle
    ASSIGN p.x 0 ;
    ASSIGN p.y 0 ;
    CALL c0de_paint/cpaint/DRAW_BLOCK
        PARAMETER canvas c ;
        PARAMETER point p ;
        PARAMETER style light ;
    // upright, its middle r + 2 blocks east and r up
    ASSIGN at.x PID.x + r + 2 ;
    ASSIGN at.y PID.y + r ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION
  1. Put an INTEGER variable item r with 0 into the trigger block of the star. What happens? Let the program say "No star: r is too small" instead.
Solution

With r 0, all corners are 0,0,0. They lie on one line – even on one point – so they give no plane, and DRAW_POLYGON raises NOT_A_PLANE: the program crashes. Catch the error in the CALL and compare its code with the constant c0de_paint/cpaint/NOT_A_PLANE.

c0de
PROGRAM safestar
NOOP
INCLUDE c0de/math
INCLUDE c0de/minecraft
INCLUDE c0de_paint/cpaint
NOOP
FUNCTION solid
    PARAMETER id STRING
    RESULT result TYPE c0de_paint/cpaint/STYLE
BEGIN
    VARIABLE block STRUCT c0de_paint/cpaint/BLOCK
    ASSIGN block.id id ;
    CALL c0de_paint/cpaint/STYLE_SOLID
        PARAMETER block block ;
        RESULT result result
END FUNCTION
NOOP
FUNCTION star
    PARAMETER r INTEGER 8
BEGIN
    VARIABLE c TYPE c0de_paint/cpaint/CANVAS
    VARIABLE p STRUCT c0de_paint/cpaint/POINT
    VARIABLE corners ARRAY STRUCT c0de_paint/cpaint/POINT
    VARIABLE gold TYPE c0de_paint/cpaint/STYLE
    VARIABLE white TYPE c0de_paint/cpaint/STYLE
    VARIABLE light TYPE c0de_paint/cpaint/STYLE
    VARIABLE at STRUCT c0de/minecraft/POSITION
    VARIABLE angle FLOAT
    VARIABLE radius FLOAT
    VARIABLE f FLOAT
    VARIABLE problem ERROR
    CALL solid
        PARAMETER id "gold_block" ;
        RESULT result gold
    CALL solid
        PARAMETER id "white_concrete" ;
        RESULT result white
    CALL solid
        PARAMETER id "sea_lantern" ;
        RESULT result light
    // 10 corners: tips and notches take turns
    FOR i INTEGER 0 ; 9 ;
    BEGIN
        ASSIGN radius r ;
        IF i \ 2 = 1 ;
        BEGIN
            ASSIGN radius r * 2 / 5 ;
        END IF
        ASSIGN angle ( i / 5 - 0.5 ) * c0de/math/PI ;
        CALL c0de/math/COS
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.x
        CALL c0de/math/SIN
            PARAMETER value angle ;
            RESULT result f
        CALL c0de/math/ROUND
            PARAMETER value radius * f ;
            RESULT result p.z
        ASSIGN corners[i] p ;
    END FOR
    CALL c0de_paint/cpaint/DRAW_POLYGON problem
        PARAMETER canvas c ;
        PARAMETER points corners ;
        PARAMETER line_style gold ;
        PARAMETER fill_style white ;
    IF problem.code = c0de_paint/cpaint/NOT_A_PLANE ;
    BEGIN
        CALL c0de/minecraft/SAY
            PARAMETER message "No star: r is too small" ;
        RETURN
    END IF
    // a lamp in the middle
    ASSIGN p.x 0 ;
    ASSIGN p.z 0 ;
    CALL c0de_paint/cpaint/DRAW_BLOCK
        PARAMETER canvas c ;
        PARAMETER point p ;
        PARAMETER style light ;
    // into the floor, its middle r + 2 blocks east
    ASSIGN at.x PID.x + r + 2 ;
    ASSIGN at.y PID.y - 1 ;
    ASSIGN at.z PID.z ;
    CALL c0de_paint/cpaint/RENDER_CANVAS
        PARAMETER canvas c ;
        PARAMETER position at ;
END FUNCTION

Read more ​