lib

kogradientmanager.h
1/* This file is part of the KDE project
2 Copyright (C) 2005 Tim Beaulen <tbscope@gmail.org>
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef __GRADIENT_LOADER__
21#define __GRADIENT_LOADER__
22
23#include <tqptrlist.h>
24#include <tqstring.h>
25#include <tqstringlist.h>
26#include <tqfile.h>
27#include <tqdom.h>
28#include <tqcolor.h>
29#include <koffice_export.h>
30struct KoColorStop
31{
32 double offset;
33 double midpoint;
34 double opacity;
35 double color1;
36 double color2;
37 double color3;
38 double color4;
39 int colorType;
40 int interpolation;
41};
42
43struct KoGradient
44{
45 double originX;
46 double originY;
47 double vectorX;
48 double vectorY;
49 double focalpointX;
50 double focalpointY;
51 int gradientType;
52 int gradientRepeatMethod;
53
54 TQPtrList<KoColorStop> colorStops;
55};
56
57class KOPAINTER_EXPORT KoGradientManager
58{
59public:
60
61 enum KoGradientType
62 {
63 gradient_type_linear = 0,
64 gradient_type_radial = 1,
65 gradient_type_conic = 2
66 };
67
68 enum KoGradientInterpolation
69 {
70 interpolation_linear = 0,
71 interpolation_curved = 1,
72 interpolation_sine = 2,
73 interpolation_sphere_increasing = 3,
74 interpolation_sphere_decreasing = 4
75 };
76
77 enum KoGradientColorType
78 {
79 color_type_rgb = 0,
80 color_type_hsv_ccw = 1,
81 color_type_hsv_cw = 2,
82 color_type_gray = 3,
83 color_type_cmyk = 4
84 };
85
86 enum KoGradientRepeatMethod
87 {
88 repeat_method_none = 0,
89 repeat_method_reflect = 1,
90 repeat_method_repeat = 2
91 };
92
93 KoGradientManager();
94 ~KoGradientManager();
95
96 KoGradient* loadGradient(const TQString& filename);
97 static TQStringList filters()
98 {
99 TQStringList filterList;
100 filterList << "*.kgr" << "*.svg" << "*.ggr";
101 return filterList;
102 }
103
104private:
105 KoGradient* loadKarbonGradient(TQFile* file);
106 KoGradient* loadChalkGradient(TQFile* file);
107 KoGradient* loadSvgGradient(TQFile* file);
108 KoGradient* parseKarbonGradient(const TQDomElement& element);
109 KoGradient* parseSvgGradient(const TQDomElement& element);
110 void parseSvgColor(TQColor &color, const TQString &s);
111};
112
113#endif
114
115