-
Notifications
You must be signed in to change notification settings - Fork 33
Configuration Variables
A configuration declaration is a special form of a variable declaration, where the variable is in the CF:: namespace. Configuration declarations change the behavior of Context Free/cfdg. Configuration declarations must be at the top-level, they cannot be inside of shapes or paths.
If a configuration variable is declared multiple times then the first declaration is used and the rest are ignored. Configuration declarations in imported files are ignored if the same variable is declared in the importing CFDG file, even if the higher level declaration comes after the imported declaration. CF::Impure is the exception to this rule: declaring CF::impure enables or disables context-free enforcement from that point forward.
CF::AllowOverlap = 1
Context Free issues a warning if there are two variables with the same name at the same scope level. Setting CF::AllowOverlap to 1 disables the warning messages for variables with the same name.
CF::Alpha = 1
Setting CF::Alpha to 1 (or any non-zero value) forces the canvas to be RGBA even if the background is opaque. Setting it to zero forces the canvas to be grayscale or RGB and forces the background to be opaque.
CF::Background = [b -1]
Setting CF::Background changes the background color from the default opaque white to some other color. CF::Background must be set to a shape adjustment. The shape adjustment changes the background color relative to the color (hue = 0°, saturation = 0, brightness = 1, alpha = 1). Only the color part of the adjustment is used, any non-color adjustments are ignored.
If there is no CF::Size or CF::Tile declaration then Context Free resizes the design to fit in the canvas with a blank border. This border has a dynamic part and a fixed part. The dynamic border depends on the size of the primitive shapes closest to the edge of the design. Essentially, the primitive shapes are dilated by a scaling factor, CF::BorderDynamic, and the boundary of the dilated primitive shape is used to determine the dynamic border. The default value for CF::BorderDynamic is 2, which results in a dynamic border equal to the size of the closest shape. Setting CF::BorderDynamic to 1 causes the dynamic border to be right at the edge of the primitive shapes. Values between 0 and 1 cause shapes near the edge to lie outside the dynamic border. Values ≤0 result in a value of 1.
There is a fixed border outside the dynamic border. By default this is 8 pixels. The fixed border can be set directly by a CF::BorderFixed declaration.
CF::Color = 1
Normally, Context Free detects if a design has color and uses RGB or RGBA for the canvas. Setting CF::Color to zero or non-zero overrides this and sets the canvas to grayscale or color accordingly.
CF::ColorDepth = 16
By default Context Free uses 8-bit color channels (gray8, rgb24, or rgba32 pixel types). Setting CF::ColorDepth to 16 causes Context Free to use 16-bit color channels instead (gray16, rgb48, or rgba64).
The frame() and ftime() functions only return useful information during animation, not when performing a normal render. Setting CF::Frame tells Context Free what to return from frame() when not animating. Setting CF::FrameTime tells Context Free what to return from ftime() when not animating. This allows the designer to test different frames.
CF::Impure = 1
Context Free places restrictions on numeric and natural shape parameters to prevent context-sensitive designs. These restrictions can be overidden by setting CF::Impure to a non-zero value.
The upper limit on allowable natural numbers. Trying to send a natural number higher than CF::MaxNatural to a function call or shape invocation will result in a runtime error and rendering will halt. The default value for CF::MaxNatural is 1000, but it can be set to any value between 1 and 9,007,199,254,740,992.
Context Free stops executing shapes once they are too small to render. The default minimum size is 0.3 pixels on side. The minimum size can be changed by a CF::MinimumSize declaration. Setting CF::MinimumSize to ≤0 sets the minimum size to the default of 0.3 pixels.
Normally the output canvas contains all of the primitive shapes. As the design is executed the bounding box of all the primitive shapes is accumulated and the shapes are resized and positioned to fit within the canvas (plus the border). A CF::Size declaration directly sets the canvas scaling and position.
CF::Size = [s width height x xpos y ypos]
This sets the canvas width and height in drawing units and sets the position of the center of the canvas to (-xpos, -ypos). Only the geometric part of the adjustment is used, any non-geometric adjustments are ignored. Skew and flip adjustments will produce an error message.
Context Free implements one and two dimensional symmetry operations. These are enabled and configured using the CF::Symmetry declaration.
Setting CF::Tile enables tiled rendering and sets the size of the tiling grid. Only the geometric part of the adjustment is used, any non-geometric adjustments are ignored.
When animating a design using the shape time feature, Context Free accumulates the existence time for all of the primitive shapes and divides this time span evenly for each animation frame. If there is a CF::Time declaration then Context Free uses the provided time span instead. CF::Time must be set to a shape adjustment containing a time adjustment:
CF::Time = [time 0 ((sqrt(5)+1)/2)]