June 19, 2019, 01:08:29 pm


IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

How do graphic pgms work ?

Started by RitchieF, August 07, 2011, 11:46:29 am

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


Using the draw.iwb example I can draw different shapes  in different colors at differrent positions.

Now if want to change the position,color or size of a drawn shape how can this be done ? How do I find and select the shape to manipulate its properties like position or color.

Must I write parallel a table and fill it with the mouse-coords and more and compare the mouse position with this table ?

Thanks in advance for infos



August 07, 2011, 12:10:48 pm #1 Last Edit: August 07, 2011, 12:14:50 pm by LarryMc
you have to clear the screen and redraw them

do it on a window with the @noautodraw style or subclass the window and put you drawing stuff in the @IDPAINT message handler or put everything in the @IDPAINT/WM_PAINT handler.

I will get to that part in detail in Custom Control tutorial I'm working on.
If you are using 2D screens you do it by creating sprites and moving them around.

It all depends upon you ultimate goal and what else you have on the window.

Right now I would have to say your best bet is probably to use sprites and 2D screens.  There are examples.

Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library


Do you mean a program like Gimp or Inkskape is working with 2D screens and sprites ?

Every shape I draw is converted to a sprite ?



Well, since you gave some specific for what you MIGHT be trying to do I can give you a little more information.
I had never heard of the two applications you cited.
Gimp appears to be a photo editor.
I've done a little of that sort of thing using a free library called DeVIL.  That, coupled with some custom code in IWB, I drew rubber-band boxes for cropping and such.

Inkskape appears to be a vector graphics editor.  The IWB equivalent for that is the 3D library commands.

So, based upon what I think you are wanting, you would need to use the 3D library to create and manipulate shapes.
I suggest you run the 3D examples and play with them for a while.

Some of my questions would be:
1. Are you wanting to edit pictures or are you wanting to create graphics?
2. If pure graphics, are you wanting to create an application that has dynamic graphics or are you wanting to build a graphics editor?

But again, I, and others, can only help when we know what you are trying to do.

Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library


Hi Richard,

The in-built graphics alllow you to draw lines, rectangles, ellipses etc. in colour and with differing line styles.
You can draw these with a single command on a normal window. ie. for a circle ..

Code Select

CIRCLE w,250,75,50,RGB(0,255,0),RGB(0,0,255)

You also can use a Direct X window to load, move and resize images.  These can be specified with a transparency colour which makes the image (say a spaceship) appear to float on the background. These are called sprites and can have selectable transparency.

Moving up to a whole new level of black art  ::)  you can use 3D graphics - see some of the examples.
Here graphic objects appear to be in 3D and can be skinned - so you might have a sphere, mapped with an image of the Earth, and apparently rotating.

The programming of such objects gets a lot more complicated - something I've yet to play with ..  ;D

All of these methods are pixel based, raster graphics.  Like images you'd manipulate in Photoshop.

The programs you mention are Vector Graphics tools, where the resulting image is generated from mathematical representation of shapes.  Check this out ..


I wouldn't have a clue how these types of programs work.  It may be that something approximating vector graphics could be programmed in Basic - it would depend on the algorithms used. 

Looking at the documentation of Inkskape for example, it would be a major undertaking to replicate those facilities using Windows API library routines.

So as Larry says - it depends what you are planning to do ..  :P

best wishes, :)

Tomorrow may be too late ..


Well Larry, Graham,

I'm by profession working with a cnc-milling machine. And I want to write my own engraving software . There is some very good software out there but for very much $$$.

As I see I asked a bit wrong. Imagine you write text within a RichText control. Now you have to examine where is every letter in relation to a fix zero position which I can define where I want.

A TrueType / Otf - letter consists always of a outline whose coordinates are described within the font. I'd like to read these coordinates in relation to the zero position and convert them into a cnc-program which I can run with my machine at work.

So my first idea was : how to find where the letters or later any graphical element is within my canvas/milling area
The second stage would be to try writing code for engraving with a v-shaped tool where the depth to mill is directly depending on the width of the letter or any other element.
To have an idea of what I mean please have a look here :


Sorry for perhaps asking the wrong way



It just so happens that I have a complete set of plans to build my own CNC wood router.  I also have all the electronics and servos for it.  My health, and a lack of space have kept me from ever starting it.  I've even got some source code on a CD somewhere.
I was going to use mine to carve portraits from B&W photos. The software scanned a row of pixels on my screen (scaled to my plot area) and set the depth based upon the color of the pixel. White was the shallowest and black was the deepest.
That's pretty easy to do and is straight forward.

You mentioned engraving so that requires a lot more precision.
It is relativly easy to determine the location of a given text string in a given font.  I use that in some of stuff I do.  But I'm not concerned with specific, individual characters. I'm just looking for the overall box the text screen fits in.

If it was easy to do you wouldn't be seeing the price so high for that type of code.

I've got Mach1, Mach2, TurboCNC, Master5, ttf2dxf,DeskEngrave,
DXF to G code ACE converter , and a couple of other odds and ends.

About all I can do is use my Bill clinton impersonation and say "I feel your pain"

Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library


I never use this type of programs but found one free:
called: CNC Code Maker

maby is good...
forum for hobby programming:


Larry's beaten me to it ..  :)

Having read around a bit, my advice would be to grit your teeth, save your pocket money, and buy the software.

They've already solved the typography problems and the interface to CNC equipment.

Just a for-instance of the headaches that would await a do-it-yourselfer, take a peek at this 'fundamentals' note from Microsoft ..


I reckon you'd have to devote a few man-years to achieve much progress in that field.

Sorry I have no easy answer to your problem ..

all the best, :)


Tomorrow may be too late ..


Quotemy advice would be to grit your teeth, save your pocket money, and buy the software

I'm about to do this. Just wanted to figure out how this v-varving thing works .

Larry, I nearly have the same set of software ;D and bought a license for some others like MeshCAM, Sheetcam, NCPLOT and they work all pretty well. Sometimes I can engrave and mill small things at work if my boss is good-tempered and the machine is free for a hour or two.

I have enough router plans to found a company but neither place nor money to build one of them.

Anyway friends thanks for your help in this theme.