-
Notifications
You must be signed in to change notification settings - Fork 0
PolyWall
A description of every function and parameter of the PolyWall class and all of its extension classes.
- The Cascade Class
- The Channel Class
- The Vertex Class
- The Quad Vertex Class
- The Dual Limit Class
- The Dual Angle Class
- The PolyWall Class
The Cascade class is the most primitive extension class and only manages a single value of a specific type. (Common types are Numeric, Function, and Boolean.) All parameters such as thickness, position, etc. have been given their own class instances which allows them to inherit values from other instances. Each of these classes has five functions.
-
Cascade:set(val)
Sets the value of class to<val>
. Setting<val>
tonil
or an invalid type will cause the class value to be cleared. -
Cascade:get()
Gets the class value. If the class has no value, the function will return the superclass value. -
Cascade:rawget()
Gets the raw class value. Ignores inheritance. -
Cascade:define(fn)
Defines a class's value to be a function. This function will be called every time the value needs to be assessed. The function is allowed to take arguments which can be set when callingCascade:get()
. Defining with a function that returns more than one value or a value that is of the wrong type is undefined behavior. -
Cascade:freeze()
Sets the value of the class to be it's closest inherited value. This function is equivalent to running:Cascade:set(nil) Cascade:set(Cascade:get())
The Channel class is a special cascading class designed to handle colors.
-
Channel:setcolor(r, g, b)
Sets the red, green, and blue channels. The alpha channel is untouched. -
Channel:sethsv(h, s, v)
Sets the red, green, and blue channels using the HSV color space. The alpha channel is untouched. -
Channel:setalpha(a)
Sets the alpha channel. -
Channel:set(r, g, b, a)
Sets the red, green, blue, and alpha channels. -
Channel:get()
Returns the red, green, blue, and alpha channels in that order. -
Channel:rawget()
Same as above but ignores inheritance. -
Channel:define(fn)
Defines the color to a function. The function is allowed to take arguments which can be set when callingCascade:get()
. The function must return 4 numbers for red, green, blue, and alpha. Returning anything else is undefined behavior. -
Channel:freeze()
Sets the channel to its closest inherited values.
The Vertex class is mostly just a wrapper class that packages three transformation functions and a color channel class together.
-
Vertex.ch
- This is a Channel class.
-
Vertex.pol
- The polar transformation parameter.
- This is a cascading function class.
- Its default value is the function:
function (r, a) return r, a end
-
Vertex.cart
- The cartesian transformation parameter.
- This is a cascading function class.
- Its default value is the function:
function (x, y) return x, y end
-
Vertex.col
- The color transformation parameter.
- This is a cascading function class.
- Its default value is the function:
function (r, g, b, a) return r, g, b, a end
-
Vertex:result()
Returns ther
,g
,b
, anda
channels of the channel parameter with the color transformation applied.
For more on transformation functions, visit Transformations.
These four verticies are Vertex classes.
QuadVertex[0]
QuadVertex[1]
QuadVertex[2]
QuadVertex[3]
-
QuadVertex:chsetcolor(r, g, b)
Sets the red, green, and blue channels of all 4 verticies. The alpha channel is untouched. -
QuadVertex:chsetalpha(a)
Sets the alpha channel of all 4 verticies. -
QuadVertex:chsethsv(h, s, v)
Sets the red, green, and blue channels of all 4 verticies using the HSV color space. The alpha channel is untouched. -
QuadVertex:chset(r, g, b, a)
Sets the channels of all 4 verticies. -
QuadVertex:chget()
Returns 16 values: the red, green, blue, and alpha channel values of vertex 0, then 1, then 2, and finally 3. -
QuadVertex:chrawget()
Same as above but ignores inheritance. -
QuadVertex:chdefine(fn)
Defines all 4 verticies to a function. Definition function rules still apply. -
QuadVertex:chfreeze()
Sets all channels of all 4 verticies to their closest inherited values.
-
QuadVertex:polset(pol)
Sets the polar transformation of all 4 verticies. -
QuadVertex:polget()
Returns the polar transformations of verticies 0, 1, 2, and 3 in that order. -
QuadVertex:polrawget()
Same as above but ignores inheritance. -
QuadVertex:poldefine(fn)
Defines the polar transformation function of all 4 verticies to a function. Definition function rules still apply. -
QuadVertex:polfreeze()
Sets the polar transformation of all 4 verticies to the closest inherited value.
-
QuadVertex:cartset(cart)
Sets the cartesian transformation of all 4 verticies. -
QuadVertex:cartget()
Returns the cartesian transformations of verticies 0, 1, 2, and 3 in that order. -
QuadVertex:cartrawget()
Same as above but ignores inheritance. -
QuadVertex:cartdefine(fn)
Defines the cartesian transformation function of all 4 verticies to a function. Definition function rules still apply. -
QuadVertex:cartfreeze()
Sets the cartesian transformation of all 4 verticies to the closest inherited value.
-
QuadVertex:colset(col)
Sets the color transformation of all 4 verticies. -
QuadVertex:colget()
Returns the color transformations of verticies 0, 1, 2, and 3 in that order. -
QuadVertex:colrawget()
Same as above but ignores inheritance. -
QuadVertex:coldefine(fn)
Defines the color transformation function of all 4 verticies to a function. Definition function rules still apply. -
QuadVertex:colfreeze()
Sets the color transformation of all 4 verticies to the closest inherited value.
Limits determine the radial range where walls can appear. Walls always start at the origin
limit (unless otherwise specified) and move towards the extent
limit. If a wall's thickness or position causes it to exceed its limits, it is culled by those limits.
These two parameters are cascading numeric classes.
-
DualLimit.origin
- Its default value is 1600.
-
DualLimit.extent
- Its default value is defined by the radius of the center polygon.
-
DualLimit:set(lim0, lim1)
Sets theorigin
limit to<lim0>
and theextent
limit to<lim1>
. -
DualLimit:get()
Returns theorigin
limit and theextent
limit in that order. -
DualLimit:rawget()
Same as above but ignores inheritance. -
DualLimit:define(lim0fn, lim1fn)
Defines theorigin
limit to the function<lim0fn>
and theextent
limit to the function<lim1fn>
. -
DualLimit:freeze()
Sets theorigin
limit andextent
limit to their closest inherited values. -
DualLimit:swap()
Swaps the values of each limit. This causes the direction of walls to reverse.
WARNING: Swapping literally swaps the origin and extent angles so all downstream angles will also be affected.
-
DualLimit:order()
Returns both limits in order from smaller to larger. -
DualLimit:dir()
Returns 1 if theorigin
limit is greater than or equal to theextent
limit, -1 otherwise.
Angles determine the shape of walls. There are two, one for the left side and one for the right side of the wall. The origin
angle governs the radial axis of verticies 0 and 3 while the extent
angle governs the radial axis of verticies 1 and 2. Both angles can be offset by the offset
parameter.
These three parameters are cascading numeric classes.
They all have default values of 0.
DualAngle.origin
DualAngle.extent
DualAngle.offset
-
DualAngle:set(a0, a1, ofs)
Sets theorigin
angle,extent
angle, andoffset
parameters to<a0>
,<a1>
, and<ofs>
, respectively. -
DualAngle:get()
Returns theorigin
angle,extent
angle, andoffset
in that order. -
DualAngle:rawget()
Same as above but ignores inheritance. -
DualAngle:define(a0fn, a1fn, ofsfn)
Defines theorigin
angle,extent
angle, andoffset
to the functions<a0fn>
,<a1fn>
, and<ofsfn>
, respectively. -
DualAngle:freeze()
Sets theorigin
angle,extent
angle, andoffset
to their closest inherited values. -
DualAngle:result()
Returns two angles, the result of theorigin
angle plus theoffset
and theextent
angle plus theoffset
.
The PolyWall class contains functions that operate directly on layers. They are mainly used to create, destroy, and organize layers and walls. The class also facilitates the movement and animation of walls.
-
PolyWall[i][j] ... [k][l]
- Directly indexing a layer with a number returns the corresponding sublayer. If there is no sublayer, indexing returns
nil
. This can be chained repeatedly to access any layer from the current layer.
- Directly indexing a layer with a number returns the corresponding sublayer. If there is no sublayer, indexing returns
-
PolyWall.L
- A table of all sublayers of the current layer. This isn't usually used in practice since directy indexing a PolyWall class with a number returns the corrsponding sublayer.
-
PolyWall.W
- A table of all walls contained in the current layer. Every wall has a unique table as a key and a primitive layer as its value.
For more on wall keys, visit Walls
-
PolyWall.P
- This is a MockPlayer class.
-
PolyWall.thickness
- This is a cascading numeric class.
- Its default value is
THICKNESS
or 40.
-
PolyWall.speed
- This is a cascading numeric class.
- Its default value is defined by the level's current speed and difficulty multipliers.
-
PolyWall.position
- This is a cascading numeric class
- Unlike other parameters, position does not inherit its value from the superclass layer but the current layer's origin limit value. For example, if the current layer's origin limit is 1600 (the default) then position will inherit the value of 1600.
-
PolyWall.vertex
- This is a Quad Vertex class.
-
PolyWall.angle
- This is a Dual Angle class.
-
PolyWall.limit
- This is a Dual Limit class.
IMPORTANT: Many of the functions below are recursive. This is indicated by their first argument being the
<depth>
value. This value specifies how many layers deep the function should be run relative to the current layer. For example, if the depth is2
then the function operation will performed on every layer two layers down from the current layer. Layers in between are unaffected with the exception ofPolyWall:sort(depth, descending)
. An asterisk (*) indicates functions which are recursive.
-
PolyWall:construct(th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
Creates the most primitive layer object. In practice, this is only used by walls which don't need all features of an actual layer. This object lacks the ability to create new layers and does not contain a MockPlayer extension class.Parameter Initializations
The arguments of this function are used to initialize the parameter classes with certain values and are listed below:
Name Parameter <th>
thickness
<sp>
speed
<p>
position
<r>
Red channel (all verticies) <g>
Green channel (all verticies) <b>
Blue channel (all verticies) <a>
Alpha channel (all verticies) <pol>
Polar transformation (all verticies) <cart>
Cartesian transformation (all verticies) <col>
Color transformation (all verticies) <a0>
origin
angle<a1>
extent
angle<ofs>
offset
angle<lim0>
origin
limit<lim1>
extent
limit
IMPORTANT: The arguments of this function are commonly repeated amongst other following functions that involve the creation of a wall or layer. These parameters will be listed with the same names.
-
PolyWall:new(th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
Creates a new standalone layer. This layer is disconnected from its superclass layer but still inherits its values. In practice, this function is only used once to create a root layer for other layers to branch off of. -
PolyWall:add(n, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
Creates a new layer with numerical index<n>
and links it to the current layer. -
PolyWall:radd(depth, n, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
*
Same asadd
but acts recursively. -
PolyWall:remove(n)
Removes layer<n>
of the current layer. All sublayers and walls are also destroyed.
Legacy name:rmLayer
-
PolyWall:rremove(depth, n)
Similar toremove
but acts recursively. -
PolyWall:xremove(depth)
*
Removes all layers.
Legacy name:rrmLayer
-
PolyWall:wremove(key)
Removes a wall of the current layer with key<key>
.
Legacy name:rmWall
-
PolyWall:wxremove(depth)
*
Removes all walls.
Legacy name:rrmWall
-
PolyWall:wall(depth, t, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
*
Creates walls. The mode<t>
can be one of three strings's'
,'n'
, or'd'
indicating the type of wall to be spawned. If depth is zero, returns the key of the created wall. -
PolyWall:sWall(depth, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
*
Creates a standard wall. If depth is zero, returns the instance of the created wall. -
PolyWall:nWall(depth, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
*
Creates a non-solid wall. If depth is zero, returns the instance of the created wall. -
PolyWall:dWall(depth, th, sp, p, r, g, b, a, pol, cart, col, a0, a1, ofs, lim0, lim1)
*
Creates a deadly wall. If depth is zero, returns the instance of the created wall.
For more on wall keys, visit Walls
-
PolyWall:pivotCap(depth, r, g, b, a, pol, cart, col, a0, a1, ofs)
*
Creates a non-solid imitation of a section of the center polygon cap. -
PolyWall:pivotBorder(depth, r, g, b, a, pol, cart, col, a0, a1, ofs)
*
Creates a non-solid imitation of a section of the center polygon border. -
PolyWall:hasWalls(depth)
*
Returns true if any layer<depth>
layers down has one or more walls.
-
PolyWall:template(depth, n, ...)
*
Creates<n>
layers with indicies0, 1, ... , n - 2, n - 1
. -
PolyWall:regularize(depth, shape, ofs)
*
Modifies theorigin
andextent
angles of the layers0, 1, ... , shape - 2, shape - 1
such that they take the shape of a regular polygon with angle offset<ofs>
. Any layers that aren't included in the sequence are ignored. The<shape>
parameter must be a valid side count. -
PolyWall:distribute(depth, n, ofs)
*
Modifies theoffset
angles of the layers0, 1, ... , n - 2, n - 1
such that they are evenly distributed from 0 to 2π with angle offset<ofs>
. -
PolyWall:proportionalize(depth, ofs, ...)
*
Modifies theorigin
andextent
angles of layers in proportion to a ratio provided in the variadic (...
) with angle offset<ofs>
. The range of layers affected is0, 1, ... , n - 2, n - 1
wheren
is the length of the ratio. The sum of all numbers in the ratio must be greater than zero but individual numbers in the ratio can equal zero. (They'll just have an arc length of zero making them invisible.)
-
PolyWall:move(depth, mFrameTime)
*
Advances and updates all wall positions according toposition
,thickness
, and direction. Any polar and cartesian transformation functions are applied, in that order. -
PolyWall:fill(depth)
*
Updates wall colors. Any color transformations are also applied. -
PolyWall:run(depth, mFrameTime)
*
Union ofmove
andfill
. Color transformations applied by this function have access to polar and cartesian coordinate information. A more detailed description of this functionailty is provided in Transformations. -
PolyWall:sort(depth, descending)
*
Sorts wall CW handles such that lower numbered handles are moved to lower layers and higher numbered handles to higher layers. The order can be reversed by setting the<decending>
parameter to true. Enables wall layering based on layer indicies. Only affects currently existing walls so this function should be run regularly to maintain proper layering. (However, do not run this function too frequently as it is very computationally expensive.) Layering of walls within a single layer is unstable and will very likely change. MockPlayers are also affected and will always be prioritized above walls within their own layers. Layers closer to the root layer are prioritized above deeper layers.
IMPORTANT: This is the only function that affects layers in between the current layer and all layers
<depth>
layers deep.
The information presented in this wiki is not guaranteed to be accurate. The information presented may be a few versions old.