IPT - A Virtual Approach IPT A Virtual Approach by Peter Whitehouse
Quick Links:
 
 
Information and Intelligent Systems Social and Ethical Implications Human Computer Interaction Software and Systems Engineering eXercise Files Course Outline and Assessment A-Z of Geeky Acronyms Terrace Work Program 2004 Sillybus FAQ = Frequently Asked Questions Help
 
 

Algorithms and Programming - Graphics

Command | Property | Event Glossary | Graphics | Contribute


Being a windows program-building tool, Lazarus ships with many graphical builtins that can make on-screen action hoopy. The GRAPHICS mode is a little screwy - ie. the ORIGIN[0,0] is the TOP LEFT corner of the screen - the X-AXIS behaves as you expect, increasing in value the further right you move. The Y-AXIS is OPPOSITE to normal cartesian coordinates - at the TOP of the form, Y=0, Y INCREASES the further down the form you go. This complicates certain graphical actions requiring you to transpose the Y axis. Sadly this feature is NOT uniformly implemented on both Windows and MAC - Mac users can include these commands but they do not run in OSX, annoyingly.

Contained herein are SOME graphical commands, designed to give you a flavour of some of the things possible.

The 30 Second Guide to useful Graphics commands:

Command Notes
canvas.moveto(x,y) moves the graphics cursor to the moninated point (x,y) without leaving a trail from the previous location
canvas.lineto(x,y) draws a straight line (based on pen.color and pen.width) from the previous position of the graphics cursor to the nominated point
canvas.rectangle(x1,y1,x2,y2) draws a rectangle whose top right corner is the point (x1,y1) and bottom right corner is (x2,y2)
canvas.roundrect(x1, y1, x2, y2, x3, y3) draws a rounded cornered rectangle whose top right corner is the point (x1,y1) and bottom right corner is (x2,y2) and whose corners are an arc that fits in a box x3 * y3 pixels big
canvas.arc(x1, y1, x2, y2, x3, y3, x4, y4); draws an ellipse section that is bounded by a box whose top right corner is the point (x1,y1) and bottom right corner is (x2,y2) with the starting point of the arc being (x3,y3) and finishing point being (x4,y4)
canvas.ellipse(x1, y1, x2, y2) draws an ellipse that is bounded by a box whose top right corner is the point (x1,y1) and bottom right corner is (x2,y2
canvas.textout(x,y,'message') positions some graphically generated text at coordinates (x,y)
   
   

The 30 Second Guide to useful Graphical properties:

Useful Property data type Notes
canvas
or
thing.canvas
TCanvas Many objects on a form(including the form itself) have a canvas property - that is the graphical scratchpad that we use to make marks on it programatically. A form's canvas allows you to draw transient images [ones that are obliterated by other screen schrapnel], using a TImage's canvas you to make persistent images that are damaged when you, the programmer, decide to damage them.
canvas.brush.color TColor the FILL color when drawing closed shapes
canvas.pen.color TColor the OUTLINE color when drawing lines, shapes and other things
canvas.pen.width +ve num the thickness, in px of the line drawn
canvas.font.color TColor the graphical text color
canvas.font.size picas the point size of the graphically generated font text
canvas.font.style set of font styles

you can add font styles of the current font using set union:

canvas.font.style := [fsBold];
canvas.font.style := canvas.font.style + [fsItalic];

"adds" italics to an already bolded font.

to remove a style, use the difference operator [-] instead of the union operator [+]. Font styles available are: fsBold, fsItalic, fsUnderline, fsStrikeOut

canvas.font.name font name changes the font used

The 30 Second Guide to useful Graphical events:

Useful Event Notes
   

Contribute a Command

Surname:
Given names:
E-mail address:
Enter the Command example here:



wonko@wonko.info
©Copyright t 1992..2018+. Edition 26.150117
wonkosite
Creative Commons License
This work is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 2.1 Australia License
.