 |
CLIP Score: 26.66
from AIDL import *
def old_telephone(
base_width: float = 8 * inches,
base_height: float = 5 * inches,
dial_radius: float = 2 * inches,
handset_length: float = 7 * inches,
handset_width: float = 1.5 * inches,
earpiece_radius: float = 0.75 * inches,
cord_length: float = 4 * inches):
"""
Creates a model of an old-school telephone.
"""
# The main structure of the telephone
telephone = Solid()
# Define the base structure
base = Solid()
telephone.base = base
# Define the dial structure
dial = Solid(shift=(0, 0.5 * base_height))
base.dial = dial
# Define the handset structure
handset = Solid(shift=(0, 1.5 * base_height))
receiver = Solid(shift=(-0.5 * handset_length, 0))
mouthpiece = Solid(shift=(0.5 * handset_length, 0))
handset.receiver = receiver
handset.mouthpiece = mouthpiece
telephone.handset = handset
# Define the cord structure
cord = Drawing()
telephone.cord = cord
# Base geometry
base.body = RoundedRectangle((0, 0), base_width, base_height, base_height / 10)
# Dial geometry
dial.disk = Circle((0, 0), dial_radius)
dial.hole = Hole()
dial.hole.center_hole = Circle((0, 0), dial_radius * 0.25)
# Define the numbers (holes for fingers)
dial.numbers = [Hole() for _ in range(10)]
for i in range(10):
angle = (i * 36 - 90) * (pi / 180)
x = 0.7 * dial_radius * cos(angle)
y = 0.7 * dial_radius * sin(angle)
dial.numbers[i].finger_hole = Circle((x, y), 0.25 * dial_radius)
# Handset geometry
handset.body = Rectangle((0, 0), handset_length, handset_width)
# Receiver geometry
receiver.disk = Circle((0, 0), earpiece_radius)
# Mouthpiece geometry
mouthpiece.disk = Circle((0, 0), earpiece_radius)
# Cord geometry
cord.start = Point(0, 0.5 * base_height)
cord.end = Point(0, 1.5 * base_height)
cord.line = Line(cord.start, cord.end)
return telephone
with AIDL_2D:
model = old_telephone()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a old-school telephone
Sure, let's get started on writing an AIDL program to generate an old-school telephone. Here’s how we can break down the structure of a telephone:
1. **Base**: The main body of the telephone which often has a rectangular shape.
2. **Rotary Dial**: A circular dial, often in the center of the base.
3. **Handset**: The part you pick up to talk, which usually rests on the base.
4. **Receiver and Mouthpiece**: Parts of the handset where you listen and talk.
5. **Cord**: A coiled line between the handset and the base (to keep it simple, we’ll depict this as a straight or curved line).
Here is how we can piece this together in AIDL:
```python
from AIDL import *
def old_telephone(
base_width: float = 8 * inches,
base_height: float = 5 * inches,
dial_radius: float = 2 * inches,
handset_length: float = 7 * inches,
handset_width: float = 1.5 * inches,
earpiece_radius: float = 0.75 * inches,
cord_length: float = 4 * inches):
"""
Creates a model of an old-school telephone.
"""
# The main structure of the telephone
telephone = Solid()
# Define the base structure
base = Solid()
telephone.base = base
# Define the dial structure
dial = Solid(shift=(0, 0.5 * base_height))
base.dial = dial
# Define the handset structure
handset = Solid(shift=(0, 1.5 * base_height))
receiver = Solid(shift=(-0.5 * handset_length, 0))
mouthpiece = Solid(shift=(0.5 * handset_length, 0))
handset.receiver = receiver
handset.mouthpiece = mouthpiece
telephone.handset = handset
# Define the cord structure
cord = Drawing()
telephone.cord = cord
# Base geometry
base.body = RoundedRectangle((0, 0), base_width, base_height, base_height / 10)
# Dial geometry
dial.disk = Circle((0, 0), dial_radius)
dial.hole = Hole()
dial.hole.center_hole = Circle((0, 0), dial_radius * 0.25)
# Define the numbers (holes for fingers)
dial.numbers = [Hole() for _ in range(10)]
for i in range(10):
angle = (i * 36 - 90) * (pi / 180)
x = 0.7 * dial_radius * cos(angle)
y = 0.7 * dial_radius * sin(angle)
dial.numbers[i].finger_hole = Circle((x, y), 0.25 * dial_radius)
# Handset geometry
handset.body = Rectangle((0, 0), handset_length, handset_width)
# Receiver geometry
receiver.disk = Circle((0, 0), earpiece_radius)
# Mouthpiece geometry
mouthpiece.disk = Circle((0, 0), earpiece_radius)
# Cord geometry
cord.start = Point(0, 0.5 * base_height)
cord.end = Point(0, 1.5 * base_height)
cord.line = Line(cord.start, cord.end)
return telephone
with AIDL_2D:
model = old_telephone()
print(model.Solve())
model.Render()
```
In this implementation:
- We've constructed a base structure with a `RoundedRectangle`.
- A dial is added to the base, comprising a central `Circle` and several finger holes positioned at intervals.
- A handset is defined with a rectangular body, accompanied by two smaller circles representing the receiver and mouthpiece.
- Lastly, a simple straight line symbolizes the cord.
Let me know if you want to modify any specific part, or if you have additional features you'd like to include!
|