Author Topic: How do graphic pgms work ?  (Read 2978 times)

0 Members and 1 Guest are viewing this topic.

Offline RitchieF

  • Paid Subscriber
  • Full Member
  • *****
  • Posts: 184
How do graphic pgms work ?
« on: August 07, 2011, 11:46:29 AM »
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

Richard

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5989
  • 'All I like is finishing'
Re: How do graphic pgms work ?
« Reply #1 on: August 07, 2011, 12:10:48 PM »
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.

LarryMc
« Last Edit: August 07, 2011, 12:14:50 PM by LarryMc »
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Offline RitchieF

  • Paid Subscriber
  • Full Member
  • *****
  • Posts: 184
Re: How do graphic pgms work ?
« Reply #2 on: August 07, 2011, 09:07:19 PM »
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 ?

Richard

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5989
  • 'All I like is finishing'
Re: How do graphic pgms work ?
« Reply #3 on: August 07, 2011, 09:31:24 PM »
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.

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

Offline GWS

  • Partner Developer
  • Hero Member
  • *****
  • Posts: 1499
Re: How do graphic pgms work ?
« Reply #4 on: August 07, 2011, 10:12:54 PM »
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 ..

http://en.wikipedia.org/wiki/Vector_graphics

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, :)

Graham
Tomorrow may be too late ..

Offline RitchieF

  • Paid Subscriber
  • Full Member
  • *****
  • Posts: 184
Re: How do graphic pgms work ?
« Reply #5 on: August 08, 2011, 11:53:54 AM »
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 :

http://www.vectric.com/WebSite/Vectric/vcp/vcp_index.htm
 
Sorry for perhaps asking the wrong way

Richard

Offline LarryMc

  • Administrator
  • Hero Member
  • *****
  • Posts: 5989
  • 'All I like is finishing'
Re: How do graphic pgms work ?
« Reply #6 on: August 08, 2011, 12:49:07 PM »
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"

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

Offline aurelCB

  • Hero Member
  • *****
  • Posts: 1008
Re: How do graphic pgms work ?
« Reply #7 on: August 08, 2011, 01:08:27 PM »
I never use this type of programs but found one free:
http://www.cncsimple.com/features.php
called: CNC Code Maker

maby is good...
forum for hobby programming:
http://basicpro.mipropia.com/smf/index.php

Offline GWS

  • Partner Developer
  • Hero Member
  • *****
  • Posts: 1499
Re: How do graphic pgms work ?
« Reply #8 on: August 08, 2011, 01:09:06 PM »
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 ..

http://www.microsoft.com/typography/otspec/TTCH01.htm

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, :)

Graham

Tomorrow may be too late ..

Offline RitchieF

  • Paid Subscriber
  • Full Member
  • *****
  • Posts: 184
Re: How do graphic pgms work ?
« Reply #9 on: August 08, 2011, 09:13:01 PM »
Quote
my 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.

Richard