IonicWind Software

IWBasic => General Questions => Topic started by: Robert34 on June 16, 2009, 02:10:12 PM

Title: Clipping circles
Post by: Robert34 on June 16, 2009, 02:10:12 PM
When I draw a circle that falls partly outside a window, the circle looks ok but when I print the window, the section of the circle outside the window is also printed.

Is there a way to clip the circle so it doesn't print outside the window?

Is there an EBasic command or API to draw arcs?

Thanks,
  Robert
Title: Re: Clipping circles
Post by: Ionic Wind Support Team on June 16, 2009, 02:53:33 PM
There is an example included with Emergence that shows how to set up clipping regions.  It is aptly named "clipping_example.eba". 

The Windows API has two GDI functions that can help you with drawing arcs.  They are named Arc and ArcTo

Paul.

Title: Re: Clipping circles
Post by: Ionic Wind Support Team on June 16, 2009, 03:10:32 PM
Here is a quickie example of the Arc function:


$include "windows.inc"
/* Example of using the API function Arc to draw */

window w
openwindow w,0,0,640,480,@size|@minbox|@caption|@hidden,0,"Arc example",NULL
centerwindow w
showwindow w,@swshow

/* The Arc function takes a handle to device context
The coordinates of a bounding rectangle
And the start and end points of the arc
*/

uint hdc = GetHDC(w)
'set the ArcDirection to clockwise, you can use AD_COUNTERCLOCKWISE as well
_SetArcDirection(hdc, AD_CLOCKWISE)
'set the color to red
FrontPen w, RGB(255,0,0)
'draw the arc
_Arc(hdc,10,10,200,200, 10,100,200,50)
'release the device context
ReleaseHDC(w,hdc)

OnMessage w,@IDCLOSEWINDOW,&OnClose
waituntil IsWindowClosed(w)
end

sub OnClose(),int
Closewindow w
return false
endsub

/* The MSDN definition of the Arc API funciton for reference
BOOL Arc(
  HDC hdc,         // handle to device context
  int nLeftRect,   // x-coord of rectangle's upper-left corner
  int nTopRect,    // y-coord of rectangle's upper-left corner
  int nRightRect,  // x-coord of rectangle's lower-right corner
  int nBottomRect, // y-coord of rectangle's lower-right corner
  int nXStartArc,  // x-coord of first radial ending point
  int nYStartArc,  // y-coord of first radial ending point
  int nXEndArc,    // x-coord of second radial ending point
  int nYEndArc     // y-coord of second radial ending point
);
*/