333 float hot_xp, hot_yp;
334 float sin_angle, cos_angle;
335 Pixmap bitmap_to_paint;
341 while(angle<0) angle+=360;
343 while(angle>=360) angle-=360;
357 GC my_gc = XCreateGC(dpy, drawable, 0,
nullptr);
358 XCopyGC(dpy, gc, GCForeground|GCBackground|GCFunction|GCPlaneMask, my_gc);
394 hot_xp= hot_x*cos_angle - hot_y*sin_angle;
395 hot_yp= hot_x*sin_angle + hot_y*cos_angle;
401 Pixmap empty_stipple;
405 if(!xpoints)
return 1;
408 for(i=0; i<4*item->
fNl; i++) {
409 xpoints[i].x=
int((
float)
x + ( (item->
fCornersX[i]-hot_x)*cos_angle +
411 xpoints[i].y=
int((
float)
y + (-(item->
fCornersX[i]-hot_x)*sin_angle +
418 empty_stipple=XCreatePixmap(dpy, drawable, 1, 1, 1);
420 depth_one_gc=XCreateGC(dpy, empty_stipple, 0,
nullptr);
421 XSetForeground(dpy, depth_one_gc, 0);
422 XFillRectangle(dpy, empty_stipple, depth_one_gc, 0, 0, 2, 2);
424 XSetStipple(dpy, my_gc, empty_stipple);
425 XSetFillStyle(dpy, my_gc, FillOpaqueStippled);
427 XFillPolygon(dpy, drawable, my_gc, xpoints, 4*item->
fNl, Nonconvex,
432 XFreeGC(dpy, depth_one_gc);
433 XFreePixmap(dpy, empty_stipple);
448 Pixmap new_bitmap, inverse;
451 if(XGetGCValues(dpy, gc,
452 GCStipple|GCFillStyle|GCForeground|GCBackground|
453 GCTileStipXOrigin|GCTileStipYOrigin,
457 if((values.fill_style==FillStippled ||
458 values.fill_style==FillOpaqueStippled) && !bg) {
461 if(values.fill_style==FillOpaqueStippled) {
462 XSetForeground(dpy, my_gc, values.background);
463 XSetFillStyle(dpy, my_gc, FillStippled);
464 XSetStipple(dpy, my_gc, item->
fBitmap);
465 XSetTSOrigin(dpy, my_gc, xp, yp);
466 XFillRectangle(dpy, drawable, my_gc, xp, yp,
468 XSetForeground(dpy, my_gc, values.foreground);
472 new_bitmap=XCreatePixmap(dpy, drawable,
476 depth_one_gc=XCreateGC(dpy, new_bitmap, 0,
nullptr);
477 XSetForeground(dpy, depth_one_gc, 1);
478 XSetBackground(dpy, depth_one_gc, 0);
481 XSetTSOrigin(dpy, depth_one_gc,
482 values.ts_x_origin-xp, values.ts_y_origin-yp);
485 XSetStipple(dpy, depth_one_gc, values.stipple);
486 XSetFillStyle(dpy, depth_one_gc, FillOpaqueStippled);
487 XFillRectangle(dpy, new_bitmap, depth_one_gc,
491 XSetTSOrigin(dpy, depth_one_gc, 0, 0);
494 inverse=XCreatePixmap(dpy, drawable,
498 XSetFillStyle(dpy, depth_one_gc, FillSolid);
499 XSetFunction(dpy, depth_one_gc, GXcopyInverted);
500 XCopyArea(dpy, item->
fBitmap, inverse, depth_one_gc,
504 XSetForeground(dpy, depth_one_gc, 0);
505 XSetBackground(dpy, depth_one_gc, 1);
506 XSetStipple(dpy, depth_one_gc, inverse);
507 XSetFillStyle(dpy, depth_one_gc, FillStippled);
508 XSetFunction(dpy, depth_one_gc, GXcopy);
509 XFillRectangle(dpy, new_bitmap, depth_one_gc,
513 XFreePixmap(dpy, inverse);
514 XFreeGC(dpy, depth_one_gc);
517 bitmap_to_paint=new_bitmap;
524 XSetFillStyle(dpy, my_gc, FillStippled);
525 XSetStipple(dpy, my_gc, bitmap_to_paint);
526 XSetTSOrigin(dpy, my_gc, xp, yp);
527 XFillRectangle(dpy, drawable, my_gc, xp, yp,
534 if(bitmap_to_paint!=item->
fBitmap)
535 XFreePixmap(dpy, bitmap_to_paint);
538 XFreePixmap(dpy, item->
fBitmap);
559 char *str1, *str2, *str3;
560 const char *str2_a=
"\0", *str2_b=
"\n\0";
567 GC my_gc = XCreateGC(dpy, drawable, 0,
nullptr);
569 GCForeground|GCBackground|GCFunction|GCStipple|GCFillStyle|
570 GCTileStipXOrigin|GCTileStipYOrigin|GCPlaneMask, my_gc);
571 XSetFont(dpy, my_gc, font->fid);
575 for(i=0; i<(
int)strlen(
text)-1; i++)
586 height=font->ascent+font->descent;
595 yp=
y-nl*(height-font->descent)/2+font->ascent;
601 yp=
y-nl*(height-font->descent)+font->ascent;
609 str3 = my_strtok(str1, str2);
617 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
624 xp=
x-overall.rbearing/2;
626 xp=
x-overall.rbearing;
630 XDrawString(dpy, drawable, my_gc, xp, yp, str3, strlen(str3));
632 XDrawImageString(dpy, drawable, my_gc, xp, yp, str3, strlen(str3));
637 str3=my_strtok((
char *)
nullptr, str2);
797 char *str1, *str2, *str3;
798 const char *str2_a=
"\0", *str2_b=
"\n\0";
800 int byte_w_in, byte_w_out;
802 float sin_angle, cos_angle;
810 int old_cols_in=0, old_rows_in=0;
814 if(!item)
return nullptr;
821 for(i=0; i<(
int)strlen(
text)-1; i++)
827 str2 = (
char *)str2_a;
829 str2 = (
char *)str2_b;
838 str3 = my_strtok(str1, str2);
845 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
852 str3 = my_strtok(
nullptr, str2);
855 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
865 height=font->ascent+font->descent;
872 canvas=XCreatePixmap(dpy, DefaultRootWindow(dpy),
876 font_gc = XCreateGC(dpy, canvas, 0,
nullptr);
877 XSetBackground(dpy, font_gc, 0);
878 XSetFont(dpy, font_gc, font->fid);
881 XSetForeground(dpy, font_gc, 0);
882 XFillRectangle(dpy, canvas, font_gc, 0, 0,
884 XSetForeground(dpy, font_gc, 1);
917 str3 = my_strtok(str1, str2);
928 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
940 XDrawString(dpy, canvas, font_gc, xp, yp, str3, strlen(str3));
949 (float)overall.rbearing*
gRotStyle.fMagnify;
960 str3=my_strtok(
nullptr, str2);
976 1, XYPixmap, imageIn, 0, 0);
977 imageIn->format=XYBitmap;
1009 byte_w_in = (item->
fColsIn-1)/8+1;
1010 byte_w_out = (item->
fColsOut-1)/8+1;
1019 if(angle==0 || angle==
float(
M_PI/2) ||
1020 angle==
float(
M_PI) || angle==
float(3*
M_PI/2)) {
1025 else if(angle<
M_PI) {
1027 (dj-(
float)item->
fRowsIn/(2*cos_angle))/
1030 (dj+(
float)item->
fRowsIn/(2*cos_angle))/
1036 (dj+(
float)item->
fRowsIn/(2*cos_angle))/
1039 (dj-(
float)item->
fRowsIn/(2*cos_angle))/
1050 di=(float)((xl<0)?0:(
int)xl)+0.5-(float)item->
fColsOut/2;
1051 byte_out=(item->
fRowsOut-j-1)*byte_w_out;
1054 for(i=((xl<0)?0:(
int)xl);
1058 it=
int((
float)item->
fColsIn/2 + ( di*cos_angle + dj*sin_angle));
1059 jt=
int((
float)item->
fRowsIn/2 - (-di*sin_angle + dj*cos_angle));
1062 if(it>=0 && it<item->fColsIn && jt>=0 && jt<item->fRowsIn)
1063 if((imageIn->data[jt*byte_w_in+it/8] & 128>>(it%8))>0)
1064 item->
fXimage->data[byte_out+i/8]|=128>>i%8;
1072 XDestroyImage(imageIn);
1084 item->
fBitmap=XCreatePixmap(dpy, DefaultRootWindow(dpy),
1088 XPutImage(dpy, item->
fBitmap, font_gc, item->
fXimage, 0, 0, 0, 0,
1095 XFreeGC(dpy, font_gc);
1096 XFreePixmap(dpy, canvas);
1237 int cols_in, rows_in;
1238 int cols_out, rows_out;
1240 float z1, z2, z3, z4;
1241 int byte_width_in, byte_width_out;
1245 cols_in=ximage->width;
1246 rows_in=ximage->height;
1253 imageOut =
MakeXImage(dpy, cols_out, rows_out);
1258 byte_width_in=(cols_in-1)/8+1;
1259 byte_width_out=(cols_out-1)/8+1;
1267 for(j2=0; j2<rows_out; j2++) {
1271 for(i2=0; i2<cols_out; i2++) {
1276 if(i==cols_in-1 && j!=rows_in-1) {
1280 z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
1282 z3=(ximage->data[(j+1)*byte_width_in+i/8] & 128>>(i%8))>0;
1286 else if(i!=cols_in-1 && j==rows_in-1) {
1290 z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
1291 z2=(ximage->data[j*byte_width_in+(i+1)/8] & 128>>((i+1)%8))>0;
1296 else if(i==cols_in-1 && j==rows_in-1) {
1300 z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
1310 z1=(ximage->data[j*byte_width_in+i/8] & 128>>(i%8))>0;
1311 z2=(ximage->data[j*byte_width_in+(i+1)/8] & 128>>((i+1)%8))>0;
1312 z3=(ximage->data[(j+1)*byte_width_in+(i+1)/8] &
1314 z4=(ximage->data[(j+1)*byte_width_in+i/8] & 128>>(i%8))>0;
1318 if(((1-t)*(1-u)*z1 + t*(1-u)*z2 + t*u*z3 + (1-t)*u*z4)>0.5)
1319 imageOut->data[j2*byte_width_out+i2/8]|=128>>i2%8;
1327 XDestroyImage(ximage);
1340 char *str1, *str2, *str3;
1341 const char *str2_a=
"\0", *str2_b=
"\n\0";
1343 float sin_angle, cos_angle;
1345 int cols_in, rows_in;
1349 XCharStruct overall;
1352 while(angle<0) angle+=360;
1354 while(angle>360) angle-=360;
1361 for(i=0; i<(
int)strlen(
text)-1; i++)
1367 str2=(
char *)str2_a;
1369 str2=(
char *)str2_b;
1373 if(!str1)
return nullptr;
1375 str3 = my_strtok(str1, str2);
1378 XTextExtents(font, str1, strlen(str1), &dir, &asc, &desc,
1381 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
1385 max_width = overall.rbearing;
1389 str3 = my_strtok(
nullptr, str2);
1392 XTextExtents(font, str3, strlen(str3), &dir, &asc, &desc,
1395 if(overall.rbearing>max_width)
1396 max_width=overall.rbearing;
1403 height=font->ascent+font->descent;
1415 hot_y=(float)rows_in/2*
gRotStyle.fMagnify;
1419 hot_y=-(float)rows_in/2*
gRotStyle.fMagnify;
1421 hot_y=-((float)rows_in/2-(float)font->descent)*
gRotStyle.fMagnify;
1425 hot_x=-(float)max_width/2*
gRotStyle.fMagnify;
1429 hot_x=(float)max_width/2*
gRotStyle.fMagnify;
1433 if(!xp_in)
return nullptr;
1450 xp_in[4].x = xp_in[0].x;
1451 xp_in[4].y = xp_in[0].y;
1454 for(i=0; i<5; i++) {
1455 xp_out[i].x=(
short int)((
float)
x + ( ((
float)xp_in[i].
x-hot_x)*cos_angle +
1456 ((
float)xp_in[i].
y+hot_y)*sin_angle));
1457 xp_out[i].y=(
short int)((
float)
y + (-((
float)xp_in[i].
x-hot_x)*sin_angle +
1458 ((
float)xp_in[i].
y+hot_y)*cos_angle));