 |
CLIP Score: 27.64
from AIDL import *
def vintage_camera(
body_width: float = 8 * inches,
body_height: float = 6 * inches,
lens_diameter: float = 3 * inches,
viewfinder_width: float = 1.5 * inches,
viewfinder_height: float = 1.0 * inch,
shutter_button_diameter: float = 0.5 * inch
):
"""
Creates a model of a vintage camera with major parts: body, lens, viewfinder, and shutter button.
"""
# Define the main structure of the camera
camera = Solid()
# Define substructures for body, lens, viewfinder, and shutter button
body = Solid()
lens = Solid()
viewfinder = Solid()
shutter_button = Solid()
# Attach the substructures to the main structure
camera.body = body
camera.lens = lens
camera.viewfinder = viewfinder
camera.shutter_button = shutter_button
# Define Geometry
# Body Geometry
body.main = Rectangle((0, 0), body_width, body_height)
# Lens Geometry
lens.outer = Circle((0, 0), lens_diameter / 2)
lens.inner = Circle((0, 0), lens_diameter / 3)
# Viewfinder Geometry
viewfinder.rect = Rectangle((0, 0), viewfinder_width, viewfinder_height)
# Shutter Button Geometry
shutter_button.circle = Circle((0, 0), shutter_button_diameter / 2)
# Additional Decorative Elements on Body
body.details = Drawing()
body.details.line_top = Line(
(body_width / 2, body_height / 2),
(body_width / 2, body_height / 2 - 1 * inches)
)
body.details.line_bottom = Line(
(body_width / 2, -body_height / 2),
(body_width / 2, -body_height / 2 + 1 * inches)
)
body.details.border_top = Line(
(-body_width / 2, body_height / 2),
(body_width / 2, body_height / 2)
)
body.details.border_bottom = Line(
(-body_width / 2, -body_height / 2),
(body_width / 2, -body_height / 2)
)
# Compositional Constraints
# Lens in the center of the body
camera.AddConstraint(body.bb.horizontal_center == lens.bb.horizontal_center)
# Lens is positioned towards the bottom center of the body
camera.AddConstraint(lens.bb.top == body.bb.vertical_center - (body_height / 4))
# Viewfinder at the top center of the body
camera.AddConstraint(viewfinder.bb.horizontal_center == body.bb.horizontal_center)
camera.AddConstraint(viewfinder.bb.bottom == body.bb.top + (body_height / 6))
# Shutter button on the top right of the body
camera.AddConstraint(shutter_button.bb.top == body.bb.top - (shutter_button_diameter / 2))
camera.AddConstraint(shutter_button.bb.right == body.bb.right - (shutter_button_diameter / 2))
return camera
with AIDL_2D:
model = vintage_camera()
print(model.Solve())
model.Render()
|
Please write an AIDL program to generate a vintage camera
Sure, let's start step-by-step to create a vintage camera model using AIDL. We'll begin by outlining the structure and the major components of the vintage camera.
### Step 1: Define the Structure
We will start by defining the major parts of the camera:
- The body of the camera.
- The lens.
- The viewfinder.
- The shutter button.
```python
from AIDL import *
def vintage_camera(
body_width: float = 8 * inches,
body_height: float = 6 * inches,
lens_diameter: float = 3 * inches,
viewfinder_width: float = 1.5 * inches,
viewfinder_height: float = 1.0 * inch,
shutter_button_diameter: float = 0.5 * inch
):
"""
Creates a model of a vintage camera with major parts: body, lens, viewfinder, and shutter button.
"""
# Define the main structure of the camera
camera = Solid()
# Define substructures for body, lens, viewfinder, and shutter button
body = Solid()
lens = Solid()
viewfinder = Solid()
shutter_button = Solid()
# Attach the substructures to the main structure
camera.body = body
camera.lens = lens
camera.viewfinder = viewfinder
camera.shutter_button = shutter_button
# Compositional Constraints
# Lens in the center of the body
camera.AddConstraint(body.bb.horizontal_center == lens.bb.horizontal_center)
# Lens is positioned towards the bottom center of the body
camera.AddConstraint(lens.bb.top == body.bb.vertical_center - (body_height / 4))
# Viewfinder at the top center of the body
camera.AddConstraint(viewfinder.bb.horizontal_center == body.bb.horizontal_center)
camera.AddConstraint(viewfinder.bb.bottom == body.bb.top + (body_height / 6))
# Shutter button on the top right of the body
camera.AddConstraint(shutter_button.bb.top == body.bb.top - (shutter_button_diameter / 2))
camera.AddConstraint(shutter_button.bb.right == body.bb.right - (shutter_button_diameter / 2))
return camera
with AIDL_2D:
model = vintage_camera()
print(model.Solve())
model.Render()
```
This sets up the basic hierarchy and positioning of the major components of the camera. Next, we will move on to defining the geometry for each of these components.
### Step 2: Define the Geometry
We will add specific shapes to each of these substructures. The body will be a rectangle, the lens a circle, the viewfinder another rectangle, and the shutter button a smaller circle.
Here's the detailed geometry addition for each part:
```python
from AIDL import *
def vintage_camera(
body_width: float = 8 * inches,
body_height: float = 6 * inches,
lens_diameter: float = 3 * inches,
viewfinder_width: float = 1.5 * inches,
viewfinder_height: float = 1.0 * inch,
shutter_button_diameter: float = 0.5 * inch
):
"""
Creates a model of a vintage camera with major parts: body, lens, viewfinder, and shutter button.
"""
# Define the main structure of the camera
camera = Solid()
# Define substructures for body, lens, viewfinder, and shutter button
body = Solid()
lens = Solid()
viewfinder = Solid()
shutter_button = Solid()
# Attach the substructures to the main structure
camera.body = body
camera.lens = lens
camera.viewfinder = viewfinder
camera.shutter_button = shutter_button
# Define Geometry
# Body Geometry
body.main = Rectangle((0, 0), body_width, body_height)
# Lens Geometry
lens.outer = Circle((0, 0), lens_diameter / 2)
lens.inner = Circle((0, 0), lens_diameter / 3)
# Viewfinder Geometry
viewfinder.rect = Rectangle((0, 0), viewfinder_width, viewfinder_height)
# Shutter Button Geometry
shutter_button.circle = Circle((0, 0), shutter_button_diameter / 2)
# Compositional Constraints
# Lens in the center of the body
camera.AddConstraint(body.bb.horizontal_center == lens.bb.horizontal_center)
# Lens is positioned towards the bottom center of the body
camera.AddConstraint(lens.bb.top == body.bb.vertical_center - (body_height / 4))
# Viewfinder at the top center of the body
camera.AddConstraint(viewfinder.bb.horizontal_center == body.bb.horizontal_center)
camera.AddConstraint(viewfinder.bb.bottom == body.bb.top + (body_height / 6))
# Shutter button on the top right of the body
camera.AddConstraint(shutter_button.bb.top == body.bb.top - (shutter_button_diameter / 2))
camera.AddConstraint(shutter_button.bb.right == body.bb.right - (shutter_button_diameter / 2))
return camera
with AIDL_2D:
model = vintage_camera()
print(model.Solve())
model.Render()
```
### Step 3: Add Details and Constraints
Finally, we will introduce any additional details and constraints necessary to make the model look more like a vintage camera. We might need to add details like a lens cover or decorative elements on the camera body.
Here's the complete model incorporating additional details and constraints:
```python
from AIDL import *
def vintage_camera(
body_width: float = 8 * inches,
body_height: float = 6 * inches,
lens_diameter: float = 3 * inches,
viewfinder_width: float = 1.5 * inches,
viewfinder_height: float = 1.0 * inch,
shutter_button_diameter: float = 0.5 * inch
):
"""
Creates a model of a vintage camera with major parts: body, lens, viewfinder, and shutter button.
"""
# Define the main structure of the camera
camera = Solid()
# Define substructures for body, lens, viewfinder, and shutter button
body = Solid()
lens = Solid()
viewfinder = Solid()
shutter_button = Solid()
# Attach the substructures to the main structure
camera.body = body
camera.lens = lens
camera.viewfinder = viewfinder
camera.shutter_button = shutter_button
# Define Geometry
# Body Geometry
body.main = Rectangle((0, 0), body_width, body_height)
# Lens Geometry
lens.outer = Circle((0, 0), lens_diameter / 2)
lens.inner = Circle((0, 0), lens_diameter / 3)
# Viewfinder Geometry
viewfinder.rect = Rectangle((0, 0), viewfinder_width, viewfinder_height)
# Shutter Button Geometry
shutter_button.circle = Circle((0, 0), shutter_button_diameter / 2)
# Additional Decorative Elements on Body
body.details = Drawing()
body.details.line_top = Line(
(body_width / 2, body_height / 2),
(body_width / 2, body_height / 2 - 1 * inches)
)
body.details.line_bottom = Line(
(body_width / 2, -body_height / 2),
(body_width / 2, -body_height / 2 + 1 * inches)
)
body.details.border_top = Line(
(-body_width / 2, body_height / 2),
(body_width / 2, body_height / 2)
)
body.details.border_bottom = Line(
(-body_width / 2, -body_height / 2),
(body_width / 2, -body_height / 2)
)
# Compositional Constraints
# Lens in the center of the body
camera.AddConstraint(body.bb.horizontal_center == lens.bb.horizontal_center)
# Lens is positioned towards the bottom center of the body
camera.AddConstraint(lens.bb.top == body.bb.vertical_center - (body_height / 4))
# Viewfinder at the top center of the body
camera.AddConstraint(viewfinder.bb.horizontal_center == body.bb.horizontal_center)
camera.AddConstraint(viewfinder.bb.bottom == body.bb.top + (body_height / 6))
# Shutter button on the top right of the body
camera.AddConstraint(shutter_button.bb.top == body.bb.top - (shutter_button_diameter / 2))
camera.AddConstraint(shutter_button.bb.right == body.bb.right - (shutter_button_diameter / 2))
return camera
with AIDL_2D:
model = vintage_camera()
print(model.Solve())
model.Render()
```
This code should give a complete AIDL model for a vintage camera with a body, lens, viewfinder, shutter button, and some decorative details. You can modify the dimensions and add more details as desired to match a specific camera design. If there's anything more specific you'd like to add or modify, please let me know!
|