mirror of
https://github.com/gumyr/build123d.git
synced 2025-12-06 02:30:55 -08:00
(+ example_1.rst)
This commit is contained in:
parent
6e06a14cb5
commit
b18d176706
7 changed files with 78 additions and 36 deletions
BIN
docs/assets/examples/example_canadian_flag_01.png
Normal file
BIN
docs/assets/examples/example_canadian_flag_01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 30 KiB |
BIN
docs/assets/examples/example_canadian_flag_02.png
Normal file
BIN
docs/assets/examples/example_canadian_flag_02.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 20 KiB |
BIN
docs/assets/examples/example_canadian_flag_03.png
Normal file
BIN
docs/assets/examples/example_canadian_flag_03.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 26 KiB |
BIN
docs/assets/examples/thumbnail_canadian_flag_01.png
Normal file
BIN
docs/assets/examples/thumbnail_canadian_flag_01.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 19 KiB |
|
|
@ -40,6 +40,11 @@ Most of the examples show the builder and algebra modes.
|
|||
:link-type: ref
|
||||
|
||||
|
||||
.. grid-item-card:: Canadian Flag blowing in the wind |Builder| |Algebra|
|
||||
:img-top: assets/examples/thumbnail_canadian_flag_01.png
|
||||
:link: examples-canadian_flag
|
||||
:link-type: ref
|
||||
|
||||
.. NOTE 01: insert new example thumbnails above this line
|
||||
|
||||
.. TODO: Copy this block to add the example thumbnails here
|
||||
|
|
@ -157,6 +162,43 @@ The builder mode example also generates the SVG file `logo.svg`.
|
|||
:start-after: [Code]
|
||||
:end-before: [End]
|
||||
|
||||
|
||||
.. _examples-canadian_flag:
|
||||
|
||||
Canadian Flag blowing in the wind
|
||||
--------------------------------
|
||||
.. image:: assets/examples/example_canadian_flag_01.png
|
||||
:align: center
|
||||
|
||||
|
||||
|
||||
A Canadian Flag blowing in the wind created by projecting planar faces onto a non-planar face (the_wind).
|
||||
|
||||
This example also demonstrates building complex lines that snap to existing features.
|
||||
|
||||
|
||||
.. dropdown:: More Images
|
||||
|
||||
.. image:: assets/examples/example_canadian_flag_02.png
|
||||
:align: center
|
||||
|
||||
.. image:: assets/examples/example_canadian_flag_03.png
|
||||
:align: center
|
||||
|
||||
|
||||
.. dropdown:: |Builder| Reference Implementation (Builder Mode)
|
||||
|
||||
.. literalinclude:: ../examples/canadian_flag.py
|
||||
:start-after: [Code]
|
||||
:end-before: [End]
|
||||
|
||||
.. dropdown:: |Algebra| Reference Implementation (Algebra Mode)
|
||||
|
||||
.. literalinclude:: ../examples/canadian_flag_algebra.py
|
||||
:start-after: [Code]
|
||||
:end-before: [End]
|
||||
|
||||
|
||||
.. NOTE 02: insert new example thumbnails above this line
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,43 +1,36 @@
|
|||
"""
|
||||
name: "canadian_flag.py"
|
||||
title: "Canadian Flag blowing in the wind"
|
||||
authors: "Gumyr"
|
||||
license: "http://www.apache.org/licenses/LICENSE-2.0"
|
||||
created: "2023-02-23"
|
||||
modified: "2023-07-31"
|
||||
|
||||
description: |
|
||||
A Canadian Flag blowing in the wind created by projecting planar faces onto a non-planar face (the_wind).
|
||||
|
||||
This example also demonstrates building complex lines that snap to existing features.
|
||||
|
||||
has_builder_mode: true
|
||||
has_algebra_mode: true
|
||||
image_files:
|
||||
- "example_canadian_flag_01.png"
|
||||
- "example_canadian_flag_02.png"
|
||||
- "example_canadian_flag_03.png"
|
||||
"""
|
||||
|
||||
Projection Examples: Canadian Flag in the Wind
|
||||
|
||||
name: canadian_flag.py
|
||||
by: Gumyr
|
||||
date: February 23th 2023
|
||||
|
||||
desc: A Canadian Flag blowing in the wind created by projecting planar
|
||||
faces onto a non-planar face (the_wind).
|
||||
|
||||
This example also demonstrates building complex lines that snap to
|
||||
existing features.
|
||||
|
||||
license:
|
||||
|
||||
Copyright 2023 Gumyr
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
||||
"""
|
||||
# [Imports]
|
||||
from math import sin, cos, pi
|
||||
from build123d import *
|
||||
from ocp_vscode import show_object
|
||||
|
||||
# [Parameters]
|
||||
# Canadian Flags have a 2:1 aspect ratio
|
||||
height = 50
|
||||
width = 2 * height
|
||||
wave_amplitude = 3
|
||||
|
||||
# [Code]
|
||||
|
||||
def surface(amplitude, u, v):
|
||||
"""Calculate the surface displacement of the flag at a given position"""
|
||||
|
|
@ -112,3 +105,4 @@ show_object(west_field, name="west", options={"color": (255, 0, 0)})
|
|||
show_object(east_field, name="east", options={"color": (255, 0, 0)})
|
||||
show_object(center_field, name="center", options={"color": (255, 255, 255)})
|
||||
show_object(maple_leaf, name="maple", options={"color": (255, 0, 0)})
|
||||
# [End]
|
||||
|
|
@ -1,12 +1,18 @@
|
|||
"""
|
||||
for details see `canadian_flag.py`
|
||||
"""
|
||||
# [Imports]
|
||||
from math import sin, cos, pi
|
||||
from build123d import *
|
||||
from ocp_vscode import *
|
||||
|
||||
# [Parameters]
|
||||
# Canadian Flags have a 2:1 aspect ratio
|
||||
height = 50
|
||||
width = 2 * height
|
||||
wave_amplitude = 3
|
||||
|
||||
|
||||
# [Code]
|
||||
def surface(amplitude, u, v):
|
||||
"""Calculate the surface displacement of the flag at a given position"""
|
||||
return v * amplitude / 20 * cos(3.5 * pi * u) + amplitude / 10 * v * sin(
|
||||
|
|
@ -80,8 +86,8 @@ center_field = project(center_field_planar)
|
|||
maple_leaf = project(maple_leaf_planar)
|
||||
|
||||
|
||||
if "show_object" in locals():
|
||||
show_object(west_field, name="west", options={"color": (255, 0, 0)})
|
||||
show_object(east_field, name="east", options={"color": (255, 0, 0)})
|
||||
show_object(center_field, name="center", options={"color": (255, 255, 255)})
|
||||
show_object(maple_leaf, name="maple", options={"color": (255, 0, 0)})
|
||||
show_object(west_field, name="west", options={"color": (255, 0, 0)})
|
||||
show_object(east_field, name="east", options={"color": (255, 0, 0)})
|
||||
show_object(center_field, name="center", options={"color": (255, 255, 255)})
|
||||
show_object(maple_leaf, name="maple", options={"color": (255, 0, 0)})
|
||||
# [End]
|
||||
Loading…
Add table
Add a link
Reference in a new issue