Customized library drawings

For each library component you can create a customized drawing. The drawing is created using vector drawing commands. An overview of these commands is given in this section. Some examples of these customized drawings are given below.

Click to open full screen

To correctly display such a drawing the vector file should have the same file name as the library block, but with the *.vec extension. Example:

c:\MyLibrary\MyControlBlock\MyBlock.lib
c:\MyLibrary\MyControlBlock\MyBlock.vec
such a drawing, open the library properties dialog box by right mouse button clicking the library block.

To create such a drawing, open the library properties dialog box by right mouse button clicking the library block.

Click to open full screen

Inside the properties dialog box you have to indicate that only the customized drawing should be displayed. Therefore check only the [VEC] box.

Click to open full screen

To create a new drawing, click the [Edit VEC] button. A new *.vec block is created and you default text editor is opened with the *.vec file.

Click to open full screen

Once the file is created, you can start typing commands in the vec file.

Click to open full screen

In the example shown below a double square is drawn with white fill color and black single pixel pen width. The text is centered using two textcenter commands. Comments can be inserted either using a * or a // keyword.

Click to open full screen Click to open full screen

The example shown above a single square is drawn with white fill color and black single pixel pen width. The red line is two pixels in width. The labels are centered using the label command.

Click to open full screen Click to open full screen

The drawing area

In Caspoc,a coordinate system is used that has its origin (0, 0) on the top-left corner of the drawing area.

Anything that is positioned on the screen is based on this origin. This coordinate system can get the location of an object using a horizontal and a vertical measurement. The horizontal measures are based on an x axis that moves from the origin to the right direction. The vertical measures use a y axis that moves from the origin to the bottom direction:

This means that, if you start drawing something such as a line, it would start on the origin and continue where you want it to stop.


OFFSET

Offsets the cursor and regards this position as 0,0. Using the following syntax:

Offset x y

Pen Color and width

You can define the pen color as well as the thickness of the line. The pen color is define by the command

SolidPen R G B PenWidth
where R G B are the colors Red Green and Blue defined from 0 to 255 PenWidth is the width of the pen. You can specify the color by specifying a value for R, G and B from 0 to 255. 0 means no color, 255, means full intensity of the color. By mixing the RGB colors Red Green and Blue, 256*256*256 different colors can be generated.
The Penwidth varies from 0 to a larger value and defines the penwidth in pixels. By defining 0 for the penwidth, the pen is 1 pixel in width regardless of the size of he figure and the zoom factor. A penwidht of 3 is three pixels in width and will always display as thre times thicker than a penwidth of 1.
Examples of SolidPen are: Black line with minimum pen width:
Solidpen 0 0 0 0 
Red line with minimum pen width:
Solidpen 255 0 0 0 
Yellow Pen which is 3 pixels in width
SOLIDPEN 255 255 0 3
Black Pen which is 6 pixels in width
solidpen 0 0 0 0


Background and fill Color

You can define the background and fill by the command

Solidbrush R G B
where R G B are the colors Red Green and Blue defined from 0 to 255 You can specify the color by specifying a value for R, G and B from 0 to 255. 0 means no color, 255, means full intensity of the color. By mixing the RGB colors Red Green and Blue, 256*256*256 different colors can be generated.
All Rectangle, RoundRect, Ellipse and Pie commands are filled using the Solidbrush color.
Examples of Solidbrush are:
White:
Solidbrush 255 255 255 
Light gray:
Solidbrush 192 192 192 
Dark gray:
Solidbrush 128 128 128  
Red:
Solidbrush 255 0 0 
Yellow:
SOLIDBRUSH 255 255 0 
Transparant:
hollowbrush


Line-Based Shapes

A line is a junction of two points. This means that a line has a beginning and an end:

The beginning and the end are two distinct points. In real life, before drawing, you should define where you would start. To help with this, the MoveTocommand can be used. Its syntax is:

MoveTo X Y

The X argument represents the horizontal distance of the line beginning from the (0, 0) origin.

The Y value is the vertical distance from the (0, 0) origin.

To end the line, you use the LineTo command. Its syntax is:

LineTo  X  Y

The X argument represents the horizontal end of the line from the (0, 0) origin.

The Y value is the vertical end of the line from the (0, 0) origin.

Here is an example that draws a line starting at a point defined as (20, 15) coordinates and ending at (255, 82):



	MoveTo  20 15
	LineTo 255 82

We have mentioned that the MoveTo command is used to set the starting position of a line. When using LineTo, the line would start from the MoveTo point to the LineTo end. As long as you do not call MoveTo, any subsequent call to LineTo() would draw a line from the previous LineTo to the new LineTo point. You can use this property of the LineTo method to draw various lines. Here is an example:


	MoveTo  60  20
	LineTo  60 122
	LineTo 264 122
	LineTo  60 20

Or you can use the statement Polyline to make a line.

	Polyline 60 20 60 122 264 122 60 20
When you want to draw a line from your last point to a next point u can use the statement PolylineTo.
	Arc 0 0 100 100 115 105 32 60
	PolylineTo 100 50

Rectangles and Squares

A rectangle is a geometric figure made of four sides that compose four right angles. Like the line, to draw a rectangle, you must define where it starts and where it ends. This can be illustrated as follows:

The drawing of a rectangle typically starts from a point defined as (X1, Y1) and ends at another point (X2, Y2). To draw a rectangle, you can use the Rectangle command. Its syntax is:

Rectangle X1 Y1 X2  Y2

As seen on the figure and the formula, a rectangle spans from coordinates (x1, y1) to (x2, y2). Here is an example:



	Rectangle 20  20  226 144

When drawing a rectangle, if the value of x2 is less than that of x1, then the x2 coordinate would mark the left beginning of the figure. This scenario would also apply if the y2 coordinate were lower than y1.

A square is a rectangle whose sides are all equal. Therefore, to draw a square, when specifying the arguments of the Rectangle() method, make sure that |x1 - x2| = |y1 - y2|.

Polygon

This statement draws a polygon and fills it with the current brush. Using the following syntax:

Polygon x1 y1 x2 y2 x3 y3 .......  x1 y1

Parallelogram

You can make a 3D block. First you specify a rectangle using the first four parameters. Next comes the depth, followed by the color specified by its R G B parameters. Using the following syntax:

Parallelogram x1 y1 x2 y2 z r g b

Ellipses and Circles

An ellipse is a closed continuous line whose points are positioned so that two points exactly opposite each other have the exact same distant from a point called the center. It can be illustrated as follows:

Because an ellipse can fit in a rectangle, in GDI programming, an ellipse is defined with regards to a rectangle it would fit in. Therefore, to draw an ellipse, you specify its rectangular corners. The syntax used to do this is:

Ellipse X1 Y1 X2 Y2 

The arguments of this method play the same roll as those of the Rectangle() method:

Here is an example:



	Ellipse 20 20 226 144

A circle is an ellipse whose all points have the same distance with regards to a central point.


Round Rectangles and Round Squares

A rectangle qualifies as round if its corners do not form straight angles but rounded corners. It can be illustrated as follows:

To draw such a rectangle, you can use the RoundRect command. Its syntax is:

RoundRect  X1 Y1 X2 Y2 X3 Y3

When this member function executes, the rectangle is drawn from the (x1, y1) to the (x2, y2) points. The corners are rounded by an ellipse whose width would be x3 and the ellipse's height would be x3. 

Here is an example:



	RoundRect 20 20 275 188 42 38

A round square is a square whose corners are rounded.


Circle segments

A pie is a fraction of an ellipse delimited by two lines that span from the center of the ellipse to one side each. It can be illustrated as follows:

To draw a pie, you can use the Pie method whose syntax is:

Pie X1 Y1 X2 Y2 X3 Y3 X4 Y4

The (X1, Y1) point determines the upper-left corner of the rectangle in which the ellipse that represents the pie fits. The (X2, Y2) point is the bottom-right corner of the rectangle.

The (X3, Y3) point specifies the starting corner of the pie in a default counterclockwise direction.

The (X4, Y4) point species the end point of the pie.

To complete the pie, a line is drawn from (X3, Y3) to the center and from the center to the (X4, Y4) points.

Here is an example:



	Pie 40 20 226 144 155 32 202 115


Arcs

An arc is a portion or segment of an ellipse, meaning an arc is a non-complete ellipse. Because an arc must confirm to the shape of an ellipse, it is defined as it fits in a rectangle and can be illustrated as follows:

To draw an arc, you can use the Arc method whose syntax is:

Arc x1 y1 x2 y2 x3 y3 x4 y4

Besides the left (x1, y1) and the right (x2, y2) borders of the rectangle in which the arc would fit, an arc must specify where it starts and where it ends. These additional points are set as the (x3, y3) and (x4, y4) points of the figure. Based on this, the above arc can be illustrated as follows:

Here is an example:

Arc(20, 20, 226, 144, 202, 115, 105, 32)

The default value of the direction is AD_COUNTERCLOCKWISE.

The ArcTo function is the same as the Arc function, only a line is drawn from the current position to the beginning of the arc.


Polybezier

Draws a bezier line from (x1,y1) to (x4,y4), controlled by two control points (x2,y2) and (x3,y3)

Polybezier x1 y1 x2 y2  x3 y3  x4 y4

Angular Arcs

You can (also) draw an arc using the AngleArc() method. Its syntax is:

AngleArc x y Radius StartAngle SweepAngle

This member function draws a line and an arc connected. The arc is based on a circle and not an ellipse. This implies that the arc fits inside a square and not a rectangle. The circle that would be the base of the arc is defined by its center located at C(x, y) with a radius of Radius. The arc starts at an angle of StartAngle. The angle is based on the x axis and must be positive. That is, it must range from 0° to 360°. If you want to specify an angle that is below the x axis, such as -15°, use 360º-15°=345°. The last argument, SweepAngle, is the angular area covered by the arc. The AngleArc() method does control where it starts drawing. Here is an example:

AngleArc 100 100  50 0 90

centre is 100, 100, the radius equals 50 and it startss at 0 degrees and sweeps 90 degrees counter clock wise.


Angular Arrows

Angular arrows are specified the same way as the angular arcs. Its syntax is:

AngleArcArrow x y Radius StartAngle SweepAngle

Chords

The arcs we have drawn so far are considered open figures because they are made of a line that has a beginning and an end (unlike a circle or a rectangle that do not). A chord is an arc whose two ends are connected by a straight line. In other words, a chord is an ellipse that is divided by a straight line from one side to another:

To draw a chord, you can use the Chord() method. It is defined as follows:

Chord x1 y1 x2 y2 x3 y3 x4 y4

The x1, y1, x2, and y2 are the coordinates of the rectangle in which the chord of the circle would fit. These x3 and y3 coordinates specify where the arc that holds the chord starts. The x4 and y4 that can also be defined as ptEnd specify the end of the arc. To complete the chord, a line is drawn from (x3, y3) to (x4, y4). Here is an example:

Chord(20, 20, 226, 144, 202, 115, 105, 32)

Arrow

An arrow is specified using a starting and ending point Its syntax is:

Arrow xbegin ybegin xend yend

The ArcArrow is defined by its center, radius and angular position Its syntax is:

ArcArrow x y radius angle

An arrowdobble is specified using a starting and ending point Its syntax is:

ArrowDouble xbegin ybegin xend yend

Object

All animation objects from the block diagram block OBJECT can be drawn using the following syntax:

Object p1 i1 i2 i3 i4 i5 i6 i7 i8 i9 i10 i11 i12 i13 i14 i15 i16 i17 i18 i19 i20

Text

To write text, you can call the TextOut command. Its syntax is:

TextOut X Y Text

The TextOut command is used to create an display a piece of text on the screen. The X and Y arguments are the point coordinates of the top-left corner of the string being displayed. The Text argument is the text that needs to be displayed. Here is an example:


	TextOut 10 10 Vector Control Block


Centered Text

To write centered text, you can call the TextCenter command. Its syntax is:

TextCenter X Y Text

The TextCenter command is used to create an display a piece of text on the screen. The X and Y arguments are the center point coordinates of the string being displayed. The Text argument is the text that needs to be displayed. Here is an example:


	TextCENTER 20 30 PI


Label

To write a label with Greek and mathematical characters, you can call the Label command. Its syntax is:

Label X Y Text

The Label command is used to create an display a piece of text on the screen. The X and Y arguments are the center point coordinates of the label being displayed. The Text argument is the text that needs to be displayed and may not contain any spaces. Here is an example:


	Label 20 30 Ψ_R
that draws the label ΨR

© Simulation Research, www.caspoc.com