31 : screen(s), rect(ax, ay, aw, ah), shown(true), font(0)
90 static inline void swap(
int& a,
int& b) {
int tmp=a; a=b; b=tmp; }
91 static inline void sort(
int& a,
int& b) {
if (a>b) swap(a,b); }
92 static inline void swap(
double& a,
double& b) {
double tmp=a; a=b; b=tmp; }
93 static inline void sort(
double& a,
double& b) {
if (a>b) swap(a,b); }
103 if (clip_rect.
x <
rect.
x) {
104 clip_rect.
w -=
rect.
x - clip_rect.
x;
108 if (clip_rect.
y <
rect.
y) {
109 clip_rect.
h -=
rect.
y - clip_rect.
y;
131 if (x1 < 0 || x1 >=
rect.
w)
return false;
141 if (y1 < 0 || y1 >=
rect.
h)
return false;
155 double m = (double)(y2-y1) / (double)(x2-x1);
156 double b = (double) y1 - (m * x1);
159 if (x1 < 0) { x1 = 0; y1 = (int) b; }
160 if (x1 >=
rect.
w)
return false;
161 if (x2 < 0)
return false;
162 if (x2 >
rect.
w-1) { x2 =
rect.
w-1; y2 = (int) (m * x2 + b); }
164 if (y1 < 0 && y2 < 0)
return false;
165 if (y1 >=
rect.
h && y2 >=
rect.
h)
return false;
167 if (y1 < 0) { y1 = 0; x1 = (int) (-b/m); }
168 if (y1 >=
rect.
h) { y1 =
rect.
h-1; x1 = (int) ((y1-b)/m); }
169 if (y2 < 0) { y2 = 0; x2 = (int) (-b/m); }
170 if (y2 >=
rect.
h) { y2 =
rect.
h-1; x2 = (int) ((y2-b)/m); }
176 goto clip_horizontal;
190 if (x1 < 0 || x1 >=
rect.
w)
return false;
200 if (y1 < 0 || y1 >=
rect.
h)
return false;
214 double m = (double)(y2-y1) / (double)(x2-x1);
215 double b = (double) y1 - (m * x1);
218 if (x1 < 0) { x1 = 0; y1 = b; }
219 if (x1 >=
rect.
w)
return false;
220 if (x2 < 0)
return false;
221 if (x2 >
rect.
w-1) { x2 =
rect.
w-1; y2 = (m * x2 + b); }
223 if (y1 < 0 && y2 < 0)
return false;
224 if (y1 >=
rect.
h && y2 >=
rect.
h)
return false;
226 if (y1 < 0) { y1 = 0; x1 = (-b/m); }
227 if (y1 >=
rect.
h) { y1 =
rect.
h-1; x1 = ((y1-b)/m); }
228 if (y2 < 0) { y2 = 0; x2 = (-b/m); }
229 if (y2 >=
rect.
h) { y2 =
rect.
h-1; x2 = ((y2-b)/m); }
235 goto clip_horizontal;
250 points[0] = (float) (
rect.
x + x1);
251 points[1] = (float) (
rect.
y + y1);
252 points[2] = (float) (
rect.
x + x2);
253 points[3] = (float) (
rect.
y + y2);
270 if (x1 >
rect.
w || x2 < 0 || y1 >
rect.
h || y2 < 0)
275 points[ 0] = (float) (
rect.
x + x1);
276 points[ 1] = (float) (
rect.
y + y1);
277 points[ 2] = (float) (
rect.
x + x2);
278 points[ 3] = (float) (
rect.
y + y1);
280 points[ 4] = (float) (
rect.
x + x2);
281 points[ 5] = (float) (
rect.
y + y1);
282 points[ 6] = (float) (
rect.
x + x2);
283 points[ 7] = (float) (
rect.
y + y2);
285 points[ 8] = (float) (
rect.
x + x2);
286 points[ 9] = (float) (
rect.
y + y2);
287 points[10] = (float) (
rect.
x + x1);
288 points[11] = (float) (
rect.
y + y2);
290 points[12] = (float) (
rect.
x + x1);
291 points[13] = (float) (
rect.
y + y2);
292 points[14] = (float) (
rect.
x + x1);
293 points[15] = (float) (
rect.
y + y1);
315 if (x1 >
rect.
w || x2 < 0 || y1 >
rect.
h || y2 < 0)
319 for (
int i = 0; i < 4; i++) {
374 if (nPts < 2 || nPts > 16)
383 for (
int i = 0; i < nPts-1; i++) {
384 f[n++] = (float)
rect.
x + pts[i].x;
385 f[n++] = (
float)
rect.
y + pts[i].y;
386 f[n++] = (float)
rect.
x + pts[i+1].x;
387 f[n++] = (
float)
rect.
y + pts[i+1].y;
397 if (nPts < 3 || nPts > 8)
406 for (
int i = 0; i < nPts-1; i++) {
407 f[n++] = (float)
rect.
x + pts[i].x;
408 f[n++] = (
float)
rect.
y + pts[i].y;
409 f[n++] = (float)
rect.
x + pts[i+1].x;
410 f[n++] = (
float)
rect.
y + pts[i+1].y;
413 f[n++] = (float)
rect.
x + pts[nPts-1].x;
414 f[n++] = (
float)
rect.
y + pts[nPts-1].y;
415 f[n++] = (float)
rect.
x + pts[0].x;
416 f[n++] = (
float)
rect.
y + pts[0].y;
425 if (nPts < 3 || nPts > 4)
432 for (
int i = 0; i < nPts; i++) {
434 vset4.
s_loc[i].
x = (float) (
rect.
x + pts[i].x) - 0.5f;
435 vset4.
s_loc[i].
y = (float) (
rect.
y + pts[i].y) - 0.5f;
473 ClipBitmap(x1,y1,x2,y2,img,c,blend,clip_rect);
481 Rect clip = clip_rect;
489 if (clip.
x + clip.
w >
rect.
w) {
490 clip.
w -= (clip.
x + clip.
w -
rect.
w);
498 if (clip.
y + clip.
h >
rect.
h) {
499 clip.
h -= (clip.
y + clip.
h -
rect.
h);
506 if (x1 > clip.
x + clip.
w || x2 < clip.x || y1 > clip.
y + clip.
h || y2 < clip.
y)
510 for (
int i = 0; i < 4; i++) {
518 float iw = (float) (x2-x1);
519 float ih = (float) (y2-y1);
520 int x3 = clip.
x + clip.
w;
521 int y3 = clip.
y + clip.
h;
524 u1 = (clip.
x - x1) / iw;
529 u2 = 1.0f - (x2 - x3) / iw;
534 v1 = (clip.
y - y1) / ih;
539 v2 = 1.0f - (y2 - y3) / ih;
596 if (!img || !img->
Width() || !img->
Height())
return;
599 for (
int i = 0; i < 4; i++) {
603 float xscale = (float)
rect.
w / (
float) img->
Width();
604 float yscale = (float)
rect.
h / (
float) img->
Height();
617 vset4.
tu[1] = xscale;
624 vset4.
tu[2] = xscale;
625 vset4.
tv[2] = yscale;
632 vset4.
tv[3] = yscale;
652 static float ellipse_pts[256];
665 if (x1 >
rect.
w || x2 < 0 || y1 >
rect.
h || y2 < 0)
668 double w2 = (x2-x1)/2.0;
669 double h2 = (y2-y1)/2.0;
670 double cx =
rect.
x + x1 + w2;
671 double cy =
rect.
y + y1 + h2;
686 double dt = (
PI/2) / ns;
693 for (
int i = 0; i < ns; i++) {
694 double ex1 = x1 + w2 + cos(theta) * w2;
695 double ey1 = y1 + h2 + sin(theta) * h2;
699 double ex2 = x1 + w2 + cos(theta) * w2;
700 double ey2 = y1 + h2 + sin(theta) * h2;
703 ellipse_pts[np++] = (float) (
rect.
x + ex1);
704 ellipse_pts[np++] = (float) (
rect.
y + ey1);
705 ellipse_pts[np++] = (float) (
rect.
x + ex2);
706 ellipse_pts[np++] = (float) (
rect.
y + ey2);
718 for (
int i = 0; i < ns; i++) {
719 double ex1 = x1 + w2 + cos(theta) * w2;
720 double ey1 = y1 + h2 + sin(theta) * h2;
724 double ex2 = x1 + w2 + cos(theta) * w2;
725 double ey2 = y1 + h2 + sin(theta) * h2;
728 ellipse_pts[np++] = (float) (
rect.
x + ex1);
729 ellipse_pts[np++] = (float) (
rect.
y + ey1);
730 ellipse_pts[np++] = (float) (
rect.
x + ex2);
731 ellipse_pts[np++] = (float) (
rect.
y + ey2);
743 for (
int i = 0; i < ns; i++) {
744 double ex1 = x1 + w2 + cos(theta) * w2;
745 double ey1 = y1 + h2 + sin(theta) * h2;
749 double ex2 = x1 + w2 + cos(theta) * w2;
750 double ey2 = y1 + h2 + sin(theta) * h2;
753 ellipse_pts[np++] = (float) (
rect.
x + ex1);
754 ellipse_pts[np++] = (float) (
rect.
y + ey1);
755 ellipse_pts[np++] = (float) (
rect.
x + ex2);
756 ellipse_pts[np++] = (float) (
rect.
y + ey2);
768 for (
int i = 0; i < ns; i++) {
769 double ex1 = x1 + w2 + cos(theta) * w2;
770 double ey1 = y1 + h2 + sin(theta) * h2;
774 double ex2 = x1 + w2 + cos(theta) * w2;
775 double ey2 = y1 + h2 + sin(theta) * h2;
778 ellipse_pts[np++] = (float) (
rect.
x + ex1);
779 ellipse_pts[np++] = (float) (
rect.
y + ey1);
780 ellipse_pts[np++] = (float) (
rect.
x + ex2);
781 ellipse_pts[np++] = (float) (
rect.
y + ey2);
801 if (x1 >
rect.
w || x2 < 0 || y1 >
rect.
h || y2 < 0)
804 double w2 = (x2-x1)/2.0;
805 double h2 = (y2-y1)/2.0;
821 double theta = -
PI / 2;
824 for (
int i = 0; i < ns; i++) {
825 double ex1 = cos(theta) * w2;
826 double ey1 = sin(theta) * h2;
830 double ex2 = cos(theta) * w2;
831 double ey2 = sin(theta) * h2;
835 pts[0].x = (int) (cx - ex1);
836 pts[0].y = (int) (cy + ey1);
838 pts[1].x = (int) (cx + ex1);
839 pts[1].y = (int) (cy + ey1);
841 pts[2].x = (int) (cx + ex2);
842 pts[2].y = (int) (cy + ey2);
844 pts[3].x = (int) (cx - ex2);
845 pts[3].y = (int) (cy + ey2);
850 if (pts[1].x < 0 && pts[2].x < 0)
853 if (pts[0].y >
rect.
h)
859 if (pts[0].x < 0) pts[0].x = 0;
860 if (pts[3].x < 0) pts[3].x = 0;
864 if (pts[0].y < 0) pts[0].y = 0;
865 if (pts[1].y < 0) pts[1].y = 0;
885 vsprintf_s(msgbuf, fmt, (
char *)(&fmt+1));
899 Rect clip_rect = txt_rect;
901 if (clip_rect.
x < 0) {
902 int dx = -clip_rect.
x;
907 if (clip_rect.
y < 0) {
908 int dy = -clip_rect.
y;
913 if (clip_rect.
w < 1 || clip_rect.
h < 1)
916 if (clip_rect.
x + clip_rect.
w >
rect.
w)
917 clip_rect.
w =
rect.
w - clip_rect.
x;
919 if (clip_rect.
y + clip_rect.
h >
rect.
h)
920 clip_rect.
h =
rect.
h - clip_rect.
y;
925 if (
font && txt && count) {
931 if (flags & DT_CALCRECT) {
932 txt_rect.
h = clip_rect.
h;
933 txt_rect.
w = clip_rect.
w;