Vector Graphic Curves to Line-Segment Coordinates?

Here everybody can post his problems with PhotoLine
Antworten
Benutzeravatar
Koyaanis
Mitglied
Beiträge: 217
Registriert: Mo 25 Sep 2006 20:23

Vector Graphic Curves to Line-Segment Coordinates?

Beitrag von Koyaanis »

Howdy,

I have need to design some simple shapes and curves, but would like to have a way where I can output those curved lines into shorter straight-line segments. Denoted by their beginning X1,Y1, and X2,Y2 end-points as they followed the curve shape. I tried using the HP Plotter Output to HPG file format, but I can't make sense of what those commands and coordinates in the HPG file stand for. They didn't seem to correspond to the smaller document layout (of 250px X 250px) that I was working in.

Is there any way to do this in Photoline? If not, does anyone know of a program that can convert simple vector curves to short line-segments, and output those as drawing commands where each line is denoted by X1, Y1, X2, Y2.

I have done this in the past manually, by overlaying a known curve with short line segments, and then reading off all the line-segment endpoints. But as you can guess, this is tedious as hell. I just now had a slightly more complex curve to define as line-segments and refuse to go through that nightmare again.

Thanks if you have any info on an easier way to accomplish this.
Benutzeravatar
Hoogo
Betatester
Beiträge: 4021
Registriert: So 03 Jul 2005 13:35
Wohnort: Mülheim/Ruhr

Re: Vector Graphic Curves to Line-Segment Coordinates?

Beitrag von Hoogo »

I did some testing...
For solid black vectors this should work:
-Scale up to a reasonable high resolution.
-Convert the layer to monochrome.
-Convert back to vector.
-Dissolve the created group and delete the unwanted additional layer.
-Choose "Layout > Vector > Optimize vector". Play with line optimization.
-Save as hpgl.

hpgl seems to be a quite readable language.
english wikipedia and this page mentioned there explain a lot.
Benutzeravatar
Koyaanis
Mitglied
Beiträge: 217
Registriert: Mo 25 Sep 2006 20:23

Re: Vector Graphic Curves to Line-Segment Coordinates?

Beitrag von Koyaanis »

Thanks! I tried something like that earlier, but didn't include the conversions to/from monochrome to vector. It ALMOST works.

I am able to convert the coordinates to pixel locations by dividing the original document X,Y size by 40 (the 40 steps per mm in HPGL plotter output). However, the HPGL plotter output seems to add in a default 0.5mm X,Y offset to the origin. The HPGL output always sets the origin at 20,20 or if I set a -0.5mm X,Y offset then I get a -20,-20 as origin. It jumps over the 0,0 point. If I set a -0.3mm offset then it jumps to either -22 or +22 (or something like that). It seems to round-off on that 0.5mm origin and jumps over it when you set an offset that tiny. So, it's not a clean solution. If there was a way to set an absolute origin of 0,0 in the HPGL export panel, then this could almost work. I still have to duplicate every line manually, but I could probably work that out in a little script in UltraEdit or something.

For a VERY simple rectangle example, I would get:

IN; VS6;
SC;
PU;
PA22, 260;
PD;
PA22, 20;
PA382, 20;
PA382, 260;
PA22, 260;
PU;

As the HPGL output. But I'd need it as:

Line 22, 260, 22, 20
Line 22, 20, 382, 20
Line 382, 20, 382, 60
Line 382, 60, 22, 260

HPGL is going:
X1, Y1
X2, Y2
X3, Y3
X4, Y4

I have to convert that to
X1, Y1, X2, Y2
X2, Y2, X3, Y3
X3, Y3, X4, Y4
etc.

Then too, I found that for the graphic environment I'm designing for, the origin 0,0 is in the upper-left corner. It seems the HPGL output is setting the origin to the lower-right corner(?). But that can be circumvented by a 270 degree rotation before exporting in HPGL.

So confusing. :-) I should just lay down the line segments manually like I did before. I'd have had it done by now. :-)

In case anyone is curious, I'm trying to find a MUCH simpler way to draw complex "Grids" for that CHDK program for Canon cameras. http://chdk.wikia.com/wiki/Grids By using Photoline's vector graphic commands. On top of the HPGL origin problems, I also have to convert the original design done in a 360x270 aspect ratio to a 360x240 aspect ratio afterward, in order to give it the proper proportions in the LCD/EVF.

If only the Photoline Gods could include a little CHDK Grids Design Assist mode. :-) What are the chances of that happening? :-)
Antworten