title | author |
---|---|
Building a Picket Fence |
Caleb Hsu |
Objective: Build a picket fence with adjustable length and height.
Start by creating a row of picket boards. We can add parameters after we have determined our dimensions.
<craft>
<row spacing="5">
<repeat n="6">
<cube size="5 3 40" color="wheat"></cube>
</repeat>
</row>
</craft>
Next, create triangular picket spikes using prism
.
<craft>
<row spacing="5">
<repeat n="6">
<prism width="5" length="3"></prism>
</repeat>
</row>
</craft>
Stack
the spikes over the boards to make pickets
<craft>
<stack>
<row spacing="5">
<repeat n="6">
<prism width="5" length="3"></prism>
</repeat>
</row>
<row spacing="5">
<repeat n="6">
<cube size="5 3 40" color="white"></cube>
</repeat>
</row>
</stack>
</craft>
Next, stack
two boards to create the rails.
<craft>
<stack spacing="13" transform="translate(0,0,8)">
<repeat n="2">
<cube size="55 2 5"></cube>
</repeat>
</stack>
</craft>
Combine rails with pickets to complete the fence. Feel free to experiment with positioning until the fence looks right.
<craft>
<g>
<stack spacing="13" transform="translate(0,0,8)">
<repeat n="2">
<cube size="55 2 5"></cube>
</repeat>
</stack>
<stack color="wheat">
<row spacing="5">
<repeat n="6">
<prism width="5" length="3"></prism>
</repeat>
</row>
<row spacing="5">
<repeat n="6">
<cube size="5 3 40"></cube>
</repeat>
</row>
</stack>
</g>
</craft>
Now that we've finalized the dimensions, parameterize picket height and fence length.
<craft name="fence">
<parameter name="length" type="int" default="55"/>
<parameter name="height" type="int" default="40"/>
<group color="wheat">
<stack spacing="{{height / 3}}" transform="translate(0,0,{{height/6}})">
<repeat n="2">
<cube size="{{length}} 2 5"></cube>
</repeat>
</stack>
<stack>
<row spacing="5">
<repeat n="{{length / 10}}">
<prism width="5" length="3"></prism>
</repeat>
</row>
<row spacing="5">
<repeat n="{{length / 10}}">
<cube size="5 3 {{height}}"></cube>
</repeat>
</row>
</stack>
</group>
</craft>