diff --git a/docs/assets/examples/example_canadian_flag_01.png b/docs/assets/examples/example_canadian_flag_01.png new file mode 100644 index 0000000..6063c04 Binary files /dev/null and b/docs/assets/examples/example_canadian_flag_01.png differ diff --git a/docs/assets/examples/example_canadian_flag_02.png b/docs/assets/examples/example_canadian_flag_02.png new file mode 100644 index 0000000..0b2679a Binary files /dev/null and b/docs/assets/examples/example_canadian_flag_02.png differ diff --git a/docs/assets/examples/example_canadian_flag_03.png b/docs/assets/examples/example_canadian_flag_03.png new file mode 100644 index 0000000..6dc7465 Binary files /dev/null and b/docs/assets/examples/example_canadian_flag_03.png differ diff --git a/docs/assets/examples/thumbnail_canadian_flag_01.png b/docs/assets/examples/thumbnail_canadian_flag_01.png new file mode 100644 index 0000000..e55ad4c Binary files /dev/null and b/docs/assets/examples/thumbnail_canadian_flag_01.png differ diff --git a/docs/examples_1.rst b/docs/examples_1.rst index 867e3b3..4bac3c7 100644 --- a/docs/examples_1.rst +++ b/docs/examples_1.rst @@ -39,7 +39,12 @@ Most of the examples show the builder and algebra modes. :link: examples-build123d_logo :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 diff --git a/examples/canadian_flag.py b/examples/canadian_flag.py index 827ffa3..388c8f2 100644 --- a/examples/canadian_flag.py +++ b/examples/canadian_flag.py @@ -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] \ No newline at end of file diff --git a/examples/canadian_flag_algebra.py b/examples/canadian_flag_algebra.py index 8cd3030..cf3ea99 100644 --- a/examples/canadian_flag_algebra.py +++ b/examples/canadian_flag_algebra.py @@ -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] \ No newline at end of file