3 * Copyright (C) 1997-2015 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
26 #include "arraylist.h"
27 #include "bccmodels.h"
30 #include "edlsession.h"
32 #include "overlayframe.h"
33 #include "pluginserver.h"
34 #include "preferences.h"
36 #include "sketcherwindow.h"
40 void SketcherPoint::init(int id, int arc, coord x, coord y)
42 this->id = id; this->arc = arc;
43 this->x = x; this->y = y;
45 SketcherPoint::SketcherPoint(int id)
47 init(id, ARC_LINE, 0, 0);
49 SketcherPoint::SketcherPoint(int id, int arc, coord x, coord y)
53 SketcherPoint::~SketcherPoint()
56 SketcherPoint::SketcherPoint(SketcherPoint &pt)
60 int SketcherPoint::equivalent(SketcherPoint &that)
62 return this->id == that.id &&
63 this->arc == that.arc &&
64 EQUIV(this->x, that.x) &&
65 EQUIV(this->y, that.y) ? 1 : 0;
67 void SketcherPoint::copy_from(SketcherPoint &that)
69 this->id = that.id; this->arc = that.arc;
70 this->x = that.x; this->y = that.y;
72 void SketcherPoint::save_data(FileXML &output)
75 sprintf(point,"/POINT_%d",id);
76 output.tag.set_title(point+1);
77 output.tag.set_property("TYPE", arc);
78 output.tag.set_property("X", x);
79 output.tag.set_property("Y", y);
81 output.tag.set_title(point+0);
83 output.append_newline();
85 void SketcherPoint::read_data(FileXML &input)
87 id = atoi(input.tag.get_title() + 6);
88 arc = input.tag.get_property("TYPE", ARC_OFF);
89 x = input.tag.get_property("X", (coord)0);
90 y = input.tag.get_property("Y", (coord)0);
91 bclamp(arc, 0, ARC_SZ-1);
94 void SketcherCurve::init(int id, int pen, int width, int color)
101 SketcherCurve::SketcherCurve(int id)
103 init(id, 1, PEN_SQUARE, CV_COLOR);
105 SketcherCurve::SketcherCurve(int id, int pen, int width, int color)
107 init(id, pen, width, color);
109 SketcherCurve::~SketcherCurve()
112 SketcherCurve::SketcherCurve(SketcherCurve &cv)
116 int SketcherCurve::equivalent(SketcherCurve &that)
118 if( this->id != that.id ) return 0;
119 if( this->pen != that.pen ) return 0;
120 if( this->width != that.width ) return 0;
121 if( this->color != that.color ) return 0;
122 int n = this->points.size();
123 if( n != that.points.size() ) return 0;
124 for( int i=0; i<n; ++i ) {
125 if( !points[i]->equivalent(*that.points[i]) ) return 0;
129 void SketcherCurve::copy_from(SketcherCurve &that)
132 this->pen = that.pen;
133 this->width = that.width;
134 this->color = that.color;
135 int m = points.size(), n = that.points.size();
136 while( m > n ) points.remove_object_number(--m);
137 while( m < n ) { points.append(new SketcherPoint()); ++m; }
138 for( int i=0; i<n; ++i ) points[i]->copy_from(*that.points[i]);
140 void SketcherCurve::save_data(FileXML &output)
142 char curve[BCSTRLEN];
143 sprintf(curve,"/CURVE_%d",id);
144 output.tag.set_title(curve+1);
145 output.tag.set_property("PEN", pen);
146 output.tag.set_property("RADIUS", width);
147 output.tag.set_property("COLOR", color);
149 output.append_newline();
150 for( int i=0,n=points.size(); i<n; ++i )
151 points[i]->save_data(output);
152 output.tag.set_title(curve+0);
154 output.append_newline();
156 void SketcherCurve::read_data(FileXML &input)
158 id = atoi(input.tag.get_title() + 6);
159 pen = input.tag.get_property("PEN", PEN_OFF);
160 width = input.tag.get_property("RADIUS", 1.);
161 color = input.tag.get_property("COLOR", CV_COLOR);
162 bclamp(pen, 0, PEN_SZ-1);
165 int Sketcher::new_curve(int pen, int width, int color)
167 SketcherCurves &curves = config.curves;
168 int k = curves.size(), id = 1;
169 for( int i=k; --i>=0; ) {
170 int n = config.curves[i]->id;
171 if( n >= id ) id = n + 1;
173 SketcherCurve *cv = new SketcherCurve(id, pen, width, color);
175 config.cv_selected = k;
179 int Sketcher::new_curve()
181 return new_curve(PEN_XLANT, 1, CV_COLOR);
184 int Sketcher::new_point(SketcherCurve *cv, int arc, coord x, coord y, int idx)
187 for( int i=cv->points.size(); --i>=0; ) {
188 int n = cv->points[i]->id;
189 if( n >= id ) id = n + 1;
191 SketcherPoint *pt = new SketcherPoint(id, arc, x, y);
192 int n = cv->points.size();
193 if( idx < 0 || idx > n ) idx = n;
194 cv->points.insert(pt, idx);
198 int Sketcher::new_point(int idx, int arc)
200 int ci = config.cv_selected;
201 if( ci < 0 || ci >= config.curves.size() )
203 SketcherCurve *cv = config.curves[ci];
204 EDLSession *session = get_edlsession();
205 coord x = !session ? 0.f : session->output_w / 2.f;
206 coord y = !session ? 0.f : session->output_h / 2.f;
207 return new_point(cv, arc, x, y, idx);
210 double SketcherCurve::nearest_point(int &pi, coord x, coord y)
213 double dist = DBL_MAX;
214 for( int i=0; i<points.size(); ++i ) {
215 SketcherPoint *p = points[i];
216 double d = DISTANCE(x,y, p->x,p->y);
217 if( d < dist ) { dist = d; pi = i; }
219 return pi >= 0 ? dist : -1.;
222 double SketcherConfig::nearest_point(int &ci, int &pi, coord x, coord y)
224 double dist = DBL_MAX;
226 for( int i=0; i<curves.size(); ++i ) {
227 SketcherCurve *crv = curves[i];
228 SketcherPoints &points = crv->points;
229 for( int k=0; k<points.size(); ++k ) {
230 SketcherPoint *p = points[k];
231 double d = DISTANCE(x,y, p->x,p->y);
232 if( d < dist ) { dist = d; ci = i; pi = k; }
235 return pi >= 0 ? dist : -1.;
239 REGISTER_PLUGIN(Sketcher)
241 SketcherConfig::SketcherConfig()
247 SketcherConfig::~SketcherConfig()
251 int SketcherConfig::equivalent(SketcherConfig &that)
253 if( this->drag != that.drag ) return 0;
254 if( this->cv_selected != that.cv_selected ) return 0;
255 if( this->pt_selected != that.pt_selected ) return 0;
256 if( this->curves.size() != that.curves.size() ) return 0;
257 for( int i=0, n=curves.size(); i<n; ++i ) {
258 if( !curves[i]->equivalent(*that.curves[i]) ) return 0;
263 void SketcherConfig::copy_from(SketcherConfig &that)
265 this->drag = that.drag;
266 this->cv_selected = that.cv_selected;
267 this->pt_selected = that.pt_selected;
268 int m = curves.size(), n = that.curves.size();
269 while( m > n ) curves.remove_object_number(--m);
270 while( m < n ) { curves.append(new SketcherCurve()); ++m; }
271 for( int i=0; i<n; ++i ) curves[i]->copy_from(*that.curves[i]);
274 void SketcherConfig::interpolate(SketcherConfig &prev, SketcherConfig &next,
275 long prev_frame, long next_frame, long current_frame)
277 this->cv_selected = prev.cv_selected;
278 this->pt_selected = prev.pt_selected;
279 this->drag = prev.drag;
281 double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
282 double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
284 curves.remove_all_objects();
285 int prev_cv_sz = prev.curves.size();
286 int next_cv_sz = next.curves.size();
287 for( int i=0; i<prev_cv_sz; ++i ) {
288 SketcherCurve *pcv = prev.curves[i], *ncv = 0;
289 SketcherCurve *cv = curves.append(new SketcherCurve());
290 int k = next_cv_sz; // associated by id in next
291 while( --k >= 0 && pcv->id != (ncv=next.curves[k])->id );
295 cv->width = pcv->width == ncv->width ? pcv->width :
296 pcv->width*prev_scale + ncv->width*next_scale + 0.5;
297 int pr = (pcv->color>>16)&0xff, nr = (ncv->color>>16)&0xff;
298 int pg = (pcv->color>> 8)&0xff, ng = (ncv->color>> 8)&0xff;
299 int pb = (pcv->color>> 0)&0xff, nb = (ncv->color>> 0)&0xff;
300 int pa = (~pcv->color>>24)&0xff, na = (~ncv->color>>24)&0xff;
301 int r = pr == nr ? pr : pr*prev_scale + nr*next_scale + 0.5;
302 int g = pg == ng ? pg : pg*prev_scale + ng*next_scale + 0.5;
303 int b = pb == nb ? pb : pb*prev_scale + nb*next_scale + 0.5;
304 int a = pa == na ? pa : pa*prev_scale + na*next_scale + 0.5;
305 bclamp(r,0,255); bclamp(g,0,255); bclamp(b,0,255); bclamp(a,0,255);
306 cv->color = (~a<<24) | (r<<16) | (g<<8) | (b<<0);
307 int prev_pt_sz = pcv->points.size(), next_pt_sz = ncv->points.size();
308 for( int j=0; j<prev_pt_sz; ++j ) {
309 SketcherPoint &pt = *pcv->points[j], *nt = 0;
310 k = next_pt_sz; // associated by id in next
311 while( --k >= 0 && pt.id != (nt=ncv->points[k])->id );
312 coord x = pt.x, y = pt.y;
315 x = x * prev_scale + nt->x * next_scale;
317 y = y * prev_scale + nt->y * next_scale;
319 cv->points.append(new SketcherPoint(pt.id, pt.arc, x, y));
327 void SketcherConfig::limits()
332 Sketcher::Sketcher(PluginServer *server)
333 : PluginVClient(server)
340 Sketcher::~Sketcher()
344 delete overlay_frame;
347 const char* Sketcher::plugin_title() { return N_("Sketcher"); }
348 int Sketcher::is_realtime() { return 1; }
349 int Sketcher::is_synthesis() { return 1; }
351 NEW_WINDOW_MACRO(Sketcher, SketcherWindow);
352 LOAD_CONFIGURATION_MACRO(Sketcher, SketcherConfig)
354 void Sketcher::save_data(KeyFrame *keyframe)
357 // cause data to be stored directly in text
358 output.set_shared_output(keyframe->xbuf);
360 output.tag.set_title("SKETCHER");
361 output.tag.set_property("DRAG", config.drag);
362 output.tag.set_property("CV_SELECTED", config.cv_selected);
363 output.tag.set_property("PT_SELECTED", config.pt_selected);
365 output.append_newline();
366 for( int i=0,n=config.curves.size(); i<n; ++i ) {
367 config.curves[i]->save_data(output);
369 output.tag.set_title("/SKETCHER");
371 output.append_newline();
372 output.terminate_string();
375 void Sketcher::read_data(KeyFrame *keyframe)
378 input.set_shared_input(keyframe->xbuf);
379 config.curves.remove_all_objects();
381 SketcherCurve *cv = 0;
383 while( !(result=input.read_tag()) ) {
384 if( input.tag.title_is("SKETCHER") ) {
385 config.drag = input.tag.get_property("DRAG", config.drag);
386 config.cv_selected = input.tag.get_property("CV_SELECTED", 0);
387 config.pt_selected = input.tag.get_property("PT_SELECTED", 0);
389 else if( !strncmp(input.tag.get_title(),"CURVE_",6) ) {
390 cv = new SketcherCurve();
391 cv->read_data(input);
392 config.curves.append(cv);
394 else if( !strncmp(input.tag.get_title(),"/CURVE_",7) )
396 else if( !strncmp(input.tag.get_title(),"POINT_",6) ) {
398 SketcherPoint *pt = new SketcherPoint();
399 pt->read_data(input);
400 cv->points.append(pt);
403 printf("Sketcher::read_data: no curve for point\n");
407 if( !config.curves.size() )
412 void Sketcher::update_gui()
414 if( !thread ) return;
415 thread->window->lock_window("Sketcher::update_gui");
416 if( load_configuration() ) {
417 SketcherWindow *window = (SketcherWindow*)thread->window;
418 window->update_gui();
421 thread->window->unlock_window();
424 void Sketcher::draw_point(VFrame *vfrm, SketcherPoint *pt, int color, int d)
426 int r = d/2+1, x = pt->x, y = pt->y;
427 vfrm->set_pixel_color(color);
428 vfrm->draw_smooth(x-r,y+0, x-r, y-r, x+0,y-r);
429 vfrm->draw_smooth(x+0,y-r, x+r, y-r, x+r,y+0);
430 vfrm->draw_smooth(x+r,y+0, x+r, y+r, x+0,y+r);
431 vfrm->draw_smooth(x+0,y+r, x-r, y+r, x-r,y+0);
432 vfrm->draw_x(pt->x, pt->y, d);
434 void Sketcher::draw_point(VFrame *vfrm, SketcherPoint *pt, int color)
436 draw_point(vfrm, pt, color, bmax(w,h)/200 + 2);
440 int SketcherVPen::draw_pixel(int x, int y)
442 if( x >= 0 && x < vfrm->get_w() &&
443 y >= 0 && y < vfrm->get_h() )
444 msk[vfrm->get_w()*y + x] = 0xff;
448 int SketcherPenSquare::draw_pixel(int x, int y)
450 vfrm->draw_line(x-n, y, x+n, y);
451 for( int i=-n; i<n; ++i )
452 vfrm->draw_line(x-n, y+i, x+n, y+i);
453 return SketcherVPen::draw_pixel(x, y);
455 int SketcherPenPlus::draw_pixel(int x, int y)
458 vfrm->draw_line(x-n, y, x+n, y);
459 vfrm->draw_line(x, y-n, x, y+n);
462 vfrm->draw_pixel(x, y);
463 return SketcherVPen::draw_pixel(x, y);
465 int SketcherPenSlant::draw_pixel(int x, int y)
467 vfrm->draw_line(x-n, y+n, x+n, y-n);
468 vfrm->draw_line(x-n+1, y+n, x+n+1, y-n);
469 vfrm->draw_line(x-n, y+n+1, x+n, y-n+1);
470 return SketcherVPen::draw_pixel(x, y);
472 int SketcherPenXlant::draw_pixel(int x, int y)
474 vfrm->draw_line(x-n, y+n, x+n, y-n);
475 vfrm->draw_line(x-n+1, y+n, x+n+1, y-n);
476 vfrm->draw_line(x-n, y+n+1, x+n, y-n+1);
477 vfrm->draw_line(x-n, y-n, x+n, y+n);
478 vfrm->draw_line(x-n+1, y-n, x+n+1, y+n);
479 vfrm->draw_line(x-n, y-n+1, x+n, y-n+1);
480 return SketcherVPen::draw_pixel(x, y);
484 SketcherVPen *SketcherCurve::new_vpen(VFrame *out)
487 case PEN_SQUARE: return new SketcherPenSquare(out, width);
488 case PEN_PLUS: return new SketcherPenPlus(out, width);
489 case PEN_SLANT: return new SketcherPenSlant(out, width);
490 case PEN_XLANT: return new SketcherPenXlant(out, width);
495 static int intersects_at(float &x, float &y,
496 float ax,float ay, float bx, float by, float cx,float cy, // line slope ab thru c
497 float dx,float dy, float ex, float ey, float fx,float fy, // line slope de thru f
500 float badx = bx - ax, bady = by - ay;
501 float eddx = ex - dx, eddy = ey - dy;
502 float d = badx*eddy - bady*eddx;
504 if( fabsf(d) < 1 ) { ret = 1; d = signbit(d) ? -1 : 1; }
505 x = (badx*cy*eddx - badx*eddx*fy + badx*eddy*fx - bady*cx*eddx) / d;
506 y = (badx*cy*eddy - bady*cx*eddy - bady*eddx*fy + bady*eddy*fx) / d;
507 if( mx > 0 ) { bclamp(x, -mx,mx); bclamp(y, -mx,mx); }
511 static void smooth_axy(float &ax, float &ay,
512 float bx, float by, float cx, float cy, float dx, float dy)
514 //middle of bd reflected around ctr
515 // point ctr = (b+d)/2, dv=c-ctr, a=ctr-dv;
516 float xc = (bx+dx)*.5f, yc = (by+dy)*.5f;
517 float xd = cx - xc, yd = cy - yc;
518 ax = xc - xd; ay = yc - yd;
520 static void smooth_dxy(float &dx, float &dy,
521 float ax, float ay, float bx, float by, float cx, float cy)
523 //middle of ac reflected around ctr
524 // point ctr = (a+c)/2, dv=c-ctr, d=ctr-dv;
525 float xc = (ax+cx)*.5f, yc = (ay+cy)*.5f;
526 float xd = bx - xc, yd = by - yc;
527 dx = xc - xd; dy = yc - yd;
530 static int convex(float ax,float ay, float bx,float by,
531 float cx,float cy, float dx,float dy)
533 float abdx = bx-ax, abdy = by-ay;
534 float acdx = cx-ax, acdy = cy-ay;
535 float bcdx = cx-bx, bcdy = cy-by;
536 float bddx = dx-bx, bddy = dy-by;
537 float abc = abdx*acdy - abdy*acdx;
538 float bcd = bcdx*bddy - bcdy*bddx;
540 return !v ? 0 : v>0 ? 1 : -1;
545 class segment { public: int y, lt, rt; };
546 ArrayList<segment> stack;
548 void push(int y, int lt, int rt) {
549 segment &seg = stack.append();
550 seg.y = y; seg.lt = lt; seg.rt = rt;
552 void pop(int &y, int <, int &rt) {
553 segment &seg = stack.last();
554 y = seg.y; lt = seg.lt; rt = seg.rt;
561 SketcherPoints &points;
563 SketcherPoint *next();
564 bool exists() { return stack.size() > 0; }
565 void start_at(int x, int y);
567 FillRegion(SketcherPoints &pts, SketcherVPen *vpen);
571 FillRegion::FillRegion(SketcherPoints &pts, SketcherVPen *vpen)
574 this->img = vpen->vfrm;
575 this->msk = vpen->msk;
576 this->w = img->get_w();
577 this->h = img->get_h();
580 FillRegion::~FillRegion()
584 void FillRegion::start_at(int x, int y)
591 void FillRegion::run()
593 while( stack.size() > 0 ) {
597 for( int x=ilt; x<=irt; ++x,++ofs ) {
598 if( msk[ofs] ) continue;
600 img->draw_pixel(x, y);
603 for( int i=lt; --i>=0; ) {
604 if( msk[--lofs] ) break;
605 img->draw_pixel(i, y);
606 msk[lofs] = 0xff; lt = i;
609 for( int i=rt; ++i< w; ) {
610 if( msk[++rofs] ) break;
611 img->draw_pixel(i, y);
612 msk[rofs] = 0xff; rt = i;
614 if( y+1 < h ) push(y+1, lt, rt);
615 if( y-1 >= 0 ) push(y-1, lt, rt);
620 SketcherPoint *FillRegion::next()
622 while( nxt < points.size() ) {
623 SketcherPoint *pt = points[nxt++];
624 if( pt->arc == ARC_OFF ) continue;
625 if( pt->arc != ARC_FILL ) return pt;
626 start_at(pt->x, pt->y);
632 void SketcherCurve::draw(VFrame *img)
634 if( !points.size() ) return;
635 const float fmx = 16383;
636 SketcherVPen *vpen = new_vpen(img);
637 FillRegion fill(points, vpen);
638 SketcherPoint *pnt0 = fill.next();
639 SketcherPoint *pnt1 = pnt0 ? fill.next() : 0;
640 SketcherPoint *pnt2 = pnt1 ? fill.next() : 0;
641 if( pnt0 && pnt1 && pnt2 ) {
642 SketcherPoint *pt0 = pnt0, *pt1 = pnt1, *pt2 = pnt2;
643 float ax,ay, bx,by, cx,cy, dx,dy, sx,sy;
644 bx = pt0->x; by = pt0->y;
645 cx = pt1->x; cy = pt1->y;
646 dx = pt2->x; dy = pt2->y;
647 smooth_axy(ax,ay, bx,by, cx,cy, dx,dy);
649 dx = pt2->x; dy = pt2->y;
652 if( convex(ax,ay, bx,by, cx,cy, dx,dy) >= 0 ) {
653 // s = ac thru b x bd thru c
654 intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
655 vpen->draw_smooth(bx,by, sx,sy, cx,cy);
659 vpen->draw_line(bx, by, cx, cy);
662 ax = bx; ay = by; pt0 = pt1;
663 bx = cx; by = cy; pt1 = pt2;
664 cx = dx; cy = dy; pt2 = fill.next();
668 vpen->draw_line(bx, by, cx, cy);
669 if( fill.exists() ) {
670 dx = pnt0->x; dy = pnt0->y;
671 vpen->draw_line(cx,cy, dx,dy);
675 if( fill.exists() ) {
676 dx = pnt0->x; dy = pnt0->y;
677 intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
678 vpen->draw_smooth(bx,by, sx,sy, cx,cy);
682 dx = pnt1->x; dy = pnt1->y;
685 smooth_dxy(dx,dy, ax,ay, bx,by, cx,cy);
686 intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
687 vpen->draw_smooth(bx,by, sx,sy, cx,cy);
692 else if( pnt0 && pnt1 ) {
693 vpen->draw_line(pnt0->x, pnt0->y, pnt1->x, pnt1->y);
696 vpen->draw_pixel(pnt0->x, pnt0->y);
701 int Sketcher::process_realtime(VFrame *input, VFrame *output)
703 this->input = input; this->output = output;
704 w = output->get_w(); h = output->get_h();
706 load_configuration();
708 int out_color_model = output->get_color_model();
709 int color_model = out_color_model;
710 switch( color_model ) { // add alpha if needed
711 case BC_RGB888: color_model = BC_RGBA8888; break;
712 case BC_YUV888: color_model = BC_YUVA8888; break;
713 case BC_RGB161616: color_model = BC_RGBA16161616; break;
714 case BC_YUV161616: color_model = BC_YUVA16161616; break;
715 case BC_RGB_FLOAT: color_model = BC_RGBA_FLOAT; break;
716 case BC_RGB_FLOATP: color_model = BC_RGBA_FLOATP; break;
718 if( color_model == out_color_model ) {
719 delete out; out = output;
720 if( output != input )
721 output->transfer_from(input);
724 VFrame::get_temp(out, w, h, color_model);
725 out->transfer_from(input);
727 VFrame::get_temp(img, w, h, color_model);
729 if( !overlay_frame ) {
730 int cpus = server->preferences->project_smp;
731 int max = (w*h)/0x80000 + 2;
732 if( cpus > max ) cpus = max;
733 overlay_frame = new OverlayFrame(cpus);
736 for( int ci=0, n=config.curves.size(); ci<n; ++ci ) {
737 SketcherCurve *cv = config.curves[ci];
738 if( cv->pen == PEN_OFF ) continue;
739 int m = cv->points.size();
742 img->set_pixel_color(cv->color, (~cv->color>>24)&0xff);
744 overlay_frame->overlay(out, img, 0,0,w,h, 0,0,w,h,
745 1.f, TRANSFER_NORMAL, NEAREST_NEIGHBOR);
749 for( int ci=0, n=config.curves.size(); ci<n; ++ci ) {
750 SketcherCurve *cv = config.curves[ci];
751 for( int pi=0,m=cv->points.size(); pi<m; ++pi ) {
752 int color = pi==config.pt_selected && ci==config.cv_selected ?
754 draw_point(out, cv->points[pi], color);
760 output->transfer_from(out);
767 void SketcherPoints::dump()
769 for( int i=0; i<size(); ++i ) {
770 SketcherPoint *pt = get(i);
771 printf(" Pt %d, id=%d, arc=%s, x=%0.1f, y=%0.1f\n",
772 i, pt->id, pt_type[pt->arc], pt->x, pt->y);
775 void SketcherCurves::dump()
777 for( int i=0; i<size(); ++i ) {
778 SketcherCurve *cv = get(i);
779 printf("Curve %d, id=%d, pen=%s, r=%d, color=%02x%02x%02x%02x, %d points\n",
780 i, cv->id, cv_pen[cv->pen], cv->width, (~cv->color>>24)&0xff,
781 (cv->color>>16)&0xff, (cv->color>>8)&0xff, (cv->color>>0)&0xff,
786 void SketcherConfig::dump()
788 printf("Config drag=%d, cv_selected=%d, pt_selected=%d %d curves\n",
789 drag, cv_selected, pt_selected, curves.size());