7 * a couple macros to fill a single pixel or a line
9 #define PUTPIXEL(x,y,BrushInst) \
10 ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
12 &BrushInst.BrushObject, \
15 ROP2_TO_MIX(Dc_Attr->jROP2));
17 #define PUTLINE(x1,y1,x2,y2,BrushInst) \
18 ret = ret && IntEngLineTo(&BitmapObj->SurfObj, \
20 &BrushInst.BrushObject, \
23 ROP2_TO_MIX(Dc_Attr->jROP2));
25 #define Rsin(d) ((d) == 0.0 ? 0.0 : ((d) == 90.0 ? 1.0 : sin(d*M_PI/180.0)))
26 #define Rcos(d) ((d) == 0.0 ? 1.0 : ((d) == 90.0 ? 0.0 : cos(d*M_PI/180.0)))
44 PGDIBRUSHOBJ PenBrushObj
, FillBrushObj
;
45 GDIBRUSHINST FillBrushInst
, PenBrushInst
;
48 double AngleStart
, AngleEnd
;
49 LONG RadiusX
, RadiusY
, CenterX
, CenterY
;
50 LONG SfCx
, SfCy
, EfCx
, EfCy
;
60 0|___________________|
63 if (Right
<= Left
|| Top
<= Bottom
)
65 DPRINT1("Arc Fail 1\n");
66 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
70 if (Right - Left != Bottom - Top)
75 Dc_Attr
= dc
->pDc_Attr
;
76 if(!Dc_Attr
) Dc_Attr
= &dc
->Dc_Attr
;
78 FillBrushObj
= BRUSHOBJ_LockBrush(Dc_Attr
->hbrush
);
79 if (NULL
== FillBrushObj
)
81 DPRINT1("Arc Fail 2\n");
82 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
86 PenBrushObj
= PENOBJ_LockPen(Dc_Attr
->hpen
);
87 if (NULL
== PenBrushObj
)
89 DPRINT1("Arc Fail 3\n");
90 BRUSHOBJ_UnlockBrush(FillBrushObj
);
91 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
95 BitmapObj
= BITMAPOBJ_LockBitmap(dc
->w
.hBitmap
);
96 if (NULL
== BitmapObj
)
98 DPRINT1("Arc Fail 4\n");
99 BRUSHOBJ_UnlockBrush(FillBrushObj
);
100 PENOBJ_UnlockPen(PenBrushObj
);
101 SetLastWin32Error(ERROR_INTERNAL_ERROR
);
105 IntGdiInitBrushInstance(&FillBrushInst
, FillBrushObj
, dc
->XlateBrush
);
106 IntGdiInitBrushInstance(&PenBrushInst
, PenBrushObj
, dc
->XlatePen
);
108 Left
+= dc
->ptlDCOrig
.x
;
109 Right
+= dc
->ptlDCOrig
.x
;
110 Top
+= dc
->ptlDCOrig
.y
;
111 Bottom
+= dc
->ptlDCOrig
.y
;
113 XRadialStart
+= dc
->ptlDCOrig
.x
;
114 YRadialStart
+= dc
->ptlDCOrig
.y
;
115 XRadialEnd
+= dc
->ptlDCOrig
.x
;
116 YRadialEnd
+= dc
->ptlDCOrig
.y
;
118 DPRINT1("1: StartX: %d, StartY: %d, EndX: %d, EndY: %d\n",
119 XRadialStart
,YRadialStart
,XRadialEnd
,YRadialEnd
);
121 RectBounds
.left
= Left
;
122 RectBounds
.right
= Right
;
123 RectBounds
.top
= Top
;
124 RectBounds
.bottom
= Bottom
;
125 DPRINT1("1: Left: %d, Top: %d, Right: %d, Bottom: %d\n",
126 RectBounds
.left
,RectBounds
.top
,RectBounds
.right
,RectBounds
.bottom
);
130 DPRINT1("Arc Good Exit\n");
131 PUTPIXEL(Left
, Top
, PenBrushInst
);
132 BITMAPOBJ_UnlockBitmap(BitmapObj
);
133 BRUSHOBJ_UnlockBrush(FillBrushObj
);
134 PENOBJ_UnlockPen(PenBrushObj
);
137 RadiusX
= (RectBounds
.right
- RectBounds
.left
)/2;
138 RadiusY
= (RectBounds
.bottom
- RectBounds
.top
)/2;
139 CenterX
= RectBounds
.left
+ RadiusX
;
140 CenterY
= RectBounds
.top
+ RadiusY
;
142 AngleEnd
= atan2(-(YRadialEnd
- CenterY
), XRadialEnd
- CenterX
)* (180.0 / M_PI
);
143 AngleStart
= atan2(-(YRadialStart
- CenterY
), XRadialStart
- CenterX
)* (180.0 / M_PI
);
145 SfCx
= (Rcos(AngleStart
) * RadiusX
);
146 SfCy
= (Rsin(AngleStart
) * RadiusY
);
148 EfCx
= (Rcos(AngleEnd
) * RadiusX
);
149 EfCy
= (Rsin(AngleEnd
) * RadiusY
);
151 FLOAT AngS
= AngleStart
, Factor
= 1;
152 int x
,y
, ox
= 0, oy
= 0;
154 if (arctype
== GdiTypePie
)
156 PUTLINE(SfCx
+ CenterX
, SfCy
+ CenterY
, CenterX
, CenterY
, PenBrushInst
);
159 for(; AngS
< AngleEnd
; AngS
+= Factor
)
161 x
= (Rcos(AngS
) * RadiusX
);
162 y
= (Rsin(AngS
) * RadiusY
);
164 if (arctype
== GdiTypePie
)
165 PUTLINE((x
+ CenterX
) - 1, (y
+ CenterY
) - 1, CenterX
, CenterY
, FillBrushInst
);
167 PUTPIXEL (x
+ CenterX
, y
+ CenterY
, PenBrushInst
);
172 if (arctype
== GdiTypePie
)
173 PUTLINE(EfCx
+ CenterX
, EfCy
+ CenterY
, CenterX
, CenterY
, PenBrushInst
);
176 BITMAPOBJ_UnlockBitmap(BitmapObj
);
177 BRUSHOBJ_UnlockBrush(FillBrushObj
);
178 PENOBJ_UnlockPen(PenBrushObj
);
179 DPRINT1("IntArc Exit.\n");
199 double AngleStart
, AngleEnd
;
200 LONG RadiusX
, RadiusY
, CenterX
, CenterY
, Width
, Height
;
201 LONG SfCx
, SfCy
, EfCx
= 0, EfCy
= 0;
203 DPRINT1("StartX: %d, StartY: %d, EndX: %d, EndY: %d\n",
204 XStartArc
,YStartArc
,XEndArc
,YEndArc
);
205 DPRINT1("Left: %d, Top: %d, Right: %d, Bottom: %d\n",
206 LeftRect
,TopRect
,RightRect
,BottomRect
);
208 if (PATH_IsPathOpen(dc
->DcLevel
))
222 if (arctype
== GdiTypeArcTo
)
224 Width
= fabs(RightRect
- LeftRect
);
225 Height
= fabs(BottomRect
- TopRect
);
228 CenterX
= RightRect
> LeftRect
? LeftRect
+ RadiusX
: RightRect
+ RadiusX
;
229 CenterY
= BottomRect
> TopRect
? TopRect
+ RadiusY
: BottomRect
+ RadiusY
;
231 AngleStart
= atan2((YStartArc
- CenterY
)/Height
, (XStartArc
- CenterX
)/Width
);
232 AngleEnd
= atan2((YEndArc
- CenterY
)/Height
, (XEndArc
- CenterX
)/Width
);
234 EfCx
= GDI_ROUND(CenterX
+cos(AngleEnd
) * RadiusX
);
235 EfCy
= GDI_ROUND(CenterY
+sin(AngleEnd
) * RadiusY
);
236 SfCx
= GDI_ROUND(CenterX
+cos(AngleStart
) * RadiusX
);
237 SfCy
= GDI_ROUND(CenterY
+sin(AngleStart
) * RadiusY
);
239 IntGdiLineTo(dc
, SfCx
, SfCy
);
242 IntGdiSetRect(&rc
, LeftRect
, TopRect
, RightRect
, BottomRect
);
243 IntGdiSetRect(&rc1
, XStartArc
, YStartArc
, XEndArc
, YEndArc
);
245 // IntLPtoDP(dc, (LPPOINT)&rc, 2);
246 // IntLPtoDP(dc, (LPPOINT)&rc1, 2);
259 if (arctype
== GdiTypeArcTo
)
261 IntGdiMoveToEx(dc
, EfCx
, EfCy
, NULL
);
269 IntGdiAngleArc( PDC pDC
,
276 INT x1
, y1
, x2
, y2
, arcdir
;
279 /* Calculate the end point */
280 x2
= x
+ (INT
)(cos(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
281 y2
= y
- (INT
)(sin(((eStartAngle
+eSweepAngle
)/360)*(M_PI
*2)) * dwRadius
);
283 x1
= x
+ (INT
)(cos((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
284 y1
= y
- (INT
)(sin((eStartAngle
/360)*(M_PI
*2)) * dwRadius
);
286 arcdir
= pDC
->DcLevel
.flPath
& DCPATH_CLOCKWISE
;
287 if (eSweepAngle
>= 0)
288 pDC
->DcLevel
.flPath
&= ~DCPATH_CLOCKWISE
;
290 pDC
->DcLevel
.flPath
|= DCPATH_CLOCKWISE
;
292 result
= IntGdiArcInternal( GdiTypeArcTo
,
303 pDC
->DcLevel
.flPath
|= (arcdir
& DCPATH_CLOCKWISE
);
307 IntGdiMoveToEx(pDC
, x2
, y2
, NULL
);
312 /* FUNCTIONS *****************************************************************/
321 IN DWORD dwStartAngle
,
322 IN DWORD dwSweepAngle
)
326 gxf_long worker
, worker1
;
328 pDC
= DC_LockDc (hDC
);
331 SetLastWin32Error(ERROR_INVALID_HANDLE
);
334 if (pDC
->DC_Type
== DC_TYPE_INFO
)
337 /* Yes, Windows really returns TRUE in this case */
340 worker
.l
= dwStartAngle
;
341 worker1
.l
= dwSweepAngle
;
342 Ret
= IntGdiAngleArc( pDC
, x
, y
, dwRadius
, worker
.f
, worker1
.f
);
364 dc
= DC_LockDc (hDC
);
367 SetLastWin32Error(ERROR_INVALID_HANDLE
);
370 if (dc
->DC_Type
== DC_TYPE_INFO
)
373 /* Yes, Windows really returns TRUE in this case */
377 Ret
= IntGdiArcInternal(