static SPPaintSelectorMode sp_fill_style_determine_paint_selector_mode (SPStyle *style) { SPColorSpaceType cstype; switch (style->fill.type) { case SP_PAINT_TYPE_NONE: return SP_PAINT_SELECTOR_MODE_NONE; case SP_PAINT_TYPE_COLOR: cstype = sp_color_get_colorspace_type (&style->fill.value.color); switch (cstype) { case SP_COLORSPACE_TYPE_RGB: return SP_PAINT_SELECTOR_MODE_COLOR_RGB; case SP_COLORSPACE_TYPE_CMYK: return SP_PAINT_SELECTOR_MODE_COLOR_CMYK; default: g_warning ("file %s: line %d: Unknown colorspace type %d", __FILE__, __LINE__, cstype); return SP_PAINT_SELECTOR_MODE_NONE; } case SP_PAINT_TYPE_PAINTSERVER: if (SP_IS_LINEARGRADIENT (SP_STYLE_FILL_SERVER (style))) { return SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR; } else if (SP_IS_RADIALGRADIENT (SP_STYLE_FILL_SERVER (style))) { return SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL; } g_warning ("file %s: line %d: Unknown paintserver", __FILE__, __LINE__); return SP_PAINT_SELECTOR_MODE_NONE; default: g_warning ("file %s: line %d: Unknown paint type %d", __FILE__, __LINE__, style->fill.type); break; } return SP_PAINT_SELECTOR_MODE_NONE; }
void PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); // FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used. Geom::Point p_snapped = snap_knot_position(p, state); // get angle from current transform gdouble theta = sp_pattern_extract_theta(pat); // Get the new scale from the position of the knotholder Geom::Point d = p_snapped - sp_pattern_extract_trans(pat); gdouble pat_x = pattern_width(pat); gdouble pat_y = pattern_height(pat); Geom::Scale scl(1); if ( state & GDK_CONTROL_MASK ) { // if ctrl is pressed: use 1:1 scaling gdouble pat_h = hypot(pat_x, pat_y); scl = Geom::Scale(d.length() / pat_h); } else { d *= Geom::Rotate(-theta); scl = Geom::Scale(d[Geom::X] / pat_x, d[Geom::Y] / pat_y); } Geom::Affine rot = (Geom::Affine)scl * Geom::Rotate(theta); Geom::Point const t = sp_pattern_extract_trans(pat); rot[4] = t[Geom::X]; rot[5] = t[Geom::Y]; item->adjust_pattern(rot, true); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); }
void PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12); SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); // get the angle from pattern 0,0 to the cursor pos Geom::Point delta = p - sp_pattern_extract_trans(pat); gdouble theta = atan2(delta); if ( state & GDK_CONTROL_MASK ) { theta = sp_round(theta, M_PI/snaps); } // get the scale from the current transform so we can keep it. Geom::Point scl = sp_pattern_extract_scale(pat); Geom::Affine rot = Geom::Affine(Geom::Scale(scl)) * Geom::Affine(Geom::Rotate(theta)); Geom::Point const t = sp_pattern_extract_trans(pat); rot[4] = t[Geom::X]; rot[5] = t[Geom::Y]; item->adjust_pattern(rot, true); item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); }
Geom::Point PatternKnotHolderEntityAngle::knot_get() { SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); gdouble x = (pattern_width(pat)); gdouble y = 0; Geom::Point delta = Geom::Point(x,y); Geom::Point scale = sp_pattern_extract_scale(pat); gdouble theta = sp_pattern_extract_theta(pat); delta = delta * Geom::Affine(Geom::Scale(scale))*Geom::Affine(Geom::Rotate(theta)); delta = delta + sp_pattern_extract_trans(pat); return delta; }
Geom::Point PatternKnotHolderEntityScale::knot_get() { SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); gdouble x = pattern_width(pat); gdouble y = pattern_height(pat); Geom::Point delta = Geom::Point(x,y); Geom::Affine a = pat->patternTransform; a[4] = 0; a[5] = 0; delta = delta * a; delta = delta + sp_pattern_extract_trans(pat); return delta; }
void StyleSwatch::setStyle(SPStyle *query) { _place[SS_FILL].remove(); _place[SS_STROKE].remove(); bool has_stroke = true; for (int i = SS_FILL; i <= SS_STROKE; i++) { Gtk::EventBox *place = &(_place[i]); SPIPaint *paint; if (i == SS_FILL) { paint = &(query->fill); } else { paint = &(query->stroke); } if (paint->set && paint->isPaintserver()) { SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query); if (SP_IS_LINEARGRADIENT (server)) { _value[i].set_markup(_("L Gradient")); place->add(_value[i]); _tooltips.set_tip(*place, (i == SS_FILL)? (_("Linear gradient fill")) : (_("Linear gradient stroke"))); } else if (SP_IS_RADIALGRADIENT (server)) { _value[i].set_markup(_("R Gradient")); place->add(_value[i]); _tooltips.set_tip(*place, (i == SS_FILL)? (_("Radial gradient fill")) : (_("Radial gradient stroke"))); } else if (SP_IS_PATTERN (server)) { _value[i].set_markup(_("Pattern")); place->add(_value[i]); _tooltips.set_tip(*place, (i == SS_FILL)? (_("Pattern fill")) : (_("Pattern stroke"))); } } else if (paint->set && paint->isColor()) { guint32 color = paint->value.color.toRGBA32( SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value) ); ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color); _color_preview[i]->show_all(); place->add(*_color_preview[i]); gchar *tip; if (i == SS_FILL) { tip = g_strdup_printf (_("Fill: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color)); } else {
void PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin, guint state) { SPPattern *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); // FIXME: this snapping should be done together with knowing whether control was pressed. If GDK_CONTROL_MASK, then constrained snapping should be used. Geom::Point p_snapped = snap_knot_position(p, state); if ( state & GDK_CONTROL_MASK ) { if (fabs((p - origin)[Geom::X]) > fabs((p - origin)[Geom::Y])) { p_snapped[Geom::Y] = origin[Geom::Y]; } else { p_snapped[Geom::X] = origin[Geom::X]; } } if (state) { Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat); item->adjust_pattern(Geom::Affine(Geom::Translate(q))); } item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); }
Geom::Point PatternKnotHolderEntityXY::knot_get() { SPPattern const *pat = SP_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)); return sp_pattern_extract_trans(pat); }