Command |
DRAW |
|
|
Description |
Draw or update a Line, Vector, Box, Circle or Graph of size X,Y. The entities can be an outline or filled.
The colour can be enhanced using alpha blending within the draw style.
Graphs of a different colour can be superimposed on top of each other.
Faster display updates occur if draw uses a solid background colour (ie no alpha blending).
DRAW accepts VARs, signed/unsigned integers
(U8, U16, U32, S8, S16, S32), floats (FLT) and pointers (PTR)
DRAW( PTR, VAR|INT|FLT|PTR, VAR|INT|FLT|PTR, Style );
Note PTR refers to the entity being pointed to by PTR and not
the PTR itself. Use LOAD( PTR > "Name" ); to set a pointer. |
|
|
Syntax/Parameters |
DRAW(Name,X,Y,Style)
DRAW(Name,X,Y,Style,PosX,PosY);
DRAW(name,length,angle,stVector); |
|
|
Style |
It is possible to specify transparency values with colours if the colour is entered as a 32-bit hex number the top 8 bits specify the alpha blending level.
col = \\aarrggbb; back = \\aarrggbb; where aa = alpha level.
For example, col = \\80FFFF00; gives 50% transparent yellow.
Support for opacity - v49.00.
STYLE(gstyle,DRAW) {
type=trace; //The shape to draw. type = B/Box; C/Circle; L/Line;, T/Trace; P/Pixel; y/yBar; x/xBar;
v/Vector;
maxX=100; // Not required except for dynamic rotation where the maximum width is declared
maxY=100; // Not required except for dynamic rotation where the maximum height is declared
col=green; //Specify the line border colour of the shape. Use hex, colour name + alpha
back=black; //Specify the fill colour of the shape. Use hex, colour name + alpha
opacity = n; // n = 0..100 where 0=transparent..100=opaque (default=100)
width=3; //Specify the line border width of the shape default = 1
rotate=0; // Specify the rotation of the shape with respect to the screen. 0,90,180,270
curRel=cc; //specify placement relative to cursor. CC Centre Centre , TC Top Centre etc.
xOrigin=50; //specify graph x origin wit respect to declared graph
yOrigin=50; //specify graph y origin wit respect to declared graph
xScale=200; //scale the value automatically to fit the graph
yScale=200; //scale the value automatically to fit the graph
xScroll=1; //define scroll direction and increment 1=left to right one pixel, 0=no
scroll
} |
|
|
Options |
Graphs - v47.00
A number of graph styles now exist as draw types:
type=p; type=pixel; // Pixel Scatter - places a point at x,y
type=t; type=trace; // Trace/Line - joins the dots between current point and previous point.
type=y; type=yBar; // Bar Y - draws vertical line from 0 to y and clears from y+1 to ymax
type=x; type=xBar; // Bar X - draws horizontal line from 0 to x and clears from x+1 to xmax
The origin on the graph can be changed
xOrigin=val; // (default=0)
yOrigin=val; // (default=0)
The scaling of pixels can be set:
xScale=val; // (default=100.0) [val can be float and is a percentage]
yScale=val; // (default=100.0) [val can be float and is a percentage]
Note to draw graph with 0,0 at top and n,n at bottom, use yScale=-100;
The graph can be made to scroll (currently right-to-left only supported)
xScroll=val; // where val=0 (default - no scroll); val=n (scroll left n pixels before each plot
Please refer to the ADC analogue input section for a graph application example.
Graph Displaying Problems v49.37
* Added bounds check to prevent drawing outside of graph
area.
* Fixed line wrapping within graph area.
DRAWing of Graphs - Trace Line Should
Not be Wrapping - v49.42
* Improved graph trace drawing.
* Solved problem with trace line wrapping when rendering a graph.
* Extended graphics area to encompass line width and modified page rendering to
deal with windowed pixels.
DRAWing of Ellipses and more DRAW parameter options
- v49.37
* Added ellipse drawing, specify type=ellipse or e in the
STYLE
* Added more DRAW command options
DRAW( name, x ); // Circle or Square modification: width=x; height=x;
DRAW( name, x, style ); // Circle or Square definition: width=x; height=x;
DRAW( name, x, y ); // All Shapes modification: width=x; height=y;
DRAW( name, x, y, style ); // All Shapes definition: width=x; height=y;
DRAW( name, x, y, s, a ); // Ellipse Arc modification: width=x; height=y;
startAngle=s; arcAngle=a;
DRAW( name, x, y, s, a, style ); // Ellipse Arc definition: width=x;
height=y; startAngle=s; arcAngle=a;
* Notes:
- 0 degrees is at 12'o'clock and positive angles are clockwise.
- The style for an arc must be defined to encompass the size of the shape if
drawn from 0 to 360 degrees.
- Further work required on the fill algorithm for ellipses.
* Added option for start angle and
arc angle to be in radians or degrees depending on SYSTEM.angles setting.
v49.48
Graphs to support alpha blending
and opacity - v49.42
* New features of alpha blending and opacity with graphs
* Support for graphs when the display is rotated 90, 180 and 270 degrees
Drawing Lines - v49.48
* New algorithm for line drawing
implemented.
* Lines are created with anti-aliased edges.
* Vertical and horizontal lines are a special case and are rapidly created (as
no anti-aliasing required).
* Line ends are now created perpendicular to the line rather than vertical or
horizontal.
Drawing Vectors (Lines with length and angle) - v49.48
* Added new line type - vector - which is defined with a length and an angle.
STYLE( stVector, DRAW ) { type = v or vector; ... }
DRAW( name, length, angle, stVector );
where
'length' is line length,
'angle' is angle clockwise from 12'o'clock position. 'angle' is in degrees or
radians depending on SYSTEM.angles setting.
Example tu800a.mnu
STYLE(stPage,PAGE){}
STYLE(stLine1,DRAW){type=vector;col=white;width=1;curRel=cc;}
STYLE(stLine2,DRAW){type=vector;col=white;width=2;curRel=cc;}
STYLE(stLine3,DRAW){type=vector;col=white;width=3;curRel=cc;}
STYLE(stLine4,DRAW){type=v;col=white;width=9;curRel=cc;}
STYLE(stLine5,DRAW){type=v;col=white;width=20;curRel=cc;}
STYLE(stLine6,DRAW){type=v;col=white;width=21;curRel=cc;}
STYLE(stCirc,DRAW){type=circle;width=1;col=red;curRel=cc;}
VAR(varAngle,0.0,FLT4);
PAGE(pgMain,stPage)
{
POSN(149,119); DRAW(drLine1,200,45,stLine1); DRAW(drCir1,150,stCirc);
DRAW(drPt1,7,stCirc);
POSN(399,119); DRAW(drLine2,200,45,stLine2); DRAW(drCir2,150,stCirc);
DRAW(drPt2,7,stCirc);
POSN(649,119); DRAW(drLine3,200,45,stLine3); DRAW(drCir3,150,stCirc);
DRAW(drPt3,7,stCirc);
POSN(149,359); DRAW(drLine4,200,45,stLine4); DRAW(drCir4,150,stCirc);
DRAW(drPt4,7,stCirc);
POSN(399,359); DRAW(drLine5,200,45,stLine5); DRAW(drCir5,150,stCirc);
DRAW(drPt5,7,stCirc);
POSN(649,359); DRAW(drLine6,200,45,stLine6); DRAW(drCir6,150,stCirc);
DRAW(drPt6,7,stCirc);
LOOP(lpMain,FOREVER)
{
DRAW(drLine1,150,varAngle);
DRAW(drLine2,150,varAngle);
DRAW(drLine3,150,varAngle);
DRAW(drLine4,150,varAngle);
DRAW(drLine5,150,varAngle);
DRAW(drLine6,150,varAngle);;
CALC(varAngle,varAngle,0.5,"+");
}
}
SHOW(pgMain);
New Line Draw CurRel options plus offset - v49.48
* Additional parameter can now be passed to DRAW() command for Line and
Vector drawing which allow for the line to be offset relative to the cursor:
DRAW( name, length, angle, offset, stVect );
DRAW( name, length, angle, offset );
DRAW( name, length, angle, offset, stVect, xPos, yPos );
DRAW( name, width, height, offset, stLine );
DRAW( name, width, height, offset );
DRAW( name, width, height, offset, stLine, xPos, yPos );
* The offset parameter is ideal for the pointer on gauges and clocks where the
point of rotation is a certain distance along the line
* New curRel options allow for better line placement.
SA, SB, SC // Start of line. SA = Edge A; SB = Edge B; SC = Centre
EA, EB, EC // End of line. EA = Edge A; EB = Edge B; EC = Centre
MA, MB, MC // Mid-point of line. MA = Edge A; MB = Edge B; MC = Centre
OA, OB, OC // Offset along line. OA = Edge A; OB = Edge Bl OC = Centre
* Example: Vector length = 100, angle = 125 deg, width = 5 (not to scale)

Draw() with structures - v49.48
* DRAW() command now accepts structure parameters for
width/height/angles/offset.
Anti-Aliased Line Drawing - v49.48
* New algorithm for line drawing implemented.
* Lines are created with anti-aliased edges.
* Vertical and horizontal lines are a special case and are rapidly created (as
no anti-aliasing required).
* Line ends are now created perpendicular to the line rather than vertical or
horizontal. |
|
|
Example |
Circle Example
DRAW(MyCircle, 32, 32, DrawCircle);
DRAW(MyCircle, 64, 64); //modified circle is double diameter.
DRAW(MyCircle,VarX,VarY); //modified
circle using variables. Should not exceed MaxX,maxY.
Box Example
DRAW(MyBox, 32, 32, DrawBox);
DRAW(MyBox, 64, 64); //modified circle is double diameter.
DRAW(MyBox,VarX,VarY); //modified
circle using variables. Should not exceed MaxX,maxY.
Line Example
DRAW(MyLine,10,10,lineStyle); //draws line 45 degrees top left to bottom right.
DRAW(MyLine2,10,-10,lineStyle); //draws line 45 degrees bottom left to top right.
Vector Example
DRAW(MyVec,150,30,VecStyle); //draws vector 150 length at 30 degree.
DRAW(MyVec2,100,320,VecStyle); //draws vector 100 length at 320 degree.
Graph Example
DRAW(MyGraph,100,100,GraphStyle); //draws a graph window of 100x100 pixels.
DRAW(MyGraph,20,30); //draws a pixel on the graph at 20,30 relative to the origin.
DRAW(MyGraph,varX,varY); //use variables to plot a pixel on the graph.
RESET(MyGraph); //clears the graph |
|
|
|