summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTavmjong Bah <tavmjong@free.fr>2016-10-19 11:11:05 +0000
committertavmjong-free <tavmjong@free.fr>2016-10-19 11:11:05 +0000
commit96bf3670efc23ecee2b9546b0b55993b1601c221 (patch)
tree57811483e1b2ea1e395b8f125964e45296138b6c /src
parentupdate author list in about dialog from AUTHORS file (diff)
downloadinkscape-96bf3670efc23ecee2b9546b0b55993b1601c221.tar.gz
inkscape-96bf3670efc23ecee2b9546b0b55993b1601c221.zip
Implement 'vector-effect' value 'non-scaling-stroke'. No GUI yet.
(bzr r15177)
Diffstat (limited to 'src')
-rw-r--r--src/attributes.cpp1
-rw-r--r--src/attributes.h3
-rw-r--r--src/display/drawing-shape.cpp14
-rw-r--r--src/display/drawing-text.cpp13
-rw-r--r--src/style-enums.h10
-rw-r--r--src/style.cpp13
-rw-r--r--src/style.h3
7 files changed, 50 insertions, 7 deletions
diff --git a/src/attributes.cpp b/src/attributes.cpp
index b06ff6048..02b9450b0 100644
--- a/src/attributes.cpp
+++ b/src/attributes.cpp
@@ -442,6 +442,7 @@ static SPStyleProp const props[] = {
{SP_PROP_PAINT_ORDER, "paint-order" },
{SP_PROP_SOLID_COLOR, "solid-color"},
{SP_PROP_SOLID_OPACITY, "solid-opacity"},
+ {SP_PROP_VECTOR_EFFECT, "vector-effect"},
/* CSS Blending/Compositing */
{SP_PROP_MIX_BLEND_MODE, "mix-blend-mode"},
diff --git a/src/attributes.h b/src/attributes.h
index ff426e8cf..12adcf8e2 100644
--- a/src/attributes.h
+++ b/src/attributes.h
@@ -450,7 +450,8 @@ enum SPAttributeEnum {
SP_PROP_PAINT_ORDER, /* SVG2 */
SP_PROP_SOLID_COLOR,
SP_PROP_SOLID_OPACITY,
-
+ SP_PROP_VECTOR_EFFECT,
+
/* CSS Blending/Compositing */
SP_PROP_MIX_BLEND_MODE,
SP_PROP_ISOLATION,
diff --git a/src/display/drawing-shape.cpp b/src/display/drawing-shape.cpp
index 63efb3c0d..ba95a63ce 100644
--- a/src/display/drawing-shape.cpp
+++ b/src/display/drawing-shape.cpp
@@ -180,6 +180,10 @@ DrawingShape::_renderStroke(DrawingContext &dc)
if( has_stroke ) {
// TODO: remove segments outside of bbox when no dashes present
dc.path(_curve->get_pathvector());
+ if (_style && _style->vector_effect.computed == SP_VECTOR_EFFECT_NON_SCALING_STROKE) {
+ dc.restore();
+ dc.save();
+ }
_nrstyle.applyStroke(dc);
dc.strokePreserve();
dc.newPath(); // clear path
@@ -213,7 +217,7 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne
}
{ Inkscape::DrawingContext::Save save(dc);
dc.setSource(rgba);
- dc.setLineWidth(0.5);
+ dc.setLineWidth(5);
dc.setTolerance(0.5);
dc.stroke();
}
@@ -230,6 +234,8 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne
// we assume the context has no path
Inkscape::DrawingContext::Save save(dc);
dc.transform(_ctm);
+ dc.path(_curve->get_pathvector());
+
// update fill and stroke paints.
// this cannot be done during nr_arena_shape_update, because we need a Cairo context
@@ -237,14 +243,16 @@ DrawingShape::_renderItem(DrawingContext &dc, Geom::IntRect const &area, unsigne
bool has_fill = _nrstyle.prepareFill(dc, _item_bbox, _fill_pattern);
bool has_stroke = _nrstyle.prepareStroke(dc, _item_bbox, _stroke_pattern);
has_stroke &= (_nrstyle.stroke_width != 0);
-
if (has_fill || has_stroke) {
// TODO: remove segments outside of bbox when no dashes present
- dc.path(_curve->get_pathvector());
if (has_fill) {
_nrstyle.applyFill(dc);
dc.fillPreserve();
}
+ if (_style && _style->vector_effect.computed == SP_VECTOR_EFFECT_NON_SCALING_STROKE) {
+ dc.restore();
+ dc.save();
+ }
if (has_stroke) {
_nrstyle.applyStroke(dc);
dc.strokePreserve();
diff --git a/src/display/drawing-text.cpp b/src/display/drawing-text.cpp
index a0918e9f5..1280a2db9 100644
--- a/src/display/drawing-text.cpp
+++ b/src/display/drawing-text.cpp
@@ -592,17 +592,24 @@ unsigned DrawingText::_renderItem(DrawingContext &dc, Geom::IntRect const &/*are
{
Inkscape::DrawingContext::Save save(dc);
dc.transform(_ctm);
-
if (has_fill && fill_first) {
_nrstyle.applyFill(dc);
dc.fillPreserve();
}
-
+ }
+ {
+ Inkscape::DrawingContext::Save save(dc);
+ if (!_style || ! _style->vector_effect.computed == SP_VECTOR_EFFECT_NON_SCALING_STROKE) {
+ dc.transform(_ctm);
+ }
if (has_stroke) {
_nrstyle.applyStroke(dc);
dc.strokePreserve();
}
-
+ }
+ {
+ Inkscape::DrawingContext::Save save(dc);
+ dc.transform(_ctm);
if (has_fill && !fill_first) {
_nrstyle.applyFill(dc);
dc.fillPreserve();
diff --git a/src/style-enums.h b/src/style-enums.h
index 06207852c..a0fcaedef 100644
--- a/src/style-enums.h
+++ b/src/style-enums.h
@@ -309,6 +309,10 @@ enum SPTextRendering {
SP_CSS_TEXT_RENDERING_GEOMETRICPRECISION
};
+enum SPVectorEffect {
+ SP_VECTOR_EFFECT_NONE,
+ SP_VECTOR_EFFECT_NON_SCALING_STROKE
+};
struct SPStyleEnum {
char const *key;
@@ -668,6 +672,12 @@ static SPStyleEnum const enum_color_interpolation[] = {
{NULL, -1}
};
+static SPStyleEnum const enum_vector_effect[] = {
+ {"none", SP_VECTOR_EFFECT_NONE},
+ {"non-scaling-stroke", SP_VECTOR_EFFECT_NON_SCALING_STROKE},
+ {NULL, -1}
+};
+
#endif // SEEN_SP_STYLE_ENUMS_H
diff --git a/src/style.cpp b/src/style.cpp
index 930e271ad..c513b735d 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -161,6 +161,9 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
solid_color( "solid-color" ), // SPIColor
solid_opacity( "solid-opacity", SP_SCALE24_MAX ),
+ // Vector effects
+ vector_effect( "vector-effect", enum_vector_effect, SP_VECTOR_EFFECT_NONE, false ),
+
// Fill properties
fill( "fill" ), // SPIPaint
fill_opacity( "fill-opacity", SP_SCALE24_MAX ),
@@ -331,6 +334,8 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
_properties.push_back( &solid_color );
_properties.push_back( &solid_opacity );
+ _properties.push_back( &vector_effect );
+
_properties.push_back( &fill );
_properties.push_back( &fill_opacity );
_properties.push_back( &fill_rule );
@@ -427,6 +432,8 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// _propmap.insert( std::make_pair( solid_color.name, reinterpret_cast<SPIBasePtr>(&SPStyle::solid_color ) ) );
// _propmap.insert( std::make_pair( solid_opacity.name, reinterpret_cast<SPIBasePtr>(&SPStyle::solid_opacity ) ) );
+ // _propmap.insert( std::make_pair( vector_effect.name, reinterpret_cast<SPIBasePtr>(&SPStyle::vector_effect ) ) );
+
// _propmap.insert( std::make_pair( fill.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill ) ) );
// _propmap.insert( std::make_pair( fill_opacity.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill_opacity ) ) );
// _propmap.insert( std::make_pair( fill_rule.name, reinterpret_cast<SPIBasePtr>(&SPStyle::fill_rule ) ) );
@@ -911,6 +918,9 @@ SPStyle::readIfUnset( gint id, gchar const *val ) {
case SP_PROP_SOLID_OPACITY:
solid_opacity.readIfUnset( val );
break;
+ case SP_PROP_VECTOR_EFFECT:
+ vector_effect.readIfUnset( val );
+ break;
case SP_PROP_FILL:
fill.readIfUnset( val );
break;
@@ -1624,6 +1634,9 @@ sp_style_unset_property_attrs(SPObject *o)
if (style->solid_opacity.set) {
repr->setAttribute("solid-opacity", NULL);
}
+ if (style->vector_effect.set) {
+ repr->setAttribute("vector-effect", NULL);
+ }
if (style->fill.set) {
repr->setAttribute("fill", NULL);
}
diff --git a/src/style.h b/src/style.h
index 0e8e34145..c8192f782 100644
--- a/src/style.h
+++ b/src/style.h
@@ -215,6 +215,9 @@ public:
/** solid-opacity */
SPIScale24 solid_opacity;
+ /** vector effect */
+ SPIEnum vector_effect;
+
/** fill */
SPIPaint fill;
/** fill-opacity */