diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2014-02-10 08:46:54 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2014-02-10 08:46:54 +0000 |
| commit | 977f22bf235db32be3a88baa8bde24d002714073 (patch) | |
| tree | e5af7c3e8cf46f70d1317eef4523f657c90675c1 /share | |
| parent | Removing hack for force show red lines in bspline mode (diff) | |
| parent | Fixing format-security errors in text debug code. (diff) | |
| download | inkscape-977f22bf235db32be3a88baa8bde24d002714073.tar.gz inkscape-977f22bf235db32be3a88baa8bde24d002714073.zip | |
update to trunk
(bzr r11950.1.252)
Diffstat (limited to 'share')
| -rw-r--r-- | share/extensions/Barcode/Base.py | 3 | ||||
| -rwxr-xr-x | share/extensions/hershey.py | 5 | ||||
| -rwxr-xr-x | share/extensions/polyhedron_3d.py | 3 | ||||
| -rwxr-xr-x | share/extensions/render_barcode.py | 1 | ||||
| -rwxr-xr-x | share/extensions/render_barcode_datamatrix.py | 3 | ||||
| -rwxr-xr-x | share/extensions/render_barcode_qrcode.py | 3 | ||||
| -rwxr-xr-x | share/extensions/triangle.py | 20 | ||||
| -rwxr-xr-x | share/extensions/wireframe_sphere.py | 16 |
8 files changed, 35 insertions, 19 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() |
