3 * Copyright (C) 1997-2014 Adam Williams <broadcast at earthling dot net>
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #ifndef __SKETCHERS_H__
24 #define __SKETCHERS_H__
26 #include "pluginvclient.h"
30 enum { PT_ID, PT_X, PT_Y, PT_SZ };
31 enum { CV_ID, CV_TY, CV_RAD, CV_PEN, CV_CLR, CV_SZ };
32 enum { TYP_OFF, TYP_SKETCHER, TYP_SMOOTH, TYP_SZ };
33 enum { PEN_SQUARE, PEN_PLUS, PEN_SLANT, PEN_XLANT, PEN_SZ };
35 class SketcherVPen : public VFrame
38 SketcherVPen(VFrame *vfrm, int n)
39 : VFrame(vfrm->get_data(), -1, vfrm->get_y()-vfrm->get_data(),
40 vfrm->get_u()-vfrm->get_data(), vfrm->get_v()-vfrm->get_data(),
41 vfrm->get_w(), vfrm->get_h(), vfrm->get_color_model(),
42 vfrm->get_bytes_per_line()) {
43 this->vfrm = vfrm; this->n = n;
45 virtual int draw_pixel(int x, int y) = 0;
50 class SketcherPenSquare : public SketcherVPen
53 SketcherPenSquare(VFrame *vfrm, int n) : SketcherVPen(vfrm, n) {}
54 int draw_pixel(int x, int y);
56 class SketcherPenPlus : public SketcherVPen
59 SketcherPenPlus(VFrame *vfrm, int n) : SketcherVPen(vfrm, n) {}
60 int draw_pixel(int x, int y);
62 class SketcherPenSlant : public SketcherVPen
65 SketcherPenSlant(VFrame *vfrm, int n) : SketcherVPen(vfrm, n) {}
66 int draw_pixel(int x, int y);
68 class SketcherPenXlant : public SketcherVPen
71 SketcherPenXlant(VFrame *vfrm, int n) : SketcherVPen(vfrm, n) {}
72 int draw_pixel(int x, int y);
82 void init(int id, int x, int y);
83 SketcherPoint(int id, int x, int y);
84 SketcherPoint(int id=-1);
85 SketcherPoint(SketcherPoint &pt);
87 int equivalent(SketcherPoint &that);
88 void copy_from(SketcherPoint &that);
89 void save_data(FileXML &output);
90 void read_data(FileXML &input);
92 class SketcherPoints : public ArrayList<SketcherPoint *>
96 ~SketcherPoints() { remove_all_objects(); }
100 #define cv_type SketcherCurve::types
101 #define cv_pen SketcherCurve::pens
106 int id, ty, radius, pen, color;
107 static const char *types[TYP_SZ];
108 static const char *pens[PEN_SZ];
110 SketcherPoints points;
112 void init(int id, int ty, int radius, int pen, int color);
113 SketcherCurve(int id, int ty, int radius, int pen, int color);
114 SketcherCurve(int id=-1);
116 SketcherCurve(SketcherCurve &cv);
117 int equivalent(SketcherCurve &that);
118 void copy_from(SketcherCurve &that);
119 void save_data(FileXML &output);
120 void read_data(FileXML &input);
121 VFrame *new_vpen(VFrame *out);
122 void draw_line(VFrame *out);
123 void draw_smooth(VFrame *out);
125 class SketcherCurves : public ArrayList<SketcherCurve *>
129 ~SketcherCurves() { remove_all_objects(); }
139 SketcherCurves curves;
140 int equivalent(SketcherConfig &that);
141 void copy_from(SketcherConfig &that);
142 void interpolate(SketcherConfig &prev, SketcherConfig &next,
143 long prev_frame, long next_frame, long current_frame);
147 int cv_selected, pt_selected;
150 class Sketcher : public PluginVClient
153 Sketcher(PluginServer *server);
155 // required for all realtime plugins
156 PLUGIN_CLASS_MEMBERS2(SketcherConfig)
159 void save_data(KeyFrame *keyframe);
160 void read_data(KeyFrame *keyframe);
161 int new_curve(int ty, int radius, int pen, int color);
163 int new_point(SketcherCurve *cv, int x, int y);
165 int process_realtime(VFrame *input, VFrame *output);
166 static void draw_point(VFrame *vfrm, SketcherPoint *pt, int color, int d);
167 void draw_point(VFrame *vfrm, SketcherPoint *pt, int color);
169 VFrame *input, *output;
170 int w, h, color_model, bpp, comp;
171 int is_yuv, is_float;