| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
 100
 101
 102
 103
 104
 105
 106
 107
 108
 109
 110
 111
 112
 113
 114
 115
 116
 117
 118
 119
 120
 121
 122
 123
 124
 125
 126
 127
 128
 129
 130
 131
 132
 133
 134
 135
 136
 137
 138
 139
 140
 141
 142
 143
 144
 145
 146
 147
 148
 149
 150
 151
 152
 153
 154
 155
 156
 157
 158
 159
 160
 161
 162
 163
 164
 165
 166
 167
 168
 169
 170
 171
 172
 173
 174
 175
 176
 177
 178
 179
 180
 181
 182
 183
 184
 185
 186
 187
 188
 189
 190
 191
 192
 193
 194
 195
 196
 197
 198
 199
 200
 201
 202
 203
 204
 205
 206
 207
 208
 209
 210
 211
 212
 213
 214
 215
 216
 217
 218
 219
 220
 221
 222
 223
 224
 225
 226
 227
 228
 229
 230
 231
 232
 233
 234
 235
 236
 237
 238
 239
 240
 241
 242
 
 | /*
 *  Copyright (c) 2005-2006 Cyrille Berger <cberger@cberger.net>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU Library General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Library General Public License for more details.
 *
 *  You should have received a copy of the GNU Library General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */
#ifndef KROSS_KRITACOREKRS_PAINTER_H
#define KROSS_KRITACOREKRS_PAINTER_H
#include <api/class.h>
#include <kis_point.h>
#include <kis_types.h>
#include <kis_paint_layer.h>
class KisPainter;
class KisFillPainter;
namespace Kross {
namespace KritaCore {
class Painter : public Kross::Api::Class<Painter>
{
    public:
        explicit Painter(KisPaintLayerSP layer);
        ~Painter();
    private:
        // Convolution
        /**
         * This function apply a convolution kernel to an image.
         * It takes at least three arguments :
         *  - a list of a list with the kernel (all lists need to have the same size)
         *  - factor
         *  - offset
         * 
         * The value of a pixel will be given by the following function K*P/factor + offset,
         * where K is the kernel and P is the neighbourhood.
         * 
         * It can takes the following optional arguments :
         *  - borderOp control how to convolve the pixels on the border of an image ( 0 use the default color
         * 1 use the pixel on the opposite side of the image 2 use the border pixel 3 avoid border pixels)
         *  - channel ( 1 for color 2 for alpha 3 for both)
         *  - x
         *  - y
         *  - width
         *  - height
         */
        Kross::Api::Object::Ptr convolve(Kross::Api::List::Ptr args);
        // Fill specific
        /**
         * Set the threshold the fill threshold.
         * It takes one argument :
         *  - threshold
         */
        Kross::Api::Object::Ptr setFillThreshold(Kross::Api::List::Ptr args);
        /**
         * Start filling color.
         * It takes two argument :
         *  - x
         *  - y
         */
        Kross::Api::Object::Ptr fillColor(Kross::Api::List::Ptr args);
        /**
         * start filling a pattern
         * It takes two argument :
         *  - x
         *  - y
         */
        Kross::Api::Object::Ptr fillPattern(Kross::Api::List::Ptr args);
        // Painting operations
        /**
         * This function will paint a polyline.
         * It takes two arguments :
         *  - a list of x position
         *  - a list of y position
         */
        Kross::Api::Object::Ptr paintPolyline(Kross::Api::List::Ptr args);
        /**
         * This function will paint a line.
         * It takes five arguments :
         *  - x1
         *  - y1
         *  - x2
         *  - y2
         *  - pressure
         */
        Kross::Api::Object::Ptr paintLine(Kross::Api::List::Ptr args);
        /**
         * This function will paint a Bezier curve.
         * It takes ten arguments :
         *  - x1
         *  - y1
         *  - p1
         *  - cx1
         *  - cy1
         *  - cx2
         *  - cx2
         *  - x2
         *  - y2
         *  - p2
         * 
         * Where (x1,y1) is the start position, p1 is the pressure at the start,
         * (x2,y2) is the ending position, p2 is the pressure at the end. (cx1,cy1) and (cx2,cy2)
         * are the position of the control points.
         */
        Kross::Api::Object::Ptr paintBezierCurve(Kross::Api::List::Ptr args);
        /**
         * This function will paint an ellipse.
         * It takes five arguments :
         *  - x1
         *  - y1
         *  - x2
         *  - y2
         *  - pressure
         * 
         * Where (x1,y1) and (x2,y2) are the position of the two centers.
         */
        Kross::Api::Object::Ptr paintEllipse(Kross::Api::List::Ptr args);
        /**
         * This function will paint a polygon.
         * It takes two arguments :
         *  - a list of x position
         *  - a list of y position
         */
        Kross::Api::Object::Ptr paintPolygon(Kross::Api::List::Ptr args);
        /**
         * This function will paint a rectangle.
         * It takes five arguments :
         *  - x
         *  - y
         *  - width
         *  - height
         *  - pressure
         */
        Kross::Api::Object::Ptr paintRect(Kross::Api::List::Ptr args);
        /**
         * This function will paint at a given position.
         * It takes three arguments :
         *  - x
         *  - y
         *  - pressure
         */
        Kross::Api::Object::Ptr paintAt(Kross::Api::List::Ptr args);
        // Color operations
        /**
         * This functions set the paint color (also called foreground color).
         * It takes one argument :
         *  - a Color
         */
        Kross::Api::Object::Ptr setPaintColor(Kross::Api::List::Ptr args);
        /**
         * This functions set the background color.
         * It takes one argument :
         *  - a Color
         */
        Kross::Api::Object::Ptr setBackgroundColor(Kross::Api::List::Ptr args);
        // How is painting done operations
        /**
         * This functions set the pattern used for filling.
         * It takes one argument :
         *  - a Pattern object
         */
        Kross::Api::Object::Ptr setPattern(Kross::Api::List::Ptr args);
        /**
         * This functions set the brush used for painting.
         * It takes one argument :
         *  - a Brush object
         */
        Kross::Api::Object::Ptr setBrush(Kross::Api::List::Ptr args);
        /**
         * This function define the paint operation.
         * It takes one argument :
         *  - the name of the paint operation
         */
        Kross::Api::Object::Ptr setPaintOp(Kross::Api::List::Ptr args);
        // Special settings
        /**
         * This function define the duplicate offset.
         * It takes two arguments :
         *  - horizontal offset
         *  - vertical offset
         */
        Kross::Api::Object::Ptr setDuplicateOffset(Kross::Api::List::Ptr args);
        // Style operation
        /**
         * This function set the opacity of the painting
         * It takes one argument :
         *  - opacity in the range 0 to 255
         */
        Kross::Api::Object::Ptr setOpacity(Kross::Api::List::Ptr args);
        /**
         * This function set the style of the stroke.
         * It takes one argument :
         *  - 0 for none 1 for brush
         */
        Kross::Api::Object::Ptr setStrokeStyle(Kross::Api::List::Ptr args);
        /**
         * This function set the fill style of the Painter.
         * It takes one argument :
         *  - 0 for none 1 for fill with foreground color 2 for fill with background color
         * 3 for fill with a pattern
         */
        Kross::Api::Object::Ptr setFillStyle(Kross::Api::List::Ptr args);
    protected:
        inline KisPaintLayerSP paintLayer() { return m_layer; }
    private:
        inline vKisPoint createPointsVector( QValueList<QVariant> xs, QValueList<QVariant> ys)
        {
            vKisPoint a;
            QValueList<QVariant>::iterator itx = xs.begin();
            QValueList<QVariant>::iterator ity = ys.begin();
            for(; itx != xs.end(); ++itx, ++ity)
            {
                a.push_back(KisPoint( (*itx).toDouble(), (*ity).toDouble()));
            }
            return a;
        }
        inline KisFillPainter* createFillPainter();
    private:
        KisPaintLayerSP m_layer;
        KisPainter* m_painter;
        int m_threshold;
};
}
}
#endif
 |