… | |
… | |
558 | // find new offset |
558 | // find new offset |
559 | int ox = mat_apply (matrix, 0, x, y); |
559 | int ox = mat_apply (matrix, 0, x, y); |
560 | int oy = mat_apply (matrix, 1, x, y); |
560 | int oy = mat_apply (matrix, 1, x, y); |
561 | |
561 | |
562 | // calculate new pixel bounding box coordinates |
562 | // calculate new pixel bounding box coordinates |
563 | double rmin[2], rmax[2]; |
563 | double d [2], rmin[2], rmax[2]; |
564 | |
564 | |
565 | for (int i = 0; i < 2; ++i) |
565 | for (int i = 0; i < 2; ++i) |
566 | { |
566 | { |
567 | double v; |
567 | double v; |
568 | v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; |
568 | v = mat_apply (matrix, i, 0, 0); rmin [i] = rmax [i] = v; d [i] = v; |
569 | v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v); |
569 | v = mat_apply (matrix, i, w, 0); min_it (rmin [i], v); max_it (rmax [i], v); |
570 | v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v); |
570 | v = mat_apply (matrix, i, 0, h); min_it (rmin [i], v); max_it (rmax [i], v); |
571 | v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v); |
571 | v = mat_apply (matrix, i, w, h); min_it (rmin [i], v); max_it (rmax [i], v); |
572 | } |
572 | } |
573 | |
573 | |
… | |
… | |
578 | int new_height = ceil (rmax [1] - dy); |
578 | int new_height = ceil (rmax [1] - dy); |
579 | |
579 | |
580 | double inv[3][3]; |
580 | double inv[3][3]; |
581 | mat_invert (matrix, inv); |
581 | mat_invert (matrix, inv); |
582 | |
582 | |
583 | rxvt_img *img = new rxvt_img (s, format, ox - dx, oy - dy, new_width, new_height, repeat); |
583 | rxvt_img *img = new rxvt_img (s, format, ox - dx - d [0], oy - dy - d [1], new_width, new_height, repeat); |
584 | img->alloc (); |
584 | img->alloc (); |
585 | |
585 | |
586 | Display *dpy = s->display->dpy; |
586 | Display *dpy = s->display->dpy; |
587 | Picture src = src_picture (); |
587 | Picture src = src_picture (); |
588 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
588 | Picture dst = XRenderCreatePicture (dpy, img->pm, img->format, 0, 0); |
… | |
… | |
631 | { |
631 | { |
632 | double s = sin (phi); |
632 | double s = sin (phi); |
633 | double c = cos (phi); |
633 | double c = cos (phi); |
634 | |
634 | |
635 | double matrix[3][3] = { |
635 | double matrix[3][3] = { |
636 | //{ c, -s, cx - c * cx + s * cy }, |
636 | { c, -s, cx - c * cx + s * cy }, |
637 | //{ s, c, cy - s * cx - c * cy }, |
637 | { s, c, cy - s * cx - c * cy }, |
638 | //{ 0, 0, 1 } |
638 | { 0, 0, 1 } |
639 | { c, -s, 0 }, |
639 | //{ c, -s, 0 }, |
640 | { s, c, 0 }, |
640 | //{ s, c, 0 }, |
641 | { 0, 0, 1 } |
641 | //{ 0, 0, 1 } |
642 | }; |
642 | }; |
643 | |
643 | |
644 | move (-cx, -cy); |
644 | //move (-cx, -cy); |
645 | rxvt_img *img = transform (matrix); |
645 | rxvt_img *img = transform (matrix); |
646 | move ( cx, cy); |
646 | //move ( cx, cy); |
647 | img->move (cx, cy); |
647 | //img->move (cx, cy); |
648 | |
648 | |
649 | return img; |
649 | return img; |
650 | } |
650 | } |
651 | |
651 | |
652 | rxvt_img * |
652 | rxvt_img * |