transform.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. Copyright 1993, 1998 The Open Group
  3. Permission to use, copy, modify, distribute, and sell this software and its
  4. documentation for any purpose is hereby granted without fee, provided that
  5. the above copyright notice appear in all copies and that both that
  6. copyright notice and this permission notice appear in supporting
  7. documentation.
  8. The above copyright notice and this permission notice shall be included
  9. in all copies or substantial portions of the Software.
  10. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  11. OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  12. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  13. IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
  14. OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  15. ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  16. OTHER DEALINGS IN THE SOFTWARE.
  17. Except as contained in this notice, the name of The Open Group shall
  18. not be used in advertising or otherwise to promote the sale, use or
  19. other dealings in this Software without prior written authorization
  20. from The Open Group.
  21. */
  22. /*
  23. * header file for transformed coordinate system. No rotations
  24. * supported, as elipses cannot be rotated in X.
  25. */
  26. typedef struct _transform {
  27. double mx, bx;
  28. double my, by;
  29. } Transform;
  30. typedef struct _TPoint {
  31. double x, y;
  32. } TPoint;
  33. typedef struct _TRectangle {
  34. double x, y, width, height;
  35. } TRectangle;
  36. # define Xx(x,y,t) ((int)((t)->mx * (x) + (t)->bx + 0.5))
  37. # define Xy(x,y,t) ((int)((t)->my * (y) + (t)->by + 0.5))
  38. # define Xwidth(w,h,t) ((int)((t)->mx * (w) + 0.5))
  39. # define Xheight(w,h,t) ((int)((t)->my * (h) + 0.5))
  40. # define Tx(x,y,t) ((((double) (x)) - (t)->bx) / (t)->mx)
  41. # define Ty(x,y,t) ((((double) (y)) - (t)->by) / (t)->my)
  42. # define Twidth(w,h,t) (((double) (w)) / (t)->mx)
  43. # define Theight(w,h,t) (((double) (h)) / (t)->my)
  44. extern void TFillPolygon ( Display *dpy, Drawable d, GC gc, Transform *t,
  45. TPoint *points, int n_points, int shape, int mode );
  46. extern void TDrawArc ( Display *dpy, Drawable d, GC gc, Transform *t,
  47. double x, double y, double width, double height,
  48. int angle1, int angle2 );
  49. extern void TFillArc ( Display *dpy, Drawable d, GC gc, Transform *t,
  50. double x, double y, double width, double height,
  51. int angle1, int angle2 );
  52. extern void SetTransform ( Transform *t, int xx1, int xx2, int xy1, int xy2,
  53. double tx1, double tx2, double ty1, double ty2 );