Gilbert Brault 5 anni fa
parent
commit
c435e95821

+ 59 - 25
jupysketch-doc/docs/reference.md

@@ -1,4 +1,22 @@
+## List of Shapes
+
+[Code to display shapes](#code-to-display-the-above-defined-shapes)
+
+- [Line](#line): defines a line providing start and end point
+- [Rectangle](#rectangle): defines a rectangle providing bottom left corner, x dimension, y dimension
+- [Triangle](#triangle): defines a triangle providing three corner
+- [Circle](#circle): defines a circle proving center and radius
+- [Distance with text](#distance-with-text): defines a sizing mark with a label 
+- [Text](#text): defines a given text positionned at the provided point
+- [Cross](#cross): defines a cross positionned at the provided point
+- [Axis](#axis): defines an axis at the given point with a given label
+- [Arc](#arc): defines an Arc providing a center point, a radius, a starting angle and an angle (rotates clock-wise)
+- [](#)
+- [](#)
+- [](#)
+
 ## Line
+[home](#list-of-shapes) Defines a line providing start and end point
 ### Yaml
 ```yaml
 A: point(-5,-5)
@@ -13,6 +31,7 @@ line = Line(A,B)
 ```
 ![line](reference/line.svg)
 ## Rectangle
+[home](#list-of-shapes) Defines a rectangle providing bottom left corner, x dimension, y dimension
 ### Yaml
 ```yaml
 L: 8
@@ -29,6 +48,7 @@ rectangle = Rectangle(p,L,h)
 ```
 ![rectangle](reference/rectangle.svg)
 ## Circle
+[home](#list-of-shapes) Defines a circle proving center and radius
 ### Yaml
 ```yaml
 circle: Circle(point(0,0),5)
@@ -39,6 +59,7 @@ circle = Circle(point(0,0),5)
 ```
 ![circle](reference/circle.svg)
 ## Triangle
+[home](#list-of-shapes) Defines a triangle providing three corner
 ### Yaml
 ```yaml
 L: 3.0
@@ -53,6 +74,7 @@ triangle = Triangle(p1=(W/2,0), p2=(3*W/2,W/2), p3=(4*W/5.,L))
 ```
 ![triangle](reference/triangle.svg)
 ## Distance with text
+[home](#list-of-shapes) Defines a sizing mark with a label 
 ### Yaml
 ```yaml
 fontsize: 14
@@ -67,6 +89,7 @@ dwt = Distance_wText((-4,0), (8, 5), t, fontsize)
 ```
 ![Distance with text](reference/distancewithtext.svg)
 ## Text
+[home](#list-of-shapes) Defines a given text positionned at the provided point
 ### Yaml
 ```yaml
 text: Text(r'$c$', point(0,0))
@@ -76,45 +99,56 @@ text: Text(r'$c$', point(0,0))
 text = Text(r'$c$', point(0,0))
 ```
 ![Text](reference/text.svg)
-## Cross (self designed)
+## Cross
+[home](#list-of-shapes) Defines a cross positionned at the provided point
 ### Yaml
 ```yaml
-c: point(0,0)
-l: 0.1
-line1: Line(c+point(-l,l),c+point(l,-l))
-line2: Line(c+point(l,l), c+point(-l,-l))
-cross: 
-    formula: "Composition({'line1': line1, 'line2': line2})"
-    style:
-        linecolor: black
-        linewidth: 1
+cross: Cross(point(0,0))
 ```
 ### Python
 ```python
-c = point(0,0)
-l = 0.1
-line1 = Line(c+point(-l,l),c+point(l,-l))
-line2 = Line(c+point(l,l), c+point(-l,-l))
-cross = Composition({'line1': line1, 'line2': line2})
-cross.set_linecolor('black')
-cross.set_linewidth(1)
+cross = Cross(point(1,0))
 ```
 ![Cross](reference/cross.svg)
 
-## Cross (from shapes)
+## Axis
+[home](#list-of-shapes) Defines an axis at the given point with a given label
 ### Yaml
 ```yaml
-cross1: Cross(point(0,0))
+axis: Axis((0,0), 5, 'x', rotation_angle=0)
 ```
 ### Python
 ```python
-cross = Cross(point(1,0))
+axis = Axis((0,0), 5, 'x', rotation_angle=0)
 ```
-![Cross](reference/cross.svg)
+![Axis](reference/axis.svg)
+
+## Arc
+[home](#list-of-shapes) Defines an Arc providing a center point, a radius, a starting angle and an angle (rotates clock-wise)
+### Yaml
+```yaml
+center: point(0,0)
+radius: 1
+angle: 120
+start_angle: 180-angle
+arc_angle: angle
+arc: Arc(center, radius, start_angle, arc_angle)
+```
+### Python
+```python
+center = point(0,0)
+radius = 1
+angle = 120
+start_angle = 180-angle
+arc_angle = angle
+arc = Arc(center, radius, start_angle, arc_angle)
+```
+![Axis](reference/axis.svg)
+
+## Code to display the above defined shapes
 
-## Code initialization
+[home](#list-of-shapes) In order to display the various shapes, use the following code in a jupyter notebook
 
-Using the following framework in a jupyter notebook
 
 ```python
 [1]: %matplotlib widget
@@ -122,15 +156,15 @@ Using the following framework in a jupyter notebook
 [3]: drawing_tool.set_coordinate_system(xmin=-10, xmax=10,ymin=-10, ymax=10,axis=True)
 [4]: drawing_tool.mpl.gcf().canvas
 ```
-for Yaml, you need the added steps
+for Yaml, you need to add those extra steps
 
 ```python
 head = """\
 libraries: ["from math import tan, radians, sin, cos","from pysketcher import *"]
-"""
 myfig={}
 sketchParse(head,myfig)
 ```
+The above code initialize myfig sketch space loading into it libraries references so samples can use tan, radians, si, cos and all the objects defined in pysketcher (the module name of jupytersketcher)
 
 ### Yaml
 

File diff suppressed because it is too large
+ 357 - 0
jupysketch-doc/docs/reference/arc.svg


File diff suppressed because it is too large
+ 369 - 0
jupysketch-doc/docs/reference/axis.svg


+ 77 - 13
jupysketch-doc/site/reference/index.html

@@ -380,11 +380,11 @@
 </li>
       
         <li class="md-nav__item">
-  <a href="#cross" class="md-nav__link">
-    Cross
+  <a href="#cross-self-designed" class="md-nav__link">
+    Cross (self designed)
   </a>
   
-    <nav class="md-nav" aria-label="Cross">
+    <nav class="md-nav" aria-label="Cross (self designed)">
       <ul class="md-nav__list">
         
           <li class="md-nav__item">
@@ -404,6 +404,33 @@
       </ul>
     </nav>
   
+</li>
+      
+        <li class="md-nav__item">
+  <a href="#cross-from-shapes" class="md-nav__link">
+    Cross (from shapes)
+  </a>
+  
+    <nav class="md-nav" aria-label="Cross (from shapes)">
+      <ul class="md-nav__list">
+        
+          <li class="md-nav__item">
+  <a href="#yaml_7" class="md-nav__link">
+    Yaml
+  </a>
+  
+</li>
+        
+          <li class="md-nav__item">
+  <a href="#python_7" class="md-nav__link">
+    Python
+  </a>
+  
+</li>
+        
+      </ul>
+    </nav>
+  
 </li>
       
         <li class="md-nav__item">
@@ -415,14 +442,14 @@
       <ul class="md-nav__list">
         
           <li class="md-nav__item">
-  <a href="#yaml_7" class="md-nav__link">
+  <a href="#yaml_8" class="md-nav__link">
     Yaml
   </a>
   
 </li>
         
           <li class="md-nav__item">
-  <a href="#python_7" class="md-nav__link">
+  <a href="#python_8" class="md-nav__link">
     Python
   </a>
   
@@ -626,11 +653,11 @@
 </li>
       
         <li class="md-nav__item">
-  <a href="#cross" class="md-nav__link">
-    Cross
+  <a href="#cross-self-designed" class="md-nav__link">
+    Cross (self designed)
   </a>
   
-    <nav class="md-nav" aria-label="Cross">
+    <nav class="md-nav" aria-label="Cross (self designed)">
       <ul class="md-nav__list">
         
           <li class="md-nav__item">
@@ -650,6 +677,33 @@
       </ul>
     </nav>
   
+</li>
+      
+        <li class="md-nav__item">
+  <a href="#cross-from-shapes" class="md-nav__link">
+    Cross (from shapes)
+  </a>
+  
+    <nav class="md-nav" aria-label="Cross (from shapes)">
+      <ul class="md-nav__list">
+        
+          <li class="md-nav__item">
+  <a href="#yaml_7" class="md-nav__link">
+    Yaml
+  </a>
+  
+</li>
+        
+          <li class="md-nav__item">
+  <a href="#python_7" class="md-nav__link">
+    Python
+  </a>
+  
+</li>
+        
+      </ul>
+    </nav>
+  
 </li>
       
         <li class="md-nav__item">
@@ -661,14 +715,14 @@
       <ul class="md-nav__list">
         
           <li class="md-nav__item">
-  <a href="#yaml_7" class="md-nav__link">
+  <a href="#yaml_8" class="md-nav__link">
     Yaml
   </a>
   
 </li>
         
           <li class="md-nav__item">
-  <a href="#python_7" class="md-nav__link">
+  <a href="#python_8" class="md-nav__link">
     Python
   </a>
   
@@ -775,7 +829,7 @@ dwt = Distance_wText((-4,0), (8, 5), t, fontsize)
 </code></pre>
 
 <p><img alt="Text" src="text.svg" /></p>
-<h2 id="cross">Cross</h2>
+<h2 id="cross-self-designed">Cross (self designed)</h2>
 <h3 id="yaml_6">Yaml</h3>
 <pre><code class="yaml">c: point(0,0)
 l: 0.1
@@ -798,6 +852,16 @@ cross.set_linecolor('black')
 cross.set_linewidth(1)
 </code></pre>
 
+<p><img alt="Cross" src="cross.svg" /></p>
+<h2 id="cross-from-shapes">Cross (from shapes)</h2>
+<h3 id="yaml_7">Yaml</h3>
+<pre><code class="yaml">cross1: Cross(point(0,0))
+</code></pre>
+
+<h3 id="python_7">Python</h3>
+<pre><code class="python">cross = Cross(point(1,0))
+</code></pre>
+
 <p><img alt="Cross" src="cross.svg" /></p>
 <h2 id="code-initialization">Code initialization</h2>
 <p>Using the following framework in a jupyter notebook</p>
@@ -815,7 +879,7 @@ myfig={}
 sketchParse(head,myfig)
 </code></pre>
 
-<h3 id="yaml_7">Yaml</h3>
+<h3 id="yaml_8">Yaml</h3>
 <pre><code class="python">myfig={}
 sketch=&quot;&quot;&quot;
 # put here the yaml 'object' definition
@@ -827,7 +891,7 @@ d = myfig['object'].draw()
 drawing_tool.display()
 </code></pre>
 
-<h3 id="python_7">Python</h3>
+<h3 id="python_8">Python</h3>
 <pre><code class="python">drawing_tool.erase()
 # put the code of the object case here
 # replace object by the actual name line, rectangle, circle...

File diff suppressed because it is too large
+ 1 - 1
jupysketch-doc/site/search/search_index.json


BIN
jupysketch-doc/site/sitemap.xml.gz


File diff suppressed because it is too large
+ 497 - 5199
notebooks/reference_doc.ipynb


+ 3 - 0
pysketcher/shapes.py

@@ -1653,6 +1653,9 @@ class Distance_wText(Shape):
         return d
 
 class Arc_wText(Shape):
+    """
+    Arc with text positionned arc half-way
+    """
     def __init__(self, text, center, radius,
                  start_angle, arc_angle, fontsize=0,
                  resolution=180, text_spacing=1/60.):