Add 2D shapes in a 3D space to tikzpy object (shapes object)
The shapes object allow to add 2D shapes to the tikzpy object such as:
Line between two points. See shp.line
Path of multiple points. See shp.path
Circle given by center and radius. See shp.circle
Arc given by starting point, radius and angles. See shp.arc and shp.arc_by_center
Text label. See shp.text
Image or bitmaps. See shp.bitmap
Square grid shape (given by two corners). See shp.grid
Load main tikzpy class as follow and create and edit spatial 2D shapes and text:
1import tikzpy
2
3### Load main object
4tikZ = tikzpy.pytikz()
5
6### Add point at x=0, y=0, z=0
7p0 = tikZ.pto.pto(0,0,0)
8
9### Add point at x=1, y=1, z=1
10p2 = tikZ.pto.pto(1,1,1)
11
12### Add a line for example
13l1 = self.tikZ.shp.line(p0, p1)
14l1.zorder = 1.1 ### Viewer Z-order
and start bulding your drawing. More examples on how to use the shapes object can be found in shapes examples.
Shapes functions. Class -> tikzpy.shp
- class cls_shapes._shapes(parent)[source]
Shapes class:
- Platform
Unix, Windows
- Synopsis
Allows to add 2D shapes using points
- Properties
- Available shapes
Line between two points. See shp.line
Path of multiple points. See shp.path
Circle given by center and radius. See shp.circle
Arc given by starting point, radius and angles. See shp.arc
Arc given by center, radius and angles. See shp.arc_by_center
Text label. See shp.text
Add bitmap. See shp.bitmap
Shapes allow to set labels (see labels section). See labels
Chracteristics of a shape (shp) object
Each shape object has different properties depending on the nature of the shape
- line(p1, p2, layer=0, thick='', type='', color='', fill='')[source]
- Synopsis:
Add a line shape or segment between two points
- Args:
p1: segment start point (given by id, alias or point object)
p2: segment end point (given by id, alias or point object)
- Optional parameters:
layer = 0: layer member where the shape belongs
thick = “”: line thickness (see thick examples)
type = “”: type of line (see type examples)
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
- Returns:
A line shape object
Chracteristics of a shape line object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
arrow – set/get arrow parameters (see arrow examples)
arrow_build(start,end,scale) – arrow parameter (see arrow examples)
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
fill – set/get fill texture of the line (see fill examples)
addpto – set or add a new points to the line. Get a list of points that form the line. See addpto examples
Note
See example of lines in shapes examples
- path(ptos, layer=0, thick='', type='', color='', fill='')[source]
- Synopsis:
Add a path of multiple points connected by a line
- Args:
ptos: multiple points. Can be set as a point, a list o points, an alias or a list of alias. See addpto examples
- Optional parameters:
layer = 0: layer member where the shape belongs
thick = “”: path thickness (see thick examples)
type = “”: type of path (see type examples)
color = “”: color of the path (see colors examples)
fill = “”: fill texture of the path (see fill examples)
- Returns:
A path shape object
Chracteristics of a shape line object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
arrow – set/get arrow parameters (see arrow examples)
arrow_build(start,end,scale) – arrow parameter (see arrow examples)
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
fill – set/get fill texture of the line (see fill examples)
addpto – set or add a new points to the line. Get a list of points that form the line. See addpto examples
Note
See example of paths in shapes examples
- circle(pto, radius, layer=0, thick='', type='', color='', fill='')[source]
- Synopsis:
Add a circle defined by the centre and the radius
- Args:
pto: point of the centre of the circle (given by id, alias or point object)
radius: radius of the circle
- Optional parameters:
layer = 0: layer member where the shape belongs
thick = “”: line thickness (see thick examples)
type = “”: type of line (see type examples)
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
- Returns:
A circle shape object
Chracteristics of a shape circle object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
arrow – set/get arrow parameters (see arrow examples)
arrow_build(start,end,scale) – arrow parameter (see arrow examples)
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
fill – set/get fill texture of the line (see fill examples)
Note
See example of circles in shapes examples
- arc(start_point, radius, start_angle, end_angle, layer=0, thick='', type='', color='', fill='')[source]
- Synopsis:
Add an arc defined by the starting point, radius, start angle and end angle
- Args:
start_point: starting point of the arc (given by id, alias or point object)
radius: radius of the arc
start_angle: start angle in degrees
end_angle: end angle in degrees
- Optional parameters:
layer = 0: layer member where the shape belongs
thick = “”: line thickness (see thick examples)
type = “”: type of line (see type examples)
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
- Returns:
An arc shape object
Chracteristics of a shape arc object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
arrow – set/get arrow parameters (see arrow examples)
arrow_build(start,end,scale) – arrow parameter (see arrow examples)
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
fill – set/get fill texture of the line (see fill examples)
Note
See example of arcs in shapes examples
- arc_by_center(center_point, radius, start_angle, end_angle, layer=0, thick='', type='', color='', fill='')[source]
- Synopsis:
Add an arc defined by the center point, radius, start angle and end angle
- Args:
center_point: starting point of the arc (given by id, alias or point object)
radius: radius of the arc
start_angle: start angle in degrees
end_angle: end angle in degrees
- Optional parameters:
layer = 0: layer member where the shape belongs
thick = “”: line thickness (see thick examples)
type = “”: type of line (see type examples)
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
- Returns:
An arc shape object
Chracteristics of a shape arc object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
arrow – set/get arrow parameters (see arrow examples)
arrow_build(start,end,scale) – arrow parameter (see arrow examples)
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
fill – set/get fill texture of the line (see fill examples)
Note
See example of arcs in shapes examples
- text(pto, text, layer=0, color='', fill='', rotate_text=0, position='', align='')[source]
- Synopsis:
Add a text. Referenced by a point position.
- Args:
pto: point reference for the text node
text: text to be added
- Optional parameters:
layer = 0: layer member where the shape belongs
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
rotate_text = 0.: float number in degrees of text rotation
position = “”: “above” , “below” , “left” , “right”, “above left” , “below left” , “above right” , “below right”
align = “”: “left” , “center” , “right”
- Returns:
An text shape object
Chracteristics of a shape text object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
color – set/get color of the text (see colors examples)
fill – set/get fill texture of the text (see fill examples)
text – set/get text label
rotate_text – float number in degrees of text rotation
position – options: “above” , “below” , “left” , “right”, “above left” , “below left” , “above right” , “below right”
align – options: “left” , “center” , “right”
Note
See text examples
- bitmap(pto, bitmap_path, width=None, height=None, layer=0, color='', fill='', rotate_text=0, position='', align='')[source]
- Synopsis:
Add a bitmap or image file. Referenced by a point position using a node wrapper.
- Args:
pto: point reference for the bitmap node
bitmap_path: path to bitmap or image file (jpg, png, pdf)
- Optional parameters:
width = None: image width, if just width or height is supply the aspect ratio is mantain
height = None: image height, if just width or height is supply the aspect ratio is mantain
layer = 0: layer member where the shape belongs
color = “”: color of the line (see colors examples)
fill = “”: fill texture of the line (see fill examples)
rotate_text = 0.: float number in degrees of image rotation
position = “”: “above” , “below” , “left” , “right”, “above left” , “below left” , “above right” , “below right”
align = “”: “left” , “center” , “right”
- Returns:
An bitmap shape object
Chracteristics of a shape bitmap object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional bitmap field
color – set/get color of the bitmap (see colors examples)
fill – set/get fill texture of the bitmap (see fill examples)
text – set/get bitmap path (windows backslash is replace by slash)
rotate_text – float number in degrees of bitmap rotation
position – options: “above” , “below” , “left” , “right”, “above left” , “below left” , “above right” , “below right”
align – options: “left” , “center” , “right”
Note
See bitmap examples
- grid(corner1_pto, corner2_pto, xstep=1, ystep=1, layer=0, thick='help lines', type='', color='')[source]
- Synopsis:
Add a renctangular grid defined by the two opposite corner points
- Args:
corner1_pto: point of corner 1
corner2_pto: point of corner 2
- Optional parameters:
xstep = 1: grid step in x direction
ystep = 1: grid step in y direction
layer = 0: layer member where the shape belongs
thick = “help lines”: line thickness (see thick examples)
type = “”: type of line (see type examples)
color = “”: color of the line (see colors examples)
- Returns:
A grid shape object
Chracteristics of a shape line object
- Variables
id – get unique id of the shape object
action – get type of shape object
zorder – set/get z position respect the drawing plane and viewer
labels – get labels list that the shape is associated to
addlabel – set/get add a label or list of labels to the shape
dellabel – set/get delete a shape label
comment – multifunctional text field
thick – set/get line thickness (see thick examples)
type – set/get type of line (see type examples)
color – set/get color of the line (see colors examples)
Note
The grid cannot be rotated
See grid examples
- copy(shps)[source]
- Synopsis:
For a list of shapes (give by id or object), it return a list of ids copied shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
- Optional parameters:
None
- Returns:
List of unique ids of the copied shapes
Note
See example copy shapes.
- translate(shps, x=0.0, y=0.0, z=0.0)[source]
- Synopsis:
Translate a shapes of list in a 3D space
- Args:
shps: list of shapes or single shape. Given by id or shape object.
- Optional parameters:
x = 0: increment in x coordinate to tranlate
y = 0: increment in y coordinate to tranlate
z = 0: increment in z coordinate to tranlate
- Returns:
None
Note
See example translate shapes.
- translate_to(shps, pto_ref, pto_ref_final)[source]
- Synopsis:
Given a reference point and a final position for such point. Translate a shape or list of shapes in a 3D space in a similar manner.
- Args:
shps: list of shapes or single shape. Given by id or shape object.
- Optional parameters:
pto_ref: reference point
pto_ref_final: final refence point position
- Returns:
None
Note
See example translate shapes.
- rotate(shps, pto_rotation, Ax=0.0, Ay=0.0, Az=0.0)[source]
- Synopsis:
Rotate a shape of list of shapes in a 3D space respect an origin point
- Args:
shps: list of shapes or single shape. Given by id or shape object.
pto_rotation: center point of rotation
- Optional parameters:
Ax = 0.: yaw angle in degrees to turn respect axis X
Ay = 0.: pitch angle in degrees to turn respect axis Y
Az = 0.: roll angle in degrees to turn respect axis Z
- Returns:
None
Note
See example rotation shapes.
- zorder_to_shapes(shps, value)[source]
- Synopsis:
Modify zorder value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
value: zorder value
- Returns:
None
Note
zorder: z position respect the drawing plane and viewer
- thick_to_shapes(shps, value)[source]
- Synopsis:
Modify thick value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
value: thick value
- Returns:
None
Note
thick: shape thickness (see thick examples)
- type_to_shapes(shps, value)[source]
- Synopsis:
Modify type value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
value: type value
- Returns:
None
Note
type: type of shape (see type examples)
- color_to_shapes(shps, value)[source]
- Synopsis:
Modify color value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
value: color value
- Returns:
None
Note
color: color of the shape (see colors examples)
- fill_to_shapes(shps, value)[source]
- Synopsis:
Modify fill value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
value: fill value
- Returns:
None
Note
fill: fill texture of the shape (see fill examples)
- arrow_to_shapes(shps, start='latex', end='latex', scale=1.0)[source]
- Synopsis:
Modify arrow tips value for a shape or list of shapes
- Args:
shps: list of shapes or single shape. Given by id or shape object.
- Optional parameters:
start=”latex”: arrow tip type, at starting side
end=”latex”: arrow tip type, at end side
scale=1.: arrow scale
- Returns:
None
Note
arrow: arrow tips types of the shape (see arrow examples)
- pattern_build(type_pattern, color='')[source]
- Synopsis:
Builds a type of pattern fill object that can be set to the fill property
- Args:
type_pattern: type of pattern
- Optional parameters:
color=””: color of pattern (see colors examples)
- Returns:
A pattern object that can be set to the fill property
Note
Possible types: horizontal lines, vertical lines, north east lines, north west lines, grid, crosshatch, dots, crosshatch dots, fivepointed stars, sixpointed stars, bricks, checkerboard
See fill examples