May 16, 2024, 08:08:50 AM

News:

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


Clipping circles

Started by Robert34, June 16, 2009, 02:10:12 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Robert34

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

Ionic Wind Support Team

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.

Ionic Wind Support Team

Ionic Wind Support Team

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
);
*/
Ionic Wind Support Team