 |
CLIP Score: 30.06
from AIDL import *
def barn(
base_length: float = 20 * feet,
base_width: float = 10 * feet,
base_height: float = 10 * feet,
roof_height: float = 5 * feet,
door_width: float = 3 * feet,
door_height: float = 7 * feet,
window_size: float = 2 * feet # assuming square windows
):
"""
Model a simple barn with a rectangular base, a pitched roof, a door, and windows.
"""
barn = Solid()
# Base Structure
base = Solid()
barn.base = base
base.body = Rectangle((0, 0), base_length, base_height)
# Roof Structure
roof = Solid(shift=(0, base_height / 2 + roof_height / 2))
barn.roof = roof
# Triangular pitched roof. Centered at the top of the base.
roof.left_side = Triangle(
(-base_length / 2, 0), height=roof_height, base_width=base_length
)
roof.right_side = Triangle(
(base_length / 2, 0), height=-roof_height, base_width=-base_length
)
# Door
door = Hole()
barn.door = door
door.rect = Rectangle((0, -base_height / 2 + door_height / 2), door_width, door_height)
# Windows
windows = Hole()
barn.windows = windows
# Left window
windows.left = Rectangle((-base_length / 4, 0), window_size, window_size)
# Right window
windows.right = Rectangle((base_length / 4, 0), window_size, window_size)
return barn
with AIDL_2D:
model = barn()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a barn on a farm
Sure! Let's break down the features of a typical barn. A barn usually has:
1. A rectangular base structure.
2. A pitched roof consisting of two triangular sections.
3. Windows and doors.
4. Possibly some additional decorative elements or details.
We'll create a barn with a rectangular base, a triangular gable roof, a door, and some windows.
Let's start by defining the structure of the barn and step-by-step adding its components.
```python
from AIDL import *
def barn(
base_length: float = 20 * feet,
base_width: float = 10 * feet,
base_height: float = 10 * feet,
roof_height: float = 5 * feet,
door_width: float = 3 * feet,
door_height: float = 7 * feet,
window_size: float = 2 * feet # assuming square windows
):
"""
Model a simple barn with a rectangular base, a pitched roof, a door, and windows.
"""
barn = Solid()
# Base Structure
base = Solid()
barn.base = base
base.body = Rectangle((0, 0), base_length, base_height)
# Roof Structure
roof = Solid(shift=(0, base_height / 2 + roof_height / 2))
barn.roof = roof
# Triangular pitched roof. Centered at the top of the base.
roof.left_side = Triangle(
(-base_length / 2, 0), height=roof_height, base_width=base_length
)
roof.right_side = Triangle(
(base_length / 2, 0), height=-roof_height, base_width=-base_length
)
# Door
door = Hole()
barn.door = door
door.rect = Rectangle((0, -base_height / 2 + door_height / 2), door_width, door_height)
# Windows
windows = Hole()
barn.windows = windows
# Left window
windows.left = Rectangle((-base_length / 4, 0), window_size, window_size)
# Right window
windows.right = Rectangle((base_length / 4, 0), window_size, window_size)
return barn
with AIDL_2D:
model = barn()
print(model.Solve())
model.Render()
```
This code defines a barn with:
1. A solid base that is a rectangular structure.
2. A roof consisting of two triangles representing the gable roof.
3. A rectangular door rendered as a hole in the base.
4. Two square windows (holes) on the front face of the barn.
Feel free to modify the dimensions or add more details as needed. Let me know if you need any adjustments or additional features!
|