March 28, 2024, 04:37:09 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Parallel curves - an easy way to draw them

Started by Andy, June 18, 2021, 05:07:41 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

June 18, 2021, 05:07:41 AM Last Edit: June 18, 2021, 05:13:10 AM by Andy
I thought I would re-post this in this section.

I struggled for a long time trying to draw parallel curves.

This is an easy way for you if you want to save them as a bitmap etc.

Here I am using the CIRCLE command and I draw to circles around the same point, the second one has a smaller radius than the first, how much smaller is up to you.

circle w1, 650,350,200, RGB(255,0,0), RGB(219,219,219) 'Radius 200
circle w1, 650,350,190, RGB(255,0,0), RGB(0,0,0) 'Radius 190 (smaller)

Once you have drawn the two circles the steps are:

1. Use the Windows snipping tool to capture the circle.
2. Use a graphics editor to load the circle image.
3. Crop whatever portion of the circle you want (I use a quarters of it).
4. Save the portion(s) of the image as a new image / images.

And there you have it.

Parallel curves made easy.

See attached.

Thanks,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

ckoehn

June 21, 2021, 09:16:49 AM #1 Last Edit: June 21, 2021, 11:23:01 AM by ckoehn
I'm not sure what you are trying to do with arc's,  but here is something for you to play around with.

$INCLUDE "windowssdk.inc"

WINDOW win

OpenWindow win,0,0,400,425,@MINBOX|@MAXBOX|@SIZE|@CAPTION|@SYSMENU,0,"Test",&win_handler

DrawArc(win, 110,110, 95, 90,0, 1, rgb(255,0,0), TRUE)
DrawArc(win, 110,110, 100, 90,90, 1, rgb(255,0,0))
DrawArc(win, 110,110, 95, 180,-90, 1, rgb(255,0,0))

WAITUNTIL ISWINDOWCLOSED(win)
END

SUB win_handler(), INT
SELECT @MESSAGE
CASE @IDCREATE
CENTERWINDOW win
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
CLOSEWINDOW win
ENDSELECT
RETURN 0
END SUB

sub DrawArc(window w1, int cx, int cy, int radius, float start_angle, float sweep_angle, int arc_width, uint arc_color, Opt int MoveToStart = FALSE, opt uint backcolor = rgb(255,255,255)), int
int hdc = gethdc(w1) ' get the hdc of the window

if MoveToStart
MoveToEx(hdc, cx,cy, 0) 'move point to center of arc
SelectObject(hdc, GetStockObject(NULL_PEN)) 'this draws a line (transparent) from center to starting point of the arc))
AngleArc(hdc, cx,cy, radius, start_angle, 0) 'move to starting point of arc
endif

SelectObject(hdc, CreatePen(PS_SOLID,arc_width,arc_color)) 'set the pen color

AngleArc(hdc, cx,cy, radius, start_angle, sweep_angle) 'draws the arc

releasehdc w1, hdc 'release the hdc

        return 0
endsub

Later,
Clint

Andy

Thanks Clint, always a help!

Just showing one simple way to create parallel curves, it may help someone, someday.

Andy.
 :)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.