16
15
# include <config.h>
19
#include <glibmm/i18n.h>
20
#include <glibmm/ustring.h>
21
#include <glibmm/refptr.h>
22
#include <gtkmm/clipboard.h>
23
#include <gdk/gdkkeysyms.h>
21
#include <2geom/transforms.h>
25
23
#include "macros.h"
26
24
#include "display/canvas-bpath.h"
27
25
#include "display/canvas-arena.h"
28
26
#include "display/curve.h"
27
#include "display/cairo-utils.h"
29
28
#include "svg/svg-color.h"
31
30
#include "color-rgba.h"
217
217
Geom::Point const cd = desktop->w2d(dc->centre);
218
Geom::Matrix const w2dt = desktop->w2d();
218
Geom::Affine const w2dt = desktop->w2d();
219
219
const double scale = rw * w2dt.descrim();
220
Geom::Matrix const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) );
220
Geom::Affine const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) );
221
221
sp_canvas_item_affine_absolute(dc->area, sm);
222
222
sp_canvas_item_show(dc->area);
225
const int x0 = (int) floor(dc->centre[Geom::X] - rw);
226
const int y0 = (int) floor(dc->centre[Geom::Y] - rw);
227
const int x1 = (int) ceil(dc->centre[Geom::X] + rw);
228
const int y1 = (int) ceil(dc->centre[Geom::Y] + rw);
230
if ((x1 > x0) && (y1 > y0)) {
232
nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x0, y0, x1, y1, TRUE);
233
/* fixme: (Lauris) */
234
sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb);
235
for (int y = y0; y < y1; y++) {
236
const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs;
237
for (int x = x0; x < x1; x++) {
238
const double dx = x - dc->centre[Geom::X];
239
const double dy = y - dc->centre[Geom::Y];
240
const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw));
249
nr_pixblock_release(&pb);
251
R = (R + 0.001) / (255.0 * W);
252
G = (G + 0.001) / (255.0 * W);
253
B = (B + 0.001) / (255.0 * W);
254
A = (A + 0.001) / (255.0 * W);
256
R = CLAMP(R, 0.0, 1.0);
257
G = CLAMP(G, 0.0, 1.0);
258
B = CLAMP(B, 0.0, 1.0);
259
A = CLAMP(A, 0.0, 1.0);
225
Geom::Rect r(dc->centre, dc->centre);
227
if (!r.hasZeroArea()) {
228
Geom::IntRect area = r.roundOutwards();
229
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, area.width(), area.height());
230
sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
231
ink_cairo_surface_average_color_premul(s, R, G, B, A);
232
cairo_surface_destroy(s);
263
235
// pick single pixel
265
int x = (int) floor(event->button.x);
266
int y = (int) floor(event->button.y);
267
nr_pixblock_setup_fast(&pb, NR_PIXBLOCK_MODE_R8G8B8A8P, x, y, x+1, y+1, TRUE);
268
sp_canvas_arena_render_pixblock(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), &pb);
269
const unsigned char *s = NR_PIXBLOCK_PX(&pb);
236
Geom::IntRect area = Geom::IntRect::from_xywh(floor(event->button.x), floor(event->button.y), 1, 1);
237
cairo_surface_t *s = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, 1, 1);
238
sp_canvas_arena_render_surface(SP_CANVAS_ARENA(sp_desktop_drawing(desktop)), s, area);
239
ink_cairo_surface_average_color_premul(s, R, G, B, A);
240
cairo_surface_destroy(s);
277
243
if (pick == SP_DROPPER_PICK_VISIBLE) {