Besides text and formulas, Calcpad allows you to add scaled parametric vector images to your reports. Their dimensions can depend on your input data and the results from the calculations. It means that if you change some values, the drawings will resize accordingly. An example drawing of a prestressed TT panel section, created with Calcpad is given below:

This is obtained by inserting an SVG image in Calcpad and assigning expressions/variables to coordinates instead of fixed values. SVG (Scalable Vector Graphics) is a markup language, based on XML, for defining vector graphics for the web. You can learn more for SVG from this tutorial in W3Schools:
https://www.w3schools.com/graphics/svg_intro.asp
You can keep your SVG image in a separate file or embed it into an Html document. Since Calcpad supports Html inside comments, it automatically supports SVG as well. For convenience, some of the most common SVG elements are included into the “Insert” menu:

You must start with inserting a drawing. When you click the menu, Calcpad will add the following code snippet inside your worksheet:
#val
#hide
w = 400
h = 400
#show
'<svg viewbox="'0' '0' 'w' 'h'" xmlns="http://www.w3.org/2000/svg" version="1.1" style="font-size:16px; width:'w'px; height:'h'px">
'<rect x="'0'" y="'0'" width="'w'" height="'h'" style="stroke:black; stroke-width:1; fill:WhiteSmoke; fill-opacity:0.2; stroke-opacity:0.1" />
'<text x="'w/2'" y="'h/2'" text-anchor="middle" fill="red" style="font-size:32px;">Your drawing goes here!</text>
'</svg>
#equ
The output will look as follows:

All graphical elements must go inside the drawing (between the opening <svg ...> and the closing </svg> tags). If you place them outside, they will have no effect. The default drawing contains two sample objects: rectangle and text. You can delete them if not needed.
Let’s have a closer look at the code above. You can see that there is a #val switch before the drawing. With this, you tell Calcpad to show only the calculated numbers and not the whole equations. Otherwise, the SVG drawing will be broken. After the drawing, the default behavior is restored by adding an #equ switch. There is also a hidden section between the #hide and #show switches. You can use it to calculate the coordinates of the graphical objects.
In spite of the available code snippets, writing SVG in Calcpad in this way can be a tedious job. That is why, we created a simple macro language by wrapping the most common shapes with macro commands. Besides simple shapes like line$, rect$, circle$ and text (texth$ and textv$), it also includes more complex objects like dimension lines (dimh$ and dimv$). The definition of the macro language is provided in a separate module svg_drawing.cpd. It is available on GitHub for free download:
https://github.com/Proektsoftbg/Calcpad/blob/main/Examples/Demos/svg_drawing.cpd
To use the macro functions in your worksheet, you have to reference the module in the beginning of your code by writing:
#include svg_drawing.cpd
The module must be placed in the same folder as your worksheet or you must add the full path to the module. Then, instead of writing SVG tags, you can use the respective macro functions to draw graphical objects, e.g.:
#def rect_style$ = style="stroke:black; stroke-width:1; fill:WhiteSmoke; fill-opacity:0.2; stroke-opacity:0.1"
rect$(0;0;w;h;rect_style$)
texth$(w/2;h/2; Your drawing goes here!)
The source code for drawing the TT Panel example above is also available:
https://github.com/Proektsoftbg/Calcpad/blob/main/Examples/Demos/TT%20Panel.cpd
You can download it and try it with Calcpad. Adding such parametric drawings to your worksheets will provide easy, fast and reliable control of the input data. You can use the above example and the SVG macro language wrapper for free to create your own drawings. You can even extend the macro language if you need more graphical commands.
