TreeCanvas class

A scratch volume a tree is drawn on before it is printed into a chunk.

Why draw first: print walks the six faces outward from the blocks standing on the ground and keeps only what the walk reaches, so a frayed leaf with nothing under it, a vine hanging off the air and a branch touching the trunk by a corner alone all fall away before anyone sees them float. The canvas is in world coordinates, so every hash a shape rolls is the same in both chunks that share the tree, and both print the same tree.

Use: begin at the stump, draw with ink (or the shapes of Trees), then print into the chunk being generated. One canvas per generator; it is not reentrant.

Constructors

TreeCanvas({int radius = 8, int height = 40, required bool isSoft(int id), required int groundAt(int x, int z), required int floorY, required int hash(int x, int y, int z)})
A canvas radius blocks around the stump and height tall. isSoft names leaves and vines: a log is drawn over them, nothing is drawn over a log. groundAt gives a column's surface height (the first air cell): the tree keeps out of the ground and out of anything at or under floorY (the sea). hash is the generator's positional hash, for the shapes.

Properties

floorY → int
Nothing of a tree stays at or below this height.
final
groundAt → int Function(int x, int z)
A column's surface height.
final
hash → int Function(int x, int y, int z)
The positional hash shapes roll with.
final
hashCode → int
The hash code for this object.
no setterinherited
height → int
How far above the stump a block may be drawn.
final
isSoft → bool Function(int id)
Leaves and vines.
final
radius → int
How far from the stump a block may be drawn, sideways.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

begin(int x, int y, int z) → void
Centres a new tree on world (x, y, z), its stump on the ground.
ink(int x, int y, int z, int id) → void
Paints one block of the tree, in world coordinates. Only a log is drawn over a leaf, and nothing over a log.
inked(int x, int y, int z) → int
What the canvas holds at a world position, 0 for nothing.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
print(ChunkWriter w) → void
Keeps what holds together (a flood fill from the blocks on the ground), prints it into w over air and soft blocks, and wipes the canvas.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited