module Layout::PrimitiveTools
Overview
Tools for using primitives
Direct including types
Defined in:
primitive_tools.crMacro Summary
-
primitive(name)
Defines a new primitive.
Macro Detail
macro primitive(name)
#
Defines a new primitive. This will generate several helper methods so you can properly initialize your primitives.
Example
Here we create a sample Point class that has an x
and y
primitive.
Now, after setting some contraints we can load the constraints into Kiwi::Solver
and find the final values.
require "layout/primitive_tools"
require "kiwi"
class Point
include PrimitiveTools
primitive :x
primitive :y
end
a = Point.new
b = Point.new
b.x.eq a.x + 10
b.y.eq a.y / 2
a.x.eq 10
a.y.eq 10
# go on to solve the block
For a full example take a look at the implementation of Block
.