home Defines a line providing start and end point
A: point(-5,-5)
B: point(5,5)
line: Line(A,B)
A = point(-5,-5)
B = point(5,5)
line = Line(A,B)
home Defines a rectangle providing bottom left corner, x dimension, y dimension
L: 8
h: 5
p: point(-(L/2),-(h/2))
rectangle: Rectangle(p,L,h)
L = 8
h = 5
p = point(-(L/2),-(h/2))
rectangle = Rectangle(p,L,h)
home Defines a circle proving center and radius
circle: Circle(point(0,0),5)
circle = Circle(point(0,0),5)
home Defines a triangle providing three corner
L: 3.0
W: 4.0
triangle: Triangle(p1=(W/2,0), p2=(3*W/2,W/2), p3=(4*W/5.,L))
L = 3.0
W = 4.0
triangle = Triangle(p1=(W/2,0), p2=(3*W/2,W/2), p3=(4*W/5.,L))
home Defines a sizing mark with a label
fontsize: 14
t: r'$ 2\pi R^2 $' # sample text
dwt: Distance_wText((-4,0), (8, 5), t, fontsize)
fontsize=14
t = r'$ 2\pi R^2 $' # sample text
dwt = Distance_wText((-4,0), (8, 5), t, fontsize)
home Defines a given text positionned at the provided point
text: Text(r'$c$', point(0,0))
text = Text(r'$c$', point(0,0))
home Defines a cross positionned at the provided point
cross: Cross(point(0,0))
cross = Cross(point(1,0))
home Defines an axis at the given point with a given label
axis: Axis((0,0), 5, 'x', rotation_angle=0)
axis = Axis((0,0), 5, 'x', rotation_angle=0)
home Defines an Arc providing a center point, a radius, a starting angle and an angle (rotates clock-wise)
center: point(0,0)
radius: 1
angle: 120
start_angle: 180-angle
arc_angle: angle
arc: Arc(center, radius, start_angle, arc_angle)
center = point(0,0)
radius = 1
angle = 120
start_angle = 180-angle
arc_angle = angle
arc = Arc(center, radius, start_angle, arc_angle)
home In order to display the various shapes, use the following code in a jupyter notebook
[1]: %matplotlib widget
[2]: from pysketcher import *
[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 to add those extra steps
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)
myfig={}
sketch="""
# put here the yaml 'object' definition
"""
drawing_tool.erase()
sketchParse(sketch,myfig)
# replace 'object' by the actual one
d = myfig['object'].draw()
drawing_tool.display()
drawing_tool.erase()
# put the code of the object case here
# replace object by the actual name line, rectangle, circle...
object.draw()
drawing_tool.display()