fixed clipping, added ellipse and arc support

This commit is contained in:
dcone%netscape.com 1999-02-12 16:12:15 +00:00
Родитель 225a311d16
Коммит 2c1dc84a2f
4 изменённых файлов: 310 добавлений и 131 удалений

Просмотреть файл

@ -132,11 +132,9 @@ NS_IMETHODIMP nsDeviceContextPS :: SupportsNativeWidgets(PRBool &aSupportsWidget
*/
NS_IMETHODIMP nsDeviceContextPS :: GetScrollBarDimensions(float &aWidth, float &aHeight) const
{
// WINDOWS CALLS, NEED TO BE THE NATIVE PLATFORMS METRICS
aWidth = ::GetSystemMetrics(SM_CXVSCROLL) * mDevUnitsToAppUnits;
aHeight = ::GetSystemMetrics(SM_CXHSCROLL) * mDevUnitsToAppUnits;
aWidth = 0;
aHeight = 0;
return NS_OK;
}

Просмотреть файл

@ -165,7 +165,7 @@ nsPostScriptObj::~nsPostScriptObj()
}
/** ---------------------------------------------------
* Get rid of data structures for the postscript
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -176,7 +176,7 @@ nsPostScriptObj::finalize_translation()
}
/** ---------------------------------------------------
* Set up the postscript
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -200,7 +200,7 @@ nsPostScriptObj::initialize_translation(PrintSetup* pi)
}
/** ---------------------------------------------------
* Open a document
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -258,8 +258,7 @@ nsPostScriptObj::begin_document()
XP_FilePrintf(f, "\n");
}
XP_FilePrintf(f, "] /isolatin1encoding exch def\n");
XP_FilePrintf(f, "/c { matrix currentmatrix currentpoint translate\n");
XP_FilePrintf(f, " 3 1 roll scale newpath 0 0 1 0 360 arc setmatrix } bind def\n");
for (i = 0; i < N_FONTS; i++)
XP_FilePrintf(f,
"/F%d\n"
@ -348,7 +347,7 @@ nsPostScriptObj::begin_document()
}
/** ---------------------------------------------------
* Open a page
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -376,7 +375,7 @@ nsPostScriptObj::begin_page()
}
/** ---------------------------------------------------
* Close a page
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -399,7 +398,7 @@ nsPostScriptObj::end_page()
}
/** ---------------------------------------------------
* End a document
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -410,7 +409,7 @@ nsPostScriptObj::end_document()
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -419,7 +418,7 @@ nsPostScriptObj::annotate_page(char *aTemplate, int y, int delta_dir, int pn)
}
/** ---------------------------------------------------
* Issue a PS show command, which causes image to be rastered
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -449,7 +448,7 @@ nsPostScriptObj::show(char* txt, int len, char *align)
}
/** ---------------------------------------------------
* Output a PS moveto command
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -468,7 +467,7 @@ nsPostScriptObj::moveto(int x, int y)
}
/** ---------------------------------------------------
* Move the PS cursor to a location, see documentation in nsPostScript.h
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -490,7 +489,7 @@ nsPostScriptObj::moveto_loc(int x, int y)
/** ---------------------------------------------------
* Draw a PS line,see documentation in nsPostScript.h
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -508,19 +507,47 @@ nsPostScriptObj::lineto( int x1, int y1)
}
/** ---------------------------------------------------
* Draw a PS circle,see documentation in nsPostScript.h
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
nsPostScriptObj::circle( int aW, int aH)
nsPostScriptObj::ellipse( int aWidth, int aHeight)
{
XL_SET_NUMERIC_LOCALE();
XP_FilePrintf(mPrintContext->prSetup->out, "%g %g c ", PAGE_TO_POINT_F(aW)/2.0, PAGE_TO_POINT_F(aH)/2.0);
// Ellipse definition
XP_FilePrintf(mPrintContext->prSetup->out,"%g %g ",PAGE_TO_POINT_F(aWidth)/2, PAGE_TO_POINT_F(aHeight)/2);
XP_FilePrintf(mPrintContext->prSetup->out,
" matrix currentmatrix currentpoint translate\n");
XP_FilePrintf(mPrintContext->prSetup->out,
" 3 1 roll scale newpath 0 0 1 0 360 arc setmatrix \n");
XL_RESTORE_NUMERIC_LOCALE();
}
/** ---------------------------------------------------
* Draw a PS rectangle,see documentation in nsPostScript.h
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
nsPostScriptObj::arc( int aWidth, int aHeight,float aStartAngle,float aEndAngle)
{
XL_SET_NUMERIC_LOCALE();
// Arc definition
XP_FilePrintf(mPrintContext->prSetup->out,"%g %g ",PAGE_TO_POINT_F(aWidth)/2, PAGE_TO_POINT_F(aHeight)/2);
XP_FilePrintf(mPrintContext->prSetup->out,
" matrix currentmatrix currentpoint translate\n");
XP_FilePrintf(mPrintContext->prSetup->out,
" 3 1 roll scale newpath 0 0 1 %g %g arc setmatrix \n",aStartAngle,aEndAngle);
XL_RESTORE_NUMERIC_LOCALE();
}
/** ---------------------------------------------------
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -533,8 +560,7 @@ nsPostScriptObj::box( int aW, int aH)
}
/** ---------------------------------------------------
* Create a box, but draw the path in the counterclockwise direction
* so it will subtract using the winding run if inside another path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -547,7 +573,7 @@ nsPostScriptObj::box_subtract( int aW, int aH)
}
/** ---------------------------------------------------
* Set the clipping using the last path closed
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -557,7 +583,27 @@ nsPostScriptObj::clip()
}
/** ---------------------------------------------------
* Open a new path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
nsPostScriptObj::eoclip()
{
XP_FilePrintf(mPrintContext->prSetup->out, " eoclip \n");
}
/** ---------------------------------------------------
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
nsPostScriptObj::clippath()
{
XP_FilePrintf(mPrintContext->prSetup->out, " clippath \n");
}
/** ---------------------------------------------------
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -567,7 +613,7 @@ nsPostScriptObj::newpath()
}
/** ---------------------------------------------------
* Close the currently open path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -577,7 +623,7 @@ nsPostScriptObj::closepath()
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -587,7 +633,7 @@ nsPostScriptObj::initclip()
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -612,7 +658,7 @@ nsPostScriptObj::line( int x1, int y1, int x2, int y2, int thick)
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -622,7 +668,7 @@ nsPostScriptObj::stroke()
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -632,7 +678,7 @@ nsPostScriptObj::fill()
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -642,7 +688,7 @@ nsPostScriptObj::graphics_save()
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -652,7 +698,7 @@ nsPostScriptObj::graphics_restore()
}
/** ---------------------------------------------------
* translate in PS space
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -670,7 +716,7 @@ nsPostScriptObj::translate(int x, int y)
}
/** ---------------------------------------------------
* output an image in 24
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -726,7 +772,7 @@ PRUint8 *theBits,*curline;
}
/** ---------------------------------------------------
* Reset the cliping path
* See documentation in nsPostScriptObj.h
* @update 2/1/99 dwc
*/
void
@ -738,7 +784,7 @@ nsPostScriptObj::setcolor(nscolor aColor)
/** ---------------------------------------------------
* See documentation
* See documentation in nsPostScriptObj.h
* @update 2/1/98 dwc
*/
void
@ -797,3 +843,15 @@ int postscriptFont = 0;
#endif
}
/** ---------------------------------------------------
* OSee documentation in nsPostScriptObj.h
* @update 2/1/98 dwc
*/
void
nsPostScriptObj::comment(char *aTheComment)
{
XP_FilePrintf(mPrintContext->prSetup->out,"%%%s\n", aTheComment);
}

Просмотреть файл

@ -205,33 +205,172 @@ public:
~nsPostScriptObj();
/** ---------------------------------------------------
* Start a postscript page
* @update 2/1/99 dwc
*/
void begin_page();
/** ---------------------------------------------------
* end the current postscript page
* @update 2/1/99 dwc
*/
void end_page();
/** ---------------------------------------------------
* start the current document
* @update 2/1/99 dwc
*/
void begin_document();
/** ---------------------------------------------------
* end the current document
* @update 2/1/99 dwc
*/
void end_document();
void moveto(int x, int y);
void moveto_loc(int x, int y);
void lineto(int x1, int y1);
/** ---------------------------------------------------
* move the cursor to this location
* @update 2/1/99 dwc
*/
void moveto(int aX, int aY);
/** ---------------------------------------------------
* move the cursor to this location
* @update 2/1/99 dwc
*/
void moveto_loc(int aX, int aY);
/** ---------------------------------------------------
* put down a line from the current cursor to the x and y location
* @update 2/1/99 dwc
*/
void lineto(int aX, int aY);
/** ---------------------------------------------------
* close the current postscript path, basically will return to the starting point
* @update 2/1/99 dwc
*/
void closepath();
void circle(int w, int h);
void box(int w, int h);
void box_subtract(int w, int h);
void line(int x1, int y1, int x2, int y2, int thick);
/** ---------------------------------------------------
* create an elliptical path
* @update 2/1/99 dwc
* @param aWidth - Width of the ellipse
* @param aHeight - Height of the ellipse
*/
void ellipse(int aWidth, int aHeight);
/** ---------------------------------------------------
* create an elliptical path
* @update 2/1/99 dwc
* @param aWidth - Width of the ellipse
* @param aHeight - Height of the ellipse
*/
void arc(int aWidth, int aHeight,float aStartAngle,float aEndAngle);
/** ---------------------------------------------------
* create a retangular path
* @update 2/1/99 dwc
*/
void box(int aWidth, int aHeight);
/** ---------------------------------------------------
* create a retangular path, but winding the opposite way of a normal path, for clipping
* @update 2/1/99 dwc
*/
void box_subtract(int aWidth, int aHeight);
/** ---------------------------------------------------
* Draw a postscript line
* @update 2/1/99 dwc
*/
void line(int aX1, int aY1, int aX2, int aY2, int aThink);
/** ---------------------------------------------------
* strock the current path
* @update 2/1/99 dwc
*/
void stroke();
/** ---------------------------------------------------
* fill the current path
* @update 2/1/99 dwc
*/
void fill();
/** ---------------------------------------------------
* push the current graphics state onto the postscript stack
* @update 2/1/99 dwc
*/
void graphics_save();
/** ---------------------------------------------------
* pop the graphics state off of the postscript stack
* @update 2/1/99 dwc
*/
void graphics_restore();
void colorimage(nsIImage *aImage,int x, int y, int w, int h);
void begin_squished_text( float);
/** ---------------------------------------------------
* output a color postscript image
* @update 2/1/99 dwc
*/
void colorimage(nsIImage *aImage,int aX, int aY, int aWidth, int aHeight);
/** ---------------------------------------------------
* ???
* @update 2/1/99 dwc
*/
void begin_squished_text( float aSqeeze);
/** ---------------------------------------------------
* ???
* @update 2/1/99 dwc
*/
void end_squished_text();
/** ---------------------------------------------------
* Get rid of data structures for the postscript
* @update 2/1/99 dwc
*/
void finalize_translation();
/** ---------------------------------------------------
* ???
* @update 2/1/99 dwc
*/
void annotate_page( char*, int, int, int);
void translate(int x, int y);
void show(char* txt, int len, char *align);
/** ---------------------------------------------------
* translate the current coordinate system
* @update 2/1/99 dwc
*/
void translate(int aX, int aY);
/** ---------------------------------------------------
* Issue a PS show command, which causes image to be rastered
* @update 2/1/99 dwc
*/
void show(char* aText, int aLen, char *aAlign);
/** ---------------------------------------------------
* set the clipping path to the current path using the winding rule
* @update 2/1/99 dwc
*/
void clip();
/** ---------------------------------------------------
* set the clipping path to the current path using the even/odd rule
* @update 2/1/99 dwc
*/
void eoclip();
/** ---------------------------------------------------
* start a new path
* @update 2/1/99 dwc
*/
void newpath();
/** ---------------------------------------------------
* reset the current postsript clip path to the page
* @update 2/1/99 dwc
*/
void initclip();
/** ---------------------------------------------------
* make the current postscript path the current postscript clip path
* @update 2/1/99 dwc
*/
void clippath();
/** ---------------------------------------------------
* set the color
* @update 2/1/99 dwc
*/
void setcolor(nscolor aTheColor);
/** ---------------------------------------------------
* Set up the font
* @update 2/1/99 dwc
*/
void setscriptfont(nscoord aHeight, PRUint8 aStyle, PRUint8 aVariant, PRUint16 aWeight, PRUint8 decorations);
/** ---------------------------------------------------
* output a postscript comment
* @update 2/1/99 dwc
*/
void comment(char *aTheComment);
private:
PSContext *mPrintContext;
@ -239,8 +378,11 @@ private:
PRUint16 mPageNumber;
void initialize_translation(PrintSetup* pi);
void begin_document();
/** ---------------------------------------------------
* Set up the postscript
* @update 2/1/99 dwc
*/
void initialize_translation(PrintSetup* aPi);
};

Просмотреть файл

@ -22,9 +22,8 @@
#include "libimg.h"
#include "nsDeviceContextPS.h"
#include "nsIScriptGlobalObject.h"
//#include "prprf.h"
//#include "nsPrintManager.h"
#include "nsPostScriptObj.h"
#include "nsIRegion.h"
static NS_DEFINE_IID(kIRenderingContextIID, NS_IRENDERING_CONTEXT_IID);
@ -220,7 +219,7 @@ nsRenderingContextPS :: SelectOffScreenDrawingSurface(nsDrawingSurface aSurface)
* @update 12/21/98 dwc
*/
NS_IMETHODIMP
nsRenderingContextPS :: GetScreenDrawingSurface(nsDrawingSurface *aSurface)
nsRenderingContextPS :: GetDrawingSurface(nsDrawingSurface *aSurface)
{
*aSurface = nsnull;
return NS_OK;
@ -292,6 +291,10 @@ nsRenderingContextPS :: PushState(void)
mTMatrix = &mStates->mMatrix;
// at startup, the graphics state is not saved yet
if(mPSObj)
mPSObj->graphics_save();
return NS_OK;
}
@ -322,6 +325,7 @@ nsRenderingContextPS :: PopState(PRBool &aClipEmpty)
}
aClipEmpty = retval;
mPSObj->graphics_restore();
return NS_OK;
}
@ -350,27 +354,26 @@ int cliptype;
mTMatrix->TransformCoord(&trect.x, &trect.y,&trect.width, &trect.height);
mStates->mFlags |= FLAG_LOCAL_CLIP_VALID;
// how we combine the new rect with the previous?
if (aCombine == nsClipCombine_kIntersect){
// push the clipstate onto the postscript stack
mPSObj->graphics_save();
mPSObj->newpath();
mPSObj->moveto( NS_PIXELS_TO_POINTS(trect.x), NS_PIXELS_TO_POINTS(trect.y));
mPSObj->box(NS_PIXELS_TO_POINTS(trect.width), NS_PIXELS_TO_POINTS(trect.height));
mPSObj->closepath();
mPSObj->clip();
} else if (aCombine == nsClipCombine_kUnion){
mPSObj->graphics_save();
mPSObj->newpath();
mPSObj->moveto( NS_PIXELS_TO_POINTS(trect.x), NS_PIXELS_TO_POINTS(trect.y));
mPSObj->box(NS_PIXELS_TO_POINTS(trect.width), NS_PIXELS_TO_POINTS(trect.height));
mPSObj->closepath();
mPSObj->clip();
}else if (aCombine == nsClipCombine_kSubtract){
mPSObj->graphics_save();
mPSObj->newpath();
mPSObj->clippath(); // get the current path
mPSObj->moveto(NS_PIXELS_TO_POINTS(trect.x), NS_PIXELS_TO_POINTS(trect.y));
mPSObj->box_subtract(NS_PIXELS_TO_POINTS(trect.width), NS_PIXELS_TO_POINTS(trect.height));
mPSObj->closepath();
mPSObj->clip();
}else if (aCombine == nsClipCombine_kReplace){
mPSObj->graphics_save();
// set the cliping rectangle to this
mPSObj->initclip();
mPSObj->newpath();
mPSObj->moveto(NS_PIXELS_TO_POINTS(trect.x), NS_PIXELS_TO_POINTS(trect.y));
@ -396,14 +399,15 @@ int cliptype;
NS_IMETHODIMP
nsRenderingContextPS :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
{
if (mStates->mFlags & FLAG_LOCAL_CLIP_VALID){
if (mStates->mLocalClip.width !=0){
aRect = mStates->mLocalClip;
aClipValid = PR_TRUE;
}else{
aClipValid = PR_FALSE;
}
return NS_OK;}
return NS_OK;
}
/** ---------------------------------------------------
* See documentation in nsIRenderingContext.h
@ -412,7 +416,10 @@ nsRenderingContextPS :: GetClipRect(nsRect &aRect, PRBool &aClipValid)
NS_IMETHODIMP
nsRenderingContextPS :: SetClipRegion(const nsIRegion& aRegion, nsClipCombine aCombine, PRBool &aClipEmpty)
{
nsRect rect;
nsIRegion* pRegion = (nsIRegion*)&aRegion;
pRegion->GetBoundingBox(&rect.x, &rect.y, &rect.width, &rect.height);
SetClipRect(rect, aCombine, aClipEmpty);
return NS_OK;
}
@ -704,17 +711,19 @@ nsRenderingContextPS :: DrawPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
const nsPoint* np;
POINT pp;
// First transform nsPoint's into POINT's; perform coordinate space
// transformation at the same time
mPSObj->newpath();
// point np to the polypoints
np = &aPoints[0];
// do the initial moveto
pp.x = np->x;
pp.y = np->y;
mTMatrix->TransformCoord((int*)&pp.x,(int*)&pp.y);
mPSObj->moveto_loc(NS_PIXELS_TO_POINTS(pp.x),NS_PIXELS_TO_POINTS(pp.y));
np++;
// we are ignoring the linestyle
// add all the points to the path
for (PRInt32 i = 1; i < aNumPoints; i++, np++){
pp.x = np->x;
pp.y = np->y;
@ -738,17 +747,20 @@ nsRenderingContextPS :: FillPolygon(const nsPoint aPoints[], PRInt32 aNumPoints)
const nsPoint* np;
POINT pp;
// First transform nsPoint's into POINT's; perform coordinate space
// transformation at the same time
mPSObj->newpath();
// point np to the polypoints
np = &aPoints[0];
// do the initial moveto
pp.x = np->x;
pp.y = np->y;
mTMatrix->TransformCoord((int*)&pp.x,(int*)&pp.y);
mPSObj->moveto_loc(NS_PIXELS_TO_POINTS(pp.x),NS_PIXELS_TO_POINTS(pp.y));
np++;
// we are ignoring the linestyle
// add all the points to the path
for (PRInt32 i = 1; i < aNumPoints; i++, np++){
pp.x = np->x;
pp.y = np->y;
@ -782,14 +794,15 @@ nsRenderingContextPS :: DrawEllipse(nscoord aX, nscoord aY, nscoord aWidth, nsco
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
//SetupPen();
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
//SetupPen();
//HBRUSH oldBrush = (HBRUSH)::SelectObject(mDC, ::GetStockObject(NULL_BRUSH));
//::Ellipse(mDC, aX, aY, aX + aWidth, aY + aHeight);
//::SelectObject(mDC, oldBrush);
mPSObj->comment("arc");
mPSObj->newpath();
mPSObj->moveto(NS_PIXELS_TO_POINTS(aX), NS_PIXELS_TO_POINTS(aY));
mPSObj->ellipse(NS_PIXELS_TO_POINTS(aWidth), NS_PIXELS_TO_POINTS(aHeight));
mPSObj->closepath();
mPSObj->stroke();
return NS_OK;
}
@ -808,10 +821,12 @@ NS_IMETHODIMP nsRenderingContextPS :: FillEllipse(nscoord aX, nscoord aY, nscoor
{
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
//SetupSolidPen();
//SetupSolidBrush();
//:Ellipse(mDC, aX, aY, aX + aWidth, aY + aHeight);
mPSObj->comment("arc");
mPSObj->newpath();
mPSObj->moveto(NS_PIXELS_TO_POINTS(aX), NS_PIXELS_TO_POINTS(aY));
mPSObj->ellipse(NS_PIXELS_TO_POINTS(aWidth), NS_PIXELS_TO_POINTS(aHeight));
mPSObj->closepath();
mPSObj->fill();
return NS_OK;
}
@ -835,36 +850,18 @@ NS_IMETHODIMP
nsRenderingContextPS :: DrawArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
//if (nsLineStyle_kNone == mCurrLineStyle)
//return NS_OK;
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
float anglerad, distance;
//mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
//SetupPen();
//SetupSolidBrush();
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
// figure out the the coordinates of the arc from the angle
distance = (float)sqrt((float)(aWidth * aWidth + aHeight * aHeight));
cx = aX + aWidth / 2;
cy = aY + aHeight / 2;
anglerad = (float)(aStartAngle / (180.0 / 3.14159265358979323846));
quad1 = (PRInt32)(aStartAngle / 90.0);
sx = (PRInt32)(distance * cos(anglerad) + cx);
sy = (PRInt32)(cy - distance * sin(anglerad));
anglerad = (float)(aEndAngle / (180.0 / 3.14159265358979323846));
quad2 = (PRInt32)(aEndAngle / 90.0);
ex = (PRInt32)(distance * cos(anglerad) + cx);
ey = (PRInt32)(cy - distance * sin(anglerad));
// this just makes it consitent, on windows 95 arc will always draw CC, nt this sets direction
//::SetArcDirection(mDC, AD_COUNTERCLOCKWISE);
//::Arc(mDC, aX, aY, aX + aWidth, aY + aHeight, sx, sy, ex, ey);
mPSObj->comment("arc");
mPSObj->newpath();
mPSObj->moveto(NS_PIXELS_TO_POINTS(aX), NS_PIXELS_TO_POINTS(aY));
mPSObj->arc(NS_PIXELS_TO_POINTS(aWidth), NS_PIXELS_TO_POINTS(aHeight),aStartAngle,aEndAngle);
mPSObj->closepath();
mPSObj->stroke();
return NS_OK;
}
@ -888,34 +885,18 @@ NS_IMETHODIMP
nsRenderingContextPS :: FillArc(nscoord aX, nscoord aY, nscoord aWidth, nscoord aHeight,
float aStartAngle, float aEndAngle)
{
PRInt32 quad1, quad2, sx, sy, ex, ey, cx, cy;
float anglerad, distance;
if (nsLineStyle_kNone == mCurrLineStyle)
return NS_OK;
//mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
//SetupPen();
mTMatrix->TransformCoord(&aX, &aY, &aWidth, &aHeight);
//SetupSolidPen();
//SetupSolidBrush();
// figure out the the coordinates of the arc from the angle
distance = (float)sqrt((float)(aWidth * aWidth + aHeight * aHeight));
cx = aX + aWidth / 2;
cy = aY + aHeight / 2;
anglerad = (float)(aStartAngle / (180.0 / 3.14159265358979323846));
quad1 = (PRInt32)(aStartAngle / 90.0);
sx = (PRInt32)(distance * cos(anglerad) + cx);
sy = (PRInt32)(cy - distance * sin(anglerad));
anglerad = (float)(aEndAngle / (180.0 / 3.14159265358979323846));
quad2 = (PRInt32)(aEndAngle / 90.0);
ex = (PRInt32)(distance * cos(anglerad) + cx);
ey = (PRInt32)(cy - distance * sin(anglerad));
// this just makes it consistent, on windows 95 arc will always draw CC,
// on NT this sets direction
//::SetArcDirection(mDC, AD_COUNTERCLOCKWISE);
//::Pie(mDC, aX, aY, aX + aWidth, aY + aHeight, sx, sy, ex, ey);
mPSObj->comment("arc");
mPSObj->newpath();
mPSObj->moveto(NS_PIXELS_TO_POINTS(aX), NS_PIXELS_TO_POINTS(aY));
mPSObj->arc(NS_PIXELS_TO_POINTS(aWidth), NS_PIXELS_TO_POINTS(aHeight),aStartAngle,aEndAngle);
mPSObj->closepath();
mPSObj->fill();
return NS_OK;
}