KHTML
AffineTransform.h
Go to the documentation of this file.
00001 /* 00002 * Copyright (C) 2005, 2006 Apple Computer, Inc. All rights reserved. 00003 * 00004 * Redistribution and use in source and binary forms, with or without 00005 * modification, are permitted provided that the following conditions 00006 * are met: 00007 * 1. Redistributions of source code must retain the above copyright 00008 * notice, this list of conditions and the following disclaimer. 00009 * 2. Redistributions in binary form must reproduce the above copyright 00010 * notice, this list of conditions and the following disclaimer in the 00011 * documentation and/or other materials provided with the distribution. 00012 * 00013 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 00014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 00015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 00017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 00018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 00019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 00020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 00021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 */ 00025 00026 #ifndef AffineTransform_h 00027 #define AffineTransform_h 00028 00029 #if PLATFORM(CG) 00030 #include <CoreGraphics/CGAffineTransform.h> 00031 #elif PLATFORM(QT) 00032 #include <QMatrix> 00033 #elif PLATFORM(CAIRO) 00034 #include <cairo.h> 00035 #elif PLATFORM(WX) && USE(WXGC) 00036 #include <wx/defs.h> 00037 #include <wx/graphics.h> 00038 #endif 00039 00040 namespace WebCore { 00041 00042 class IntPoint; 00043 class IntRect; 00044 class FloatPoint; 00045 class FloatRect; 00046 00047 class AffineTransform { 00048 public: 00049 AffineTransform(); 00050 AffineTransform(double a, double b, double c, double d, double e, double f); 00051 #if PLATFORM(CG) 00052 AffineTransform(CGAffineTransform transform); 00053 #elif PLATFORM(QT) 00054 AffineTransform(const QMatrix &matrix); 00055 #elif PLATFORM(CAIRO) 00056 AffineTransform(const cairo_matrix_t &matrix); 00057 #elif PLATFORM(WX) && USE(WXGC) 00058 AffineTransform(const wxGraphicsMatrix &matrix); 00059 #endif 00060 00061 void setMatrix(double a, double b, double c, double d, double e, double f); 00062 void map(double x, double y, double *x2, double *y2) const; 00063 IntPoint mapPoint(const IntPoint&) const; 00064 FloatPoint mapPoint(const FloatPoint&) const; 00065 IntRect mapRect(const IntRect&) const; 00066 FloatRect mapRect(const FloatRect&) const; 00067 00068 bool isIdentity() const; 00069 00070 double a() const; 00071 void setA(double a); 00072 00073 double b() const; 00074 void setB(double b); 00075 00076 double c() const; 00077 void setC(double c); 00078 00079 double d() const; 00080 void setD(double d); 00081 00082 double e() const; 00083 void setE(double e); 00084 00085 double f() const; 00086 void setF(double f); 00087 00088 void reset(); 00089 00090 AffineTransform& multiply(const AffineTransform&); 00091 AffineTransform& scale(double); 00092 AffineTransform& scale(double sx, double sy); 00093 AffineTransform& scaleNonUniform(double sx, double sy); 00094 AffineTransform& rotate(double d); 00095 AffineTransform& rotateFromVector(double x, double y); 00096 AffineTransform& translate(double tx, double ty); 00097 AffineTransform& shear(double sx, double sy); 00098 AffineTransform& flipX(); 00099 AffineTransform& flipY(); 00100 AffineTransform& skew(double angleX, double angleY); 00101 AffineTransform& skewX(double angle); 00102 AffineTransform& skewY(double angle); 00103 00104 double det() const; 00105 bool isInvertible() const; 00106 AffineTransform inverse() const; 00107 00108 #if PLATFORM(CG) 00109 operator CGAffineTransform() const; 00110 #elif PLATFORM(QT) 00111 operator QMatrix() const; 00112 #elif PLATFORM(CAIRO) 00113 operator cairo_matrix_t() const; 00114 #elif PLATFORM(WX) && USE(WXGC) 00115 operator wxGraphicsMatrix() const; 00116 #endif 00117 00118 bool operator==(const AffineTransform&) const; 00119 bool operator!=(const AffineTransform& other) const { return !(*this == other); } 00120 AffineTransform& operator*=(const AffineTransform&); 00121 AffineTransform operator*(const AffineTransform&); 00122 00123 private: 00124 #if PLATFORM(CG) 00125 CGAffineTransform m_transform; 00126 #elif PLATFORM(QT) 00127 QMatrix m_transform; 00128 #elif PLATFORM(CAIRO) 00129 cairo_matrix_t m_transform; 00130 #elif PLATFORM(WX) && USE(WXGC) 00131 wxGraphicsMatrix m_transform; 00132 #endif 00133 }; 00134 00135 } // namespace WebCore 00136 00137 #endif // AffineTransform_h
KDE 4.6 API Reference