- this->color = color;
- int r = (color>>16) & 0xff;
- int g = (color>>8) & 0xff;
- int b = (color>>0) & 0xff;
- for( int i=0; i<3; ++i ) {
- VFrame *vframe = vframes[i];
- int ww = vframe->get_w(), hh = vframe->get_h();
- int cx = (ww+1)/2, cy = hh/2;
- double cc = (cx*cx + cy*cy) / 4.;
- uint8_t *bp = vframe->get_data(), *dp = bp;
- uint8_t *ep = dp + vframe->get_data_size();
- int rr = r, gg = g, bb = b;
- int bpl = vframe->get_bytes_per_line();
- switch( i ) {
- case BUTTON_UP:
- break;
- case BUTTON_UPHI:
- if( (rr+=48) > 0xff ) rr = 0xff;
- if( (gg+=48) > 0xff ) gg = 0xff;
- if( (bb+=48) > 0xff ) bb = 0xff;
- break;
- case BUTTON_DOWNHI:
- if( (rr-=48) < 0x00 ) rr = 0x00;
- if( (gg-=48) < 0x00 ) gg = 0x00;
- if( (bb-=48) < 0x00 ) bb = 0x00;
- break;
- }
- while( dp < ep ) {
- int yy = (dp-bp) / bpl, xx = ((dp-bp) % bpl) >> 2;
- int dy = cy - yy, dx = cx - xx;
- double s = dx*dx + dy*dy - cc;
- double ss = s < 0 ? 1 : s >= cc ? 0 : 1 - s/cc;
- int aa = ss * 0xff;
- *dp++ = rr; *dp++ = gg; *dp++ = bb; *dp++ = aa;
- }
- }
- set_images(vframes);
-}
-
-void SketcherCurveColor::update_gui(int color)
-{
- set_color(color);
- draw_face();
-}
-
-int SketcherCurveColor::handle_event()
-{
- gui->start_color_thread(this);
- return 1;
-}
-
-SketcherCurveColorPicker::SketcherCurveColorPicker(SketcherWindow *gui, SketcherCurveColor *color_button)
- : ColorPicker(0, _("Color"))
-{
- this->gui = gui;
- this->color_button = color_button;
- this->color = 0;
- color_update = new SketcherCurveColorThread(this);
-}
-
-SketcherCurveColorPicker::~SketcherCurveColorPicker()
-{
- delete color_update;
-}
-
-void SketcherCurveColorPicker::start(int color)
-{
- start_window(color, 0, 1);
- color_update->start();
-}
-
-void SketcherCurveColorPicker::handle_done_event(int result)
-{
- color_update->stop();
- gui->lock_window("SketcherCurveColorPicker::handle_done_event");
- if( result ) color = orig_color;
- color_button->update_gui(color);
- gui->unlock_window();