summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2014-02-10 08:46:54 +0000
committerJabiertxof <jtx@jtx.marker.es>2014-02-10 08:46:54 +0000
commit977f22bf235db32be3a88baa8bde24d002714073 (patch)
treee5af7c3e8cf46f70d1317eef4523f657c90675c1
parentRemoving hack for force show red lines in bspline mode (diff)
parentFixing format-security errors in text debug code. (diff)
downloadinkscape-977f22bf235db32be3a88baa8bde24d002714073.tar.gz
inkscape-977f22bf235db32be3a88baa8bde24d002714073.zip
update to trunk
(bzr r11950.1.252)
-rw-r--r--share/extensions/Barcode/Base.py3
-rwxr-xr-xshare/extensions/hershey.py5
-rwxr-xr-xshare/extensions/polyhedron_3d.py3
-rwxr-xr-xshare/extensions/render_barcode.py1
-rwxr-xr-xshare/extensions/render_barcode_datamatrix.py3
-rwxr-xr-xshare/extensions/render_barcode_qrcode.py3
-rwxr-xr-xshare/extensions/triangle.py20
-rwxr-xr-xshare/extensions/wireframe_sphere.py16
-rw-r--r--src/2geom/generic-interval.h4
-rw-r--r--src/2geom/generic-rect.h4
-rw-r--r--src/desktop-style.cpp8
-rw-r--r--src/sp-flowtext.cpp2
-rw-r--r--src/sp-text.cpp4
-rw-r--r--src/viewbox.cpp80
-rw-r--r--src/viewbox.h18
15 files changed, 91 insertions, 83 deletions
diff --git a/share/extensions/Barcode/Base.py b/share/extensions/Barcode/Base.py
index 8fee6a996..b86185388 100644
--- a/share/extensions/Barcode/Base.py
+++ b/share/extensions/Barcode/Base.py
@@ -39,6 +39,7 @@ class Barcode(object):
self.document = param.get('document', None)
self.x = int(param.get('x', 0))
self.y = int(param.get('y', 0))
+ self.scale = param.get('scale', 1)
self.height = param.get('height', 30)
self.label = param.get('text', None)
self.string = self.encode( self.label )
@@ -77,7 +78,7 @@ class Barcode(object):
barcode = etree.Element('{%s}%s' % (svg_uri,'g'))
barcode.set('id', name)
barcode.set('style', 'fill: black;')
- barcode.set('transform', 'translate(%d,%d)' % (self.x, self.y))
+ barcode.set('transform', 'translate(%d,%d) scale(%f)' % (self.x, self.y, self.scale))
bar_offset = 0
bar_id = 1
diff --git a/share/extensions/hershey.py b/share/extensions/hershey.py
index 931e5f337..1ddabfbe0 100755
--- a/share/extensions/hershey.py
+++ b/share/extensions/hershey.py
@@ -63,6 +63,7 @@ class Hershey( inkex.Effect ):
g_attribs = {inkex.addNS('label','inkscape'):'Hershey Text' }
g = inkex.etree.SubElement(self.current_layer, 'g', g_attribs)
+ scale = self.unittouu('1px') # convert to document units
font = eval('hersheydata.' + str(self.options.fontface))
clearfont = hersheydata.futural
#Baseline: modernized roman simplex from JHF distribution.
@@ -97,7 +98,9 @@ class Hershey( inkex.Effect ):
w = wmax
# Translate group to center of view, approximately
- t = 'translate(' + str( self.view_center[0] - w/2) + ',' + str( self.view_center[1] ) + ')'
+ t = 'translate(' + str( self.view_center[0] - scale*w/2) + ',' + str( self.view_center[1] ) + ')'
+ if scale != 1:
+ t += ' scale(' + str(scale) + ')'
g.set( 'transform',t)
diff --git a/share/extensions/polyhedron_3d.py b/share/extensions/polyhedron_3d.py
index d1d6adc0f..f191d7f89 100755
--- a/share/extensions/polyhedron_3d.py
+++ b/share/extensions/polyhedron_3d.py
@@ -459,6 +459,7 @@ class Poly_3D(inkex.Effect):
get_obj_data(obj, file)#load data from the obj file
obj.set_type(so)#set the type (face or edge) as per the settings
+ scale = self.unittouu('1px') # convert to document units
st = Style(so) #initialise style
fill_col = (so.f_r, so.f_g, so.f_b) #colour tuple for the face fill
lighting = normalise( (so.lv_x,-so.lv_y,so.lv_z) ) #unit light vector
@@ -467,6 +468,8 @@ class Poly_3D(inkex.Effect):
#Put in in the centre of the current view
poly_transform = 'translate(' + str( self.view_center[0]) + ',' + str( self.view_center[1]) + ')'
+ if scale != 1:
+ poly_transform += ' scale(' + str(scale) + ')'
#we will put all the rotations in the object name, so it can be repeated in
poly_name = obj.name+':'+make_rotation_log(so)
poly_attribs = {inkex.addNS('label','inkscape'):poly_name,
diff --git a/share/extensions/render_barcode.py b/share/extensions/render_barcode.py
index ecfe215aa..7d4c671c0 100755
--- a/share/extensions/render_barcode.py
+++ b/share/extensions/render_barcode.py
@@ -45,6 +45,7 @@ class InsertBarcode(inkex.Effect):
'document' : self.document,
'x' : x,
'y' : y,
+ 'scale' : self.unittouu('1px'),
} )
if bargen is not None:
barcode = bargen.generate()
diff --git a/share/extensions/render_barcode_datamatrix.py b/share/extensions/render_barcode_datamatrix.py
index 2d28bb433..bca1d2241 100755
--- a/share/extensions/render_barcode_datamatrix.py
+++ b/share/extensions/render_barcode_datamatrix.py
@@ -665,6 +665,7 @@ class DataMatrix(inkex.Effect):
def effect(self):
+ scale = self.unittouu('1px') # convert to document units
so = self.options
rows = so.ROWS
@@ -680,7 +681,7 @@ class DataMatrix(inkex.Effect):
#INKSCAPE GROUP TO CONTAIN EVERYTHING
centre = self.view_center #Put in in the centre of the current view
- grp_transform = 'translate' + str( centre )
+ grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale
grp_name = 'DataMatrix'
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,
'transform':grp_transform }
diff --git a/share/extensions/render_barcode_qrcode.py b/share/extensions/render_barcode_qrcode.py
index 8147d49a6..7b4895195 100755
--- a/share/extensions/render_barcode_qrcode.py
+++ b/share/extensions/render_barcode_qrcode.py
@@ -1047,6 +1047,7 @@ class QRCodeInkscape(inkex.Effect):
def effect(self):
+ scale = self.unittouu('1px') # convert to document units
so = self.options
if so.TEXT == '': #abort if converting blank text
@@ -1057,7 +1058,7 @@ class QRCodeInkscape(inkex.Effect):
so.TEXT = unicode(so.TEXT, so.input_encode)
centre = self.view_center #Put in in the centre of the current view
- grp_transform = 'translate' + str( centre )
+ grp_transform = 'translate' + str( centre ) + ' scale(%f)' % scale
grp_name = 'QR Code: '+so.TEXT
grp_attribs = {inkex.addNS('label','inkscape'):grp_name,
'transform':grp_transform }
diff --git a/share/extensions/triangle.py b/share/extensions/triangle.py
index 81945f370..019db3147 100755
--- a/share/extensions/triangle.py
+++ b/share/extensions/triangle.py
@@ -69,7 +69,7 @@ def is_valid_tri_from_sides(a,b,c):#check whether triangle with sides a,b,c is v
return (a+b)>c and (a+c)>b and (b+c)>a and a > 0 and b> 0 and c>0#two sides must always be greater than the third
#no zero-length sides, no degenerate case
-def draw_tri_from_3_sides(s_a, s_b, s_c, offset, parent): #draw a triangle from three sides (with a given offset
+def draw_tri_from_3_sides(s_a, s_b, s_c, offset, width, parent): #draw a triangle from three sides (with a given offset
if is_valid_tri_from_sides(s_a,s_b,s_c):
a_b = angle_from_3_sides(s_a, s_c, s_b)
@@ -82,7 +82,7 @@ def draw_tri_from_3_sides(s_a, s_b, s_c, offset, parent): #draw a triangle from
offy = c[1]/2 #c is the highest point
offset = ( offset[0]-offx , offset[1]-offy ) #add the centre of the triangle to the offset
- draw_SVG_tri(a, b, c , offset, 2, 'Triangle', parent)
+ draw_SVG_tri(a, b, c , offset, width, 'Triangle', parent)
else:
sys.stderr.write('Error:Invalid Triangle Specifications.\n')
@@ -122,12 +122,16 @@ class Grid_Polar(inkex.Effect):
tri = self.current_layer
offset = (self.view_center[0],self.view_center[1]) #the offset require to centre the triangle
+ self.options.s_a = self.unittouu(str(self.options.s_a) + 'px')
+ self.options.s_b = self.unittouu(str(self.options.s_b) + 'px')
+ self.options.s_c = self.unittouu(str(self.options.s_c) + 'px')
+ stroke_width = self.unittouu('2px')
if self.options.mode == '3_sides':
s_a = self.options.s_a
s_b = self.options.s_b
s_c = self.options.s_c
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
elif self.options.mode == 's_ab_a_c':
s_a = self.options.s_a
@@ -135,7 +139,7 @@ class Grid_Polar(inkex.Effect):
a_c = self.options.a_c*pi/180 #in rad
s_c = third_side_from_enclosed_angle(s_a,s_b,a_c)
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
elif self.options.mode == 's_ab_a_a':
s_a = self.options.s_a
@@ -159,13 +163,13 @@ class Grid_Polar(inkex.Effect):
if not(error) and (a_b < pi) and (a_c < pi): #check that the solution is valid, if so draw acute solution
s_c = third_side_from_enclosed_angle(s_a,s_b,a_c)
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
if not(error) and ((a_b > pi) or (a_c > pi) or ambiguous):#we want the obtuse solution
a_b = pi - a_b
a_c = pi - a_a - a_b
s_c = third_side_from_enclosed_angle(s_a,s_b,a_c)
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
elif self.options.mode == 's_a_a_ab':
s_a = self.options.s_a
@@ -176,7 +180,7 @@ class Grid_Polar(inkex.Effect):
s_b = s_a*sin(a_b)/sin(a_a)
s_c = s_a*sin(a_c)/sin(a_a)
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
elif self.options.mode == 's_c_a_ab':
s_c = self.options.s_c
@@ -187,7 +191,7 @@ class Grid_Polar(inkex.Effect):
s_a = s_c*sin(a_a)/sin(a_c)
s_b = s_c*sin(a_b)/sin(a_c)
- draw_tri_from_3_sides(s_a, s_b, s_c, offset, tri)
+ draw_tri_from_3_sides(s_a, s_b, s_c, offset, stroke_width, tri)
if __name__ == '__main__':
e = Grid_Polar()
diff --git a/share/extensions/wireframe_sphere.py b/share/extensions/wireframe_sphere.py
index 5804a1b45..bcd676dc4 100755
--- a/share/extensions/wireframe_sphere.py
+++ b/share/extensions/wireframe_sphere.py
@@ -63,10 +63,10 @@ import simplestyle
inkex.localize()
#SVG OUTPUT FUNCTIONS ================================================
-def draw_SVG_ellipse((rx, ry), (cx, cy), parent, start_end=(0,2*pi),transform='' ):
+def draw_SVG_ellipse((rx, ry), (cx, cy), width, parent, start_end=(0,2*pi),transform='' ):
style = { 'stroke' : '#000000',
- 'stroke-width' : '1',
+ 'stroke-width' : str(width),
'fill' : 'none' }
circ_attribs = {'style':simplestyle.formatStyle(style),
inkex.addNS('cx','sodipodi') :str(cx),
@@ -120,8 +120,10 @@ class Wireframe_Sphere(inkex.Effect):
else:
flip = '' #no flip
+ so.RADIUS = self.unittouu(str(so.RADIUS) + 'px')
so.TILT = abs(so.TILT)*(pi/180) #Convert to radians
so.ROT_OFFSET = so.ROT_OFFSET*(pi/180) #Convert to radians
+ stroke_width = self.unittouu('1px')
EPSILON = 0.001 #add a tiny value to the ellipse radii, so that if we get a zero radius, the ellipse still shows up as a line
@@ -174,7 +176,7 @@ class Wireframe_Sphere(inkex.Effect):
#finally, draw the line of longitude
#the centre is always at the centre of the sphere
- draw_SVG_ellipse( ( minorRad, so.RADIUS ), (0,0), grp_long , start_end,transform)
+ draw_SVG_ellipse( ( minorRad, so.RADIUS ), (0,0), stroke_width, grp_long , start_end,transform)
# LINES OF LATITUDE
if so.NUM_LAT > 0:
@@ -201,18 +203,18 @@ class Wireframe_Sphere(inkex.Effect):
if so.HIDE_BACK:
if lat_angle > so.TILT: #this LoLat is partially or fully visible
if lat_angle > pi-so.TILT: #this LoLat is fully visible
- draw_SVG_ellipse((majorRad, minorRad), (cx,cy), grp_lat)
+ draw_SVG_ellipse((majorRad, minorRad), (cx,cy), stroke_width, grp_lat)
else: #this LoLat is partially visible
proportion = -(acos( tan(lat_angle - pi/2)/tan(pi/2 - so.TILT)) )/pi + 1
start_end = ( pi/2 - proportion*pi, pi/2 + proportion*pi ) #make the start and end angles (mirror image around pi/2)
- draw_SVG_ellipse((majorRad, minorRad), (cx,cy), grp_lat, start_end)
+ draw_SVG_ellipse((majorRad, minorRad), (cx,cy), stroke_width, grp_lat, start_end)
else: #just draw the full lines of latitude
- draw_SVG_ellipse((majorRad, minorRad), (cx,cy), grp_lat)
+ draw_SVG_ellipse((majorRad, minorRad), (cx,cy), stroke_width, grp_lat)
#THE HORIZON CIRCLE
- draw_SVG_ellipse((so.RADIUS, so.RADIUS), (0,0), grp) #circle, centred on the sphere centre
+ draw_SVG_ellipse((so.RADIUS, so.RADIUS), (0,0), stroke_width, grp) #circle, centred on the sphere centre
if __name__ == '__main__':
e = Wireframe_Sphere()
diff --git a/src/2geom/generic-interval.h b/src/2geom/generic-interval.h
index 87d3be2c1..41eaf59b0 100644
--- a/src/2geom/generic-interval.h
+++ b/src/2geom/generic-interval.h
@@ -315,14 +315,14 @@ inline GenericOptInterval<C> operator&(GenericInterval<C> const &a, GenericInter
return GenericOptInterval<C>(a) & GenericOptInterval<C>(b);
}
-#ifdef _GLIBCXX_IOSTREAM
+//#ifdef _GLIBCXX_IOSTREAM
template <typename C>
inline std::ostream &operator<< (std::ostream &os,
Geom::GenericInterval<C> const &I) {
os << "Interval("<<I.min() << ", "<<I.max() << ")";
return os;
}
-#endif
+//#endif
} // namespace Geom
#endif // !LIB2GEOM_SEEN_GENERIC_INTERVAL_H
diff --git a/src/2geom/generic-rect.h b/src/2geom/generic-rect.h
index bb6f2d2b8..9ad0e60b0 100644
--- a/src/2geom/generic-rect.h
+++ b/src/2geom/generic-rect.h
@@ -483,13 +483,13 @@ inline bool GenericRect<C>::contains(OptCRect const &r) const {
return !r || contains(*r);
}
-#ifdef _GLIBCXX_IOSTREAM
+//#ifdef _GLIBCXX_IOSTREAM
template <typename C>
inline std::ostream &operator<<(std::ostream &out, GenericRect<C> const &r) {
out << "X: " << r[X] << " Y: " << r[Y];
return out;
}
-#endif
+//#endif
} // end namespace Geom
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 00b9db7d0..bab9635a9 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -587,11 +587,15 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
paint_res->colorSet = paint->colorSet;
paint_res->currentcolor = paint->currentcolor;
if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server
+ gchar const *string = NULL; // memory leak results if style->get* called inside sp_style_set_to_uri_string.
if (isfill) {
- sp_style_set_to_uri_string (style_res, true, style->getFillURI());
+ string = style->getFillURI();
+ sp_style_set_to_uri_string (style_res, true, string);
} else {
- sp_style_set_to_uri_string (style_res, false, style->getStrokeURI());
+ string = style->getStrokeURI();
+ sp_style_set_to_uri_string (style_res, false, string);
}
+ if(string)g_free((void *) string);
}
paint_res->set = paint_effectively_set;
style_res->fill_rule.computed = style->fill_rule.computed; // no averaging on this, just use the last one
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index 0cadb4345..b4fd54ee4 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -447,7 +447,7 @@ void SPFlowtext::rebuildLayout()
_buildLayoutInput(this, exclusion_shape, &shapes, &pending_line_break_object);
delete exclusion_shape;
layout.calculateFlow();
- //g_print(layout.dumpAsText().c_str());
+ //g_print("%s", layout.dumpAsText().c_str());
}
void SPFlowtext::_clearFlow(Inkscape::DrawingGroup *in_arena)
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index ef46e890f..bbc7ec43d 100644
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -518,12 +518,12 @@ void SPText::rebuildLayout()
if (SP_IS_TEXTPATH(child)) {
SPTextPath const *textpath = SP_TEXTPATH(child);
if (textpath->originalPath != NULL) {
- //g_print(layout.dumpAsText().c_str());
+ //g_print("%s", layout.dumpAsText().c_str());
layout.fitToPathAlign(textpath->startOffset, *textpath->originalPath);
}
}
}
- //g_print(layout.dumpAsText().c_str());
+ //g_print("%s", layout.dumpAsText().c_str());
// set the x,y attributes on role:line spans
for (SPObject *child = firstChild() ; child ; child = child->getNext() ) {
diff --git a/src/viewbox.cpp b/src/viewbox.cpp
index 2314cbf6a..e46fe005c 100644
--- a/src/viewbox.cpp
+++ b/src/viewbox.cpp
@@ -4,8 +4,9 @@
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com> (code extracted from symbol.cpp)
* Tavmjong Bah <tavmjong@free.fr>
+ * Johan Engelen
*
- * Copyright (C) 2013 Tavmjong Bah, authors
+ * Copyright (C) 2013-2014 Tavmjong Bah, authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
@@ -18,46 +19,40 @@
#include "enums.h"
#include "sp-item.h"
-SPViewBox::SPViewBox() {
-
- this->viewBox_set = FALSE;
-
- this->aspect_set = FALSE;
- this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec;
- this->aspect_clip = SP_ASPECT_MEET;
-
- this->c2p = Geom::identity();
-}
-
-SPViewBox::~SPViewBox() {
+SPViewBox::SPViewBox()
+ : viewBox_set(false)
+ , viewBox()
+ , aspect_set(false)
+ , aspect_align(SP_ASPECT_XMID_YMID) // Default per spec
+ , aspect_clip(SP_ASPECT_MEET)
+ , c2p(Geom::identity())
+{
}
void SPViewBox::set_viewBox(const gchar* value) {
if (value) {
- double x, y, width, height;
- char *eptr;
+ gchar *eptr = const_cast<gchar*>(value); // const-cast necessary because of const-incorrect interface definition of g_ascii_strtod
- eptr = (gchar *) value;
- x = g_ascii_strtod (eptr, &eptr);
+ double x = g_ascii_strtod (eptr, &eptr);
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) {
eptr++;
}
- y = g_ascii_strtod (eptr, &eptr);
+ double y = g_ascii_strtod (eptr, &eptr);
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) {
eptr++;
}
- width = g_ascii_strtod (eptr, &eptr);
+ double width = g_ascii_strtod (eptr, &eptr);
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) {
eptr++;
}
- height = g_ascii_strtod (eptr, &eptr);
+ double height = g_ascii_strtod (eptr, &eptr);
while (*eptr && ((*eptr == ',') || (*eptr == ' '))) {
eptr++;
@@ -66,15 +61,15 @@ void SPViewBox::set_viewBox(const gchar* value) {
if ((width > 0) && (height > 0)) {
/* Set viewbox */
this->viewBox = Geom::Rect::from_xywh(x, y, width, height);
- this->viewBox_set = TRUE;
+ this->viewBox_set = true;
} else {
- this->viewBox_set = FALSE;
+ this->viewBox_set = false;
}
} else {
- this->viewBox_set = FALSE;
+ this->viewBox_set = false;
}
- // The C++ way?
+ // The C++ way? -- not necessarily using iostreams
// std::string sv( value );
// std::replace( sv.begin(), sv.end(), ',', ' ');
// std::stringstream ss( sv );
@@ -85,18 +80,14 @@ void SPViewBox::set_viewBox(const gchar* value) {
void SPViewBox::set_preserveAspectRatio(const gchar* value) {
/* Do setup before, so we can use break to escape */
- this->aspect_set = FALSE;
+ this->aspect_set = false;
this->aspect_align = SP_ASPECT_XMID_YMID; // Default per spec
this->aspect_clip = SP_ASPECT_MEET;
if (value) {
- int len;
- gchar c[256];
- const gchar *p, *e;
- unsigned int align, clip;
- p = value;
+ const gchar *p = value;
- while (*p && *p == 32) {
+ while (*p && (*p == 32)) {
p += 1;
}
@@ -104,23 +95,25 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) {
return;
}
- e = p;
+ const gchar *e = p;
- while (*e && *e != 32) {
+ while (*e && (*e != 32)) {
e += 1;
}
- len = e - p;
+ int len = e - p;
- if (len > 8) {
+ if ( (len > 8) || (len < 256) ) { // note the extra check for buffer overflow
return;
}
+ gchar c[256];
memcpy (c, value, len);
c[len] = 0;
/* Now the actual part */
+ unsigned int align = SP_ASPECT_NONE;
if (!strcmp (c, "none")) {
align = SP_ASPECT_NONE;
} else if (!strcmp (c, "xMinYMin")) {
@@ -145,9 +138,9 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) {
return;
}
- clip = SP_ASPECT_MEET;
+ unsigned int clip = SP_ASPECT_MEET;
- while (*e && *e == 32) {
+ while (*e && (*e == 32)) {
e += 1;
}
@@ -161,7 +154,7 @@ void SPViewBox::set_preserveAspectRatio(const gchar* value) {
}
}
- this->aspect_set = TRUE;
+ this->aspect_set = true;
this->aspect_align = align;
this->aspect_clip = clip;
}
@@ -178,11 +171,10 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) {
// std::cout << " width: " << width << " height: " << height << std::endl;
if (this->aspect_align != SP_ASPECT_NONE) {
- double scalex, scaley, scale;
/* Things are getting interesting */
- scalex = in.width() / this->viewBox.width();
- scaley = in.height() / this->viewBox.height();
- scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley);
+ double scalex = in.width() / this->viewBox.width();
+ double scaley = in.height() / this->viewBox.height();
+ double scale = (this->aspect_clip == SP_ASPECT_MEET) ? MIN (scalex, scaley) : MAX (scalex, scaley);
width = this->viewBox.width() * scale;
height = this->viewBox.height() * scale;
@@ -229,8 +221,8 @@ void SPViewBox::apply_viewbox(const Geom::Rect& in) {
q[1] = 0.0;
q[2] = 0.0;
q[3] = height / this->viewBox.height();
- q[4] = -this->viewBox.left() * q[0] + x;
- q[5] = -this->viewBox.top() * q[3] + y;
+ q[4] = x - q[0] * this->viewBox.left();
+ q[5] = y - q[3] * this->viewBox.top();
// std::cout << " q\n" << q << std::endl;
diff --git a/src/viewbox.h b/src/viewbox.h
index 24356ed17..1898cd98f 100644
--- a/src/viewbox.h
+++ b/src/viewbox.h
@@ -7,8 +7,9 @@
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com> (code extracted from sp-symbol.h)
* Tavmjong Bah
+ * Johan Engelen
*
- * Copyright (C) 2013 Tavmjong Bah, authors
+ * Copyright (C) 2013-2014 Tavmjong Bah, authors
*
* Released under GNU GPL, read the file 'COPYING' for more information
*
@@ -17,26 +18,21 @@
#include <2geom/rect.h>
#include <glib.h>
-namespace Geom {
-class Rect;
-}
class SPItemCtx;
class SPViewBox {
- public:
-
+public:
SPViewBox();
- ~SPViewBox();
/* viewBox; */
- unsigned int viewBox_set : 1;
+ bool viewBox_set;
Geom::Rect viewBox; // Could use optrect
/* preserveAspectRatio */
- unsigned int aspect_set : 1;
- unsigned int aspect_align : 4;
- unsigned int aspect_clip : 1;
+ bool aspect_set;
+ unsigned int aspect_align; // enum
+ unsigned int aspect_clip; // enum
/* Child to parent additional transform */
Geom::Affine c2p;