42
42
#include "dropper-context.h"
43
43
#include "message-context.h"
44
#include "libnr/nr-scale-translate-ops.h"
44
//#include "libnr/nr-scale-translate-ops.h"
46
46
static void sp_dropper_context_class_init(SPDropperContextClass *klass);
47
47
static void sp_dropper_context_init(SPDropperContext *dc);
184
184
// calculate average
187
rw = std::min(NR::L2(NR::Point(event->button.x, event->button.y) - dc->centre), 400.0);
187
rw = std::min(Geom::L2(Geom::Point(event->button.x, event->button.y) - dc->centre), 400.0);
189
189
if (rw == 0) { // happens sometimes, little idea why...
193
NR::Point const cd = desktop->w2d(dc->centre);
194
NR::Matrix const w2dt = desktop->w2d();
195
const double scale = rw * NR::expansion(w2dt);
196
NR::Matrix const sm( NR::scale(scale, scale) * NR::translate(cd) );
193
Geom::Point const cd = desktop->w2d(dc->centre);
194
Geom::Matrix const w2dt = desktop->w2d();
195
const double scale = rw * w2dt.descrim();
196
Geom::Matrix const sm( Geom::Scale(scale, scale) * Geom::Translate(cd) );
197
197
sp_canvas_item_affine_absolute(dc->area, sm);
198
198
sp_canvas_item_show(dc->area);
201
const int x0 = (int) floor(dc->centre[NR::X] - rw);
202
const int y0 = (int) floor(dc->centre[NR::Y] - rw);
203
const int x1 = (int) ceil(dc->centre[NR::X] + rw);
204
const int y1 = (int) ceil(dc->centre[NR::Y] + rw);
201
const int x0 = (int) floor(dc->centre[Geom::X] - rw);
202
const int y0 = (int) floor(dc->centre[Geom::Y] - rw);
203
const int x1 = (int) ceil(dc->centre[Geom::X] + rw);
204
const int y1 = (int) ceil(dc->centre[Geom::Y] + rw);
206
206
if ((x1 > x0) && (y1 > y0)) {
211
211
for (int y = y0; y < y1; y++) {
212
212
const unsigned char *s = NR_PIXBLOCK_PX(&pb) + (y - y0) * pb.rs;
213
213
for (int x = x0; x < x1; x++) {
214
const double dx = x - dc->centre[NR::X];
215
const double dy = y - dc->centre[NR::Y];
214
const double dx = x - dc->centre[Geom::X];
215
const double dy = y - dc->centre[Geom::Y];
216
216
const double w = exp(-((dx * dx) + (dy * dy)) / (rw * rw));