00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __GRADIENT_LOADER__
00021 #define __GRADIENT_LOADER__
00022
00023 #include <q3ptrlist.h>
00024 #include <QString>
00025 #include <QStringList>
00026 #include <QFile>
00027 #include <qdom.h>
00028 #include <QColor>
00029 #include <koffice_export.h>
00030 struct KoColorStop
00031 {
00032 double offset;
00033 double midpoint;
00034 double opacity;
00035 double color1;
00036 double color2;
00037 double color3;
00038 double color4;
00039 int colorType;
00040 int interpolation;
00041 };
00042
00043 struct KoGradient
00044 {
00045 double originX;
00046 double originY;
00047 double vectorX;
00048 double vectorY;
00049 double focalpointX;
00050 double focalpointY;
00051 int gradientType;
00052 int gradientRepeatMethod;
00053
00054 Q3PtrList<KoColorStop> colorStops;
00055 };
00056
00057 class KOPAINTER_EXPORT KoGradientManager
00058 {
00059 public:
00060
00061 enum KoGradientType
00062 {
00063 gradient_type_linear = 0,
00064 gradient_type_radial = 1,
00065 gradient_type_conic = 2
00066 };
00067
00068 enum KoGradientInterpolation
00069 {
00070 interpolation_linear = 0,
00071 interpolation_curved = 1,
00072 interpolation_sine = 2,
00073 interpolation_sphere_increasing = 3,
00074 interpolation_sphere_decreasing = 4
00075 };
00076
00077 enum KoGradientColorType
00078 {
00079 color_type_rgb = 0,
00080 color_type_hsv_ccw = 1,
00081 color_type_hsv_cw = 2,
00082 color_type_gray = 3,
00083 color_type_cmyk = 4
00084 };
00085
00086 enum KoGradientRepeatMethod
00087 {
00088 repeat_method_none = 0,
00089 repeat_method_reflect = 1,
00090 repeat_method_repeat = 2
00091 };
00092
00093 KoGradientManager();
00094 ~KoGradientManager();
00095
00096 KoGradient* loadGradient(const QString& filename);
00097 static QStringList filters()
00098 {
00099 QStringList filterList;
00100 filterList << "*.kgr" << "*.svg" << "*.ggr";
00101 return filterList;
00102 }
00103
00104 private:
00105 KoGradient* loadKarbonGradient(QFile* file);
00106 KoGradient* loadKritaGradient(QFile* file);
00107 KoGradient* loadSvgGradient(QFile* file);
00108 KoGradient* parseKarbonGradient(const QDomElement& element);
00109 KoGradient* parseSvgGradient(const QDomElement& element);
00110 void parseSvgColor(QColor &color, const QString &s);
00111 };
00112
00113 #endif
00114
00115