bld tweaks for xplatform builds, fix bad clamps, andrews lv2/opencv tweaks, trim...
[goodguy/cinelerra.git] / cinelerra-5.1 / plugins / sketcher / sketcher.C
index a954c7ca0c21d084668e48bd46267bccbd13835b..2b392327176b85cdb35e3a22cd8283dd6ff85d3c 100644 (file)
@@ -27,6 +27,7 @@
 #include "bccmodels.h"
 #include "bccolors.h"
 #include "clip.h"
+#include "edl.h"
 #include "edlsession.h"
 #include "filexml.h"
 #include "overlayframe.h"
 #include "language.h"
 #include "vframe.h"
 
-void SketcherPoint::init(int id, int pty, int x, int y)
+void SketcherPoint::init(int id, int arc, coord x, coord y)
 {
-       this->id = id;  this->pty = pty;
+       this->id = id;  this->arc = arc;
        this->x = x;    this->y = y;
 }
 SketcherPoint::SketcherPoint(int id)
 {
-       init(id, PTY_LINE, 0, 0);
+       init(id, ARC_LINE, 0, 0);
 }
-SketcherPoint::SketcherPoint(int id, int pty, int x, int y)
+SketcherPoint::SketcherPoint(int id, int arc, coord x, coord y)
 {
-       init(id, pty, x, y);
+       init(id, arc, x, y);
 }
 SketcherPoint::~SketcherPoint()
 {
@@ -60,13 +61,13 @@ SketcherPoint::SketcherPoint(SketcherPoint &pt)
 int SketcherPoint::equivalent(SketcherPoint &that)
 {
        return this->id == that.id &&
-               this->pty == that.pty &&
-               this->x == that.x &&
-               this->y == that.y ? 1 : 0;
+               this->arc == that.arc &&
+               EQUIV(this->x, that.x) &&
+               EQUIV(this->y, that.y) ? 1 : 0;
 }
 void SketcherPoint::copy_from(SketcherPoint &that)
 {
-       this->id = that.id;  this->pty = that.pty;
+       this->id = that.id;  this->arc = that.arc;
        this->x = that.x;    this->y = that.y;
 }
 void SketcherPoint::save_data(FileXML &output)
@@ -74,7 +75,7 @@ void SketcherPoint::save_data(FileXML &output)
        char point[BCSTRLEN];
        sprintf(point,"/POINT_%d",id);
        output.tag.set_title(point+1);
-       output.tag.set_property("TYPE", pty);
+       output.tag.set_property("TYPE", arc);
        output.tag.set_property("X", x);
        output.tag.set_property("Y", y);
        output.append_tag();
@@ -85,26 +86,26 @@ void SketcherPoint::save_data(FileXML &output)
 void SketcherPoint::read_data(FileXML &input)
 {
        id = atoi(input.tag.get_title() + 6);
-       pty = input.tag.get_property("TYPE", PTY_OFF);
-       x = input.tag.get_property("X", 0.f);
-       y = input.tag.get_property("Y", 0.f);
-       bclamp(pty, 0, PTY_SZ-1);
+       arc = input.tag.get_property("TYPE", ARC_OFF);
+       x = input.tag.get_property("X", (coord)0);
+       y = input.tag.get_property("Y", (coord)0);
+       bclamp(arc, 0, ARC_SZ-1);
 }
 
-void SketcherCurve::init(int id, int pen, int radius, int color)
+void SketcherCurve::init(int id, int pen, int width, int color)
 {
        this->id = id;
-       this->radius = radius;
+       this->width = width;
        this->pen = pen;
        this->color = color;
 }
 SketcherCurve::SketcherCurve(int id)
 {
-       init(id, 1, PTY_LINE, CV_COLOR);
+       init(id, 1, PEN_SQUARE, CV_COLOR);
 }
-SketcherCurve::SketcherCurve(int id, int pen, int radius, int color)
+SketcherCurve::SketcherCurve(int id, int pen, int width, int color)
 {
-       init(id, pen, radius, color);
+       init(id, pen, width, color);
 }
 SketcherCurve::~SketcherCurve()
 {
@@ -117,7 +118,7 @@ int SketcherCurve::equivalent(SketcherCurve &that)
 {
        if( this->id != that.id ) return 0;
        if( this->pen != that.pen ) return 0;
-       if( this->radius != that.radius ) return 0;
+       if( this->width != that.width ) return 0;
        if( this->color != that.color ) return 0;
        int n = this->points.size();
        if( n != that.points.size() ) return 0;
@@ -130,7 +131,7 @@ void SketcherCurve::copy_from(SketcherCurve &that)
 {
        this->id = that.id;
        this->pen = that.pen;
-       this->radius = that.radius;
+       this->width = that.width;
        this->color = that.color;
        int m = points.size(), n = that.points.size();
        while( m > n ) points.remove_object_number(--m);
@@ -139,12 +140,11 @@ void SketcherCurve::copy_from(SketcherCurve &that)
 }
 void SketcherCurve::save_data(FileXML &output)
 {
-       this->pen = pen;  this->color = color;
        char curve[BCSTRLEN];
        sprintf(curve,"/CURVE_%d",id);
        output.tag.set_title(curve+1);
        output.tag.set_property("PEN", pen);
-       output.tag.set_property("RADIUS", radius);
+       output.tag.set_property("RADIUS", width);
        output.tag.set_property("COLOR", color);
        output.append_tag();
        output.append_newline();
@@ -157,13 +157,13 @@ void SketcherCurve::save_data(FileXML &output)
 void SketcherCurve::read_data(FileXML &input)
 {
        id = atoi(input.tag.get_title() + 6);
-       pen = input.tag.get_property("PEN", PTY_OFF);
-       radius = input.tag.get_property("RADIUS", 1.);
+       pen = input.tag.get_property("PEN", PEN_OFF);
+       width = input.tag.get_property("RADIUS", 1.);
        color = input.tag.get_property("COLOR", CV_COLOR);
        bclamp(pen, 0, PEN_SZ-1);
 }
 
-int Sketcher::new_curve(int pen, int radius, int color)
+int Sketcher::new_curve(int pen, int width, int color)
 {
        SketcherCurves &curves = config.curves;
        int k = curves.size(), id = 1;
@@ -171,7 +171,7 @@ int Sketcher::new_curve(int pen, int radius, int color)
                int n = config.curves[i]->id;
                if( n >= id ) id = n + 1;
        }
-       SketcherCurve *cv = new SketcherCurve(id, pen, radius, color);
+       SketcherCurve *cv = new SketcherCurve(id, pen, width, color);
        curves.append(cv);
        config.cv_selected = k;
        return k;
@@ -182,33 +182,33 @@ int Sketcher::new_curve()
        return new_curve(PEN_XLANT, 1, CV_COLOR);
 }
 
-int Sketcher::new_point(SketcherCurve *cv, int pty, int x, int y, int idx)
+int Sketcher::new_point(SketcherCurve *cv, int arc, coord x, coord y, int idx)
 {
        int id = 1;
        for( int i=cv->points.size(); --i>=0; ) {
                int n = cv->points[i]->id;
                if( n >= id ) id = n + 1;
        }
-       SketcherPoint *pt = new SketcherPoint(id, pty, x, y);
+       SketcherPoint *pt = new SketcherPoint(id, arc, x, y);
        int n = cv->points.size();
        if( idx < 0 || idx > n ) idx = n;
        cv->points.insert(pt, idx);
        return idx;
 }
 
-int Sketcher::new_point(int idx)
+int Sketcher::new_point(int idx, int arc)
 {
        int ci = config.cv_selected;
        if( ci < 0 || ci >= config.curves.size() )
                return -1;
        SketcherCurve *cv = config.curves[ci];
-       EDLSession *session = get_edlsession();
-       int x = !session ? 0.f : session->output_w / 2.f;
-       int y = !session ? 0.f : session->output_h / 2.f;
-       return new_point(cv, PTY_LINE, x, y, idx);
+       EDLSession *session = get_edl()->session;
+       coord x = !session ? 0.f : session->output_w / 2.f;
+       coord y = !session ? 0.f : session->output_h / 2.f;
+       return new_point(cv, arc, x, y, idx);
 }
 
-double SketcherCurve::nearest_point(int &pi, float x, float y)
+double SketcherCurve::nearest_point(int &pi, coord x, coord y)
 {
        pi = -1;
        double dist = DBL_MAX;
@@ -220,7 +220,7 @@ double SketcherCurve::nearest_point(int &pi, float x, float y)
        return pi >= 0 ? dist : -1.;
 }
 
-double SketcherConfig::nearest_point(int &ci, int &pi, float x, float y)
+double SketcherConfig::nearest_point(int &ci, int &pi, coord x, coord y)
 {
        double dist = DBL_MAX;
        ci = -1;  pi = -1;
@@ -242,6 +242,7 @@ REGISTER_PLUGIN(Sketcher)
 SketcherConfig::SketcherConfig()
 {
        drag = 1;
+       aliasing = 0;
        cv_selected = 0;
        pt_selected = 0;
 }
@@ -252,6 +253,7 @@ SketcherConfig::~SketcherConfig()
 int SketcherConfig::equivalent(SketcherConfig &that)
 {
        if( this->drag != that.drag ) return 0;
+       if( this->aliasing != that.aliasing ) return 0;
        if( this->cv_selected != that.cv_selected ) return 0;
        if( this->pt_selected != that.pt_selected ) return 0;
        if( this->curves.size() != that.curves.size() ) return 0;
@@ -264,6 +266,7 @@ int SketcherConfig::equivalent(SketcherConfig &that)
 void SketcherConfig::copy_from(SketcherConfig &that)
 {
        this->drag = that.drag;
+       this->aliasing = that.aliasing;
        this->cv_selected = that.cv_selected;
        this->pt_selected = that.pt_selected;
        int m = curves.size(), n = that.curves.size();
@@ -278,6 +281,7 @@ void SketcherConfig::interpolate(SketcherConfig &prev, SketcherConfig &next,
        this->cv_selected = prev.cv_selected;
        this->pt_selected = prev.pt_selected;
        this->drag = prev.drag;
+       this->aliasing = prev.aliasing;
 
        double next_scale = (double)(current_frame - prev_frame) / (next_frame - prev_frame);
        double prev_scale = (double)(next_frame - current_frame) / (next_frame - prev_frame);
@@ -293,19 +297,31 @@ void SketcherConfig::interpolate(SketcherConfig &prev, SketcherConfig &next,
                if( k >= 0 ) {
                        cv->id = pcv->id;
                        cv->pen = pcv->pen;
-                       cv->radius = pcv->radius;
-                       cv->color = pcv->color;
+                       cv->width = pcv->width == ncv->width ? pcv->width :
+                               pcv->width*prev_scale + ncv->width*next_scale + 0.5;
+                       int pr =  (pcv->color>>16)&0xff, nr =  (ncv->color>>16)&0xff;
+                       int pg =  (pcv->color>> 8)&0xff, ng =  (ncv->color>> 8)&0xff;
+                       int pb =  (pcv->color>> 0)&0xff, nb =  (ncv->color>> 0)&0xff;
+                       int pa = (~pcv->color>>24)&0xff, na = (~ncv->color>>24)&0xff;
+                       int r = pr == nr ? pr : pr*prev_scale + nr*next_scale + 0.5;
+                       int g = pg == ng ? pg : pg*prev_scale + ng*next_scale + 0.5;
+                       int b = pb == nb ? pb : pb*prev_scale + nb*next_scale + 0.5;
+                       int a = pa == na ? pa : pa*prev_scale + na*next_scale + 0.5;
+                       bclamp(r,0,255); bclamp(g,0,255); bclamp(b,0,255); bclamp(a,0,255);
+                       cv->color = (~a<<24) | (r<<16) | (g<<8) | (b<<0);
                        int prev_pt_sz = pcv->points.size(), next_pt_sz = ncv->points.size();
                        for( int j=0; j<prev_pt_sz; ++j ) {
                                SketcherPoint &pt = *pcv->points[j], *nt = 0;
                                k = next_pt_sz;  // associated by id in next
                                while( --k >= 0 && pt.id != (nt=ncv->points[k])->id );
-                               int x = pt.x, y = pt.y;
+                               coord x = pt.x, y = pt.y;
                                if( k >= 0 ) {
-                                       x = x * prev_scale + nt->x * next_scale;
-                                       y = y * prev_scale + nt->y * next_scale;
+                                       if( x != nt->x )
+                                               x = x * prev_scale + nt->x * next_scale;
+                                       if( y != nt->y )
+                                               y = y * prev_scale + nt->y * next_scale;
                                }
-                               cv->points.append(new SketcherPoint(pt.id, pt.pty, x, y));
+                               cv->points.append(new SketcherPoint(pt.id, pt.arc, x, y));
                        }
                }
                else
@@ -335,6 +351,7 @@ Sketcher::~Sketcher()
 
 const char* Sketcher::plugin_title() { return N_("Sketcher"); }
 int Sketcher::is_realtime() { return 1; }
+int Sketcher::is_synthesis() { return 1; }
 
 NEW_WINDOW_MACRO(Sketcher, SketcherWindow);
 LOAD_CONFIGURATION_MACRO(Sketcher, SketcherConfig)
@@ -347,6 +364,7 @@ void Sketcher::save_data(KeyFrame *keyframe)
 
        output.tag.set_title("SKETCHER");
        output.tag.set_property("DRAG", config.drag);
+       output.tag.set_property("ALIASING", config.aliasing);
        output.tag.set_property("CV_SELECTED", config.cv_selected);
        output.tag.set_property("PT_SELECTED", config.pt_selected);
        output.append_tag();
@@ -371,6 +389,7 @@ void Sketcher::read_data(KeyFrame *keyframe)
        while( !(result=input.read_tag()) ) {
                if( input.tag.title_is("SKETCHER") ) {
                        config.drag = input.tag.get_property("DRAG", config.drag);
+                       config.aliasing = input.tag.get_property("ALIASING", config.aliasing);
                        config.cv_selected = input.tag.get_property("CV_SELECTED", 0);
                        config.pt_selected = input.tag.get_property("PT_SELECTED", 0);
                }
@@ -425,57 +444,68 @@ void Sketcher::draw_point(VFrame *vfrm, SketcherPoint *pt, int color)
 }
 
 
-int SketcherVPen::draw_pixel(int x, int y)
+int SketcherVPen::draw_mask(int x, int y)
 {
-       if( x >= 0 && x < vfrm->get_w() &&
-           y >= 0 && y < vfrm->get_h() )
-               msk[vfrm->get_w()*y + x] = 0xff;
+       int w = vfrm->get_w(), h = vfrm->get_h();
+       if( x < 0 || x >= w ) return 1;
+       if( y < 0 || y >= h ) return 1;
+       msk[w * y + x] = 0xff;
        return 0;
 }
 
-int SketcherPenSquare::draw_pixel(int x, int y)
+int SketcherVPen::draw_pixel(float x, float y, float frac, int axis)
 {
+       draw_mask(x, y);
+       return VFrame::draw_pixel(x, y, frac, axis);
+}
+
+int SketcherPenSquare::draw_pixel(float x, float y, float a)
+{
+       vfrm->set_draw_alpha(a);
        vfrm->draw_line(x-n, y, x+n, y);
        for( int i=-n; i<n; ++i )
                vfrm->draw_line(x-n, y+i, x+n, y+i);
-       return SketcherVPen::draw_pixel(x, y);
+       return 0;
 }
-int SketcherPenPlus::draw_pixel(int x, int y)
+int SketcherPenPlus::draw_pixel(float x, float y, float a)
 {
+       vfrm->set_draw_alpha(a);
        if( n > 1 ) {
                vfrm->draw_line(x-n, y, x+n, y);
                vfrm->draw_line(x, y-n, x, y+n);
        }
        else
                vfrm->draw_pixel(x, y);
-       return SketcherVPen::draw_pixel(x, y);
+       return 0;
 }
-int SketcherPenSlant::draw_pixel(int x, int y)
+int SketcherPenSlant::draw_pixel(float x, float y, float a)
 {
+       vfrm->set_draw_alpha(a);
        vfrm->draw_line(x-n,   y+n,   x+n,   y-n);
        vfrm->draw_line(x-n+1, y+n,   x+n+1, y-n);
        vfrm->draw_line(x-n,   y+n+1, x+n,   y-n+1);
-       return SketcherVPen::draw_pixel(x, y);
+       return 0;
 }
-int SketcherPenXlant::draw_pixel(int x, int y)
+int SketcherPenXlant::draw_pixel(float x, float y, float a)
 {
+       vfrm->set_draw_alpha(a);
        vfrm->draw_line(x-n,   y+n,   x+n,   y-n);
        vfrm->draw_line(x-n+1, y+n,   x+n+1, y-n);
        vfrm->draw_line(x-n,   y+n+1, x+n,   y-n+1);
        vfrm->draw_line(x-n,   y-n,   x+n,   y+n);
        vfrm->draw_line(x-n+1, y-n,   x+n+1, y+n);
        vfrm->draw_line(x-n,   y-n+1, x+n,   y-n+1);
-       return SketcherVPen::draw_pixel(x, y);
+       return 0;
 }
 
 
 SketcherVPen *SketcherCurve::new_vpen(VFrame *out)
 {
        switch( pen ) {
-       case PEN_SQUARE: return new SketcherPenSquare(out, radius);
-       case PEN_PLUS:   return new SketcherPenPlus(out, radius);
-       case PEN_SLANT:  return new SketcherPenSlant(out, radius);
-       case PEN_XLANT:  return new SketcherPenXlant(out, radius);
+       case PEN_SQUARE: return new SketcherPenSquare(out, width);
+       case PEN_PLUS:   return new SketcherPenPlus(out, width);
+       case PEN_SLANT:  return new SketcherPenSlant(out, width);
+       case PEN_XLANT:  return new SketcherPenXlant(out, width);
        }
        return 0;
 }
@@ -515,7 +545,6 @@ static void smooth_dxy(float &dx, float &dy,
        dx = xc - xd;  dy = yc - yd;
 }
 
-#if 0
 static int convex(float ax,float ay, float bx,float by,
                  float cx,float cy, float dx,float dy)
 {
@@ -528,8 +557,6 @@ static int convex(float ax,float ay, float bx,float by,
        float v = abc * bcd;
        return !v ? 0 : v>0 ? 1 : -1;
 }
-#endif
-
 
 class FillRegion
 {
@@ -553,6 +580,7 @@ class FillRegion
 public:
        SketcherPoint *next();
        bool exists() { return stack.size() > 0; }
+       void draw_pixel(int x, int y) { img->draw_pixel(x, y); }
        void start_at(int x, int y);
        void run();
        FillRegion(SketcherPoints &pts, SketcherVPen *vpen);
@@ -581,25 +609,26 @@ void FillRegion::start_at(int x, int y)
 
 void FillRegion::run()
 {
+       img->set_draw_alpha(1);
        while( stack.size() > 0 ) {
                int y, ilt, irt;
                pop(y, ilt, irt);
                int ofs = y*w + ilt;
                for( int x=ilt; x<=irt; ++x,++ofs ) {
+                       draw_pixel(x, y);
                        if( msk[ofs] ) continue;
                        msk[ofs] = 0xff;
-                       img->draw_pixel(x, y);
                        int lt = x, rt = x;
                        int lofs = ofs;
                        for( int i=lt; --i>=0; ) {
+                               draw_pixel(i, y);
                                if( msk[--lofs] ) break;
-                               img->draw_pixel(i, y);
                                msk[lofs] = 0xff;  lt = i;
                        }
                        int rofs = ofs;
                        for( int i=rt; ++i< w; ) {
+                               draw_pixel(i, y);
                                if( msk[++rofs] ) break;
-                               img->draw_pixel(i, y);
                                msk[rofs] = 0xff;  rt = i;
                        }
                        if( y+1 <  h ) push(y+1, lt, rt);
@@ -611,20 +640,21 @@ void FillRegion::run()
 SketcherPoint *FillRegion::next()
 {
        while( nxt < points.size() ) {
-               SketcherPoint *pt = points[nxt];
-               if( pt->pty != PTY_FILL ) break;
+               SketcherPoint *pt = points[nxt++];
+               if( pt->arc == ARC_OFF ) continue;
+               if( pt->arc != ARC_FILL ) return pt;
                start_at(pt->x, pt->y);
-               ++nxt;
        }
-       return nxt < points.size() ? points[nxt++] : 0;
+       return 0;
 }
 
-
-void SketcherCurve::draw(VFrame *img)
+void SketcherCurve::draw(VFrame *img, int alias)
 {
        if( !points.size() ) return;
+       img->set_pixel_color(color, (~color>>24)&0xff);
        const float fmx = 16383;
        SketcherVPen *vpen = new_vpen(img);
+       vpen->set_draw_flags(alias);
        FillRegion fill(points, vpen);
        SketcherPoint *pnt0 = fill.next();
        SketcherPoint *pnt1 = pnt0 ? fill.next() : 0;
@@ -638,29 +668,31 @@ void SketcherCurve::draw(VFrame *img)
                smooth_axy(ax,ay, bx,by, cx,cy, dx,dy);
                while( pt2 ) {
                        dx = pt2->x;  dy = pt2->y;
-                       switch( pt0->pty ) {
-                       case PTY_LINE:
+                       switch( pt0->arc ) {
+                       case ARC_CURVE:
+                               if( convex(ax,ay, bx,by, cx,cy, dx,dy) >= 0 ) {
+                                       // s = ac thru b x bd thru c
+                                       intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
+                                       vpen->draw_smooth(bx,by, sx,sy, cx,cy);
+                                       break;
+                               } // fall thru
+                       case ARC_LINE:
                                vpen->draw_line(bx, by, cx, cy);
                                break;
-                       case PTY_CURVE: {
-                               // s = ac thru b x bd thru c
-                               intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
-                               vpen->draw_smooth(bx,by, sx,sy, cx,cy);
-                               break; }
                        }
                        ax = bx;  ay = by;  pt0 = pt1;
                        bx = cx;  by = cy;  pt1 = pt2;
                        cx = dx;  cy = dy;  pt2 = fill.next();
                }
-               switch( pt1->pty ) {
-               case PTY_LINE:
+               switch( pt1->arc ) {
+               case ARC_LINE:
                        vpen->draw_line(bx, by, cx, cy);
                        if( fill.exists() ) {
                                dx = pnt0->x;  dy = pnt0->y;
                                vpen->draw_line(cx,cy, dx,dy);
                        }
                        break;
-               case PTY_CURVE: {
+               case ARC_CURVE: {
                        if( fill.exists() ) {
                                dx = pnt0->x;  dy = pnt0->y;
                                intersects_at(sx,sy, ax,ay,cx,cy,bx,by, bx,by,dx,dy,cx,cy,fmx);
@@ -682,7 +714,7 @@ void SketcherCurve::draw(VFrame *img)
                vpen->draw_line(pnt0->x, pnt0->y, pnt1->x, pnt1->y);
        }
        else if( pnt0 ) {
-               vpen->draw_pixel(pnt0->x, pnt0->y);
+               vpen->draw_pixel(pnt0->x, pnt0->y, 1);
        }
        delete vpen;
 }
@@ -724,13 +756,15 @@ int Sketcher::process_realtime(VFrame *input, VFrame *output)
 
        for( int ci=0, n=config.curves.size(); ci<n; ++ci ) {
                SketcherCurve *cv = config.curves[ci];
+               if( cv->pen == PEN_OFF ) continue;
                int m = cv->points.size();
-               if( !m || cv->pen == PTY_OFF ) continue;
+               if( !m ) continue;
                img->clear_frame();
-               img->set_pixel_color(cv->color, (~cv->color>>24)&0xff);
-               cv->draw(img);
+               int alias = config.aliasing < 0 ? ALIAS_OFF :
+                       config.aliasing > 0 ? ALIAS_DBL : ALIAS_NRM;
+               cv->draw(img, alias);
                overlay_frame->overlay(out, img, 0,0,w,h, 0,0,w,h,
-                               1.f, TRANSFER_NORMAL, NEAREST_NEIGHBOR);
+                               1.f, TRANSFER_SRC_OVER, NEAREST_NEIGHBOR);
        }
 
        if( config.drag ) {
@@ -756,16 +790,16 @@ void SketcherPoints::dump()
 {
        for( int i=0; i<size(); ++i ) {
                SketcherPoint *pt = get(i);
-               printf("  Pt %d, id=%d, pty=%s, x=%d, y=%d\n",
-                       i, pt->id, pt_type[pt->pty], pt->x, pt->y);
+               printf("  Pt %d, id=%d, arc=%s, x=%0.1f, y=%0.1f\n",
+                       i, pt->id, pt_type[pt->arc], pt->x, pt->y);
        }
 }
 void SketcherCurves::dump()
 {
        for( int i=0; i<size(); ++i ) {
                SketcherCurve *cv = get(i);
-               printf("Curve %d, id=%d, pen=%s, r=%d, color=%02x%02x%02x, %d points\n",
-                       i, cv->id, cv_pen[cv->pen], cv->radius,
+               printf("Curve %d, id=%d, pen=%s, r=%d, color=%02x%02x%02x%02x, %d points\n",
+                       i, cv->id, cv_pen[cv->pen], cv->width, (~cv->color>>24)&0xff,
                        (cv->color>>16)&0xff, (cv->color>>8)&0xff, (cv->color>>0)&0xff,
                        cv->points.size());
                cv->points.dump();