Skip to content

Commit

Permalink
Remove useless scale parameter from set_context_size
Browse files Browse the repository at this point in the history
Related to #107.
  • Loading branch information
liZe committed May 29, 2019
1 parent 517fb8c commit c030149
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 19 deletions.
9 changes: 0 additions & 9 deletions cairosvg/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,16 +240,7 @@ def transform(surface, string, gradient=None):
if len(values) == 1:
values = 2 * values
matrix.scale(*values)
apply_matrix_transform(surface, matrix, gradient)


def apply_matrix_transform(surface, matrix, gradient=None):
"""Apply a ``matrix`` to ``surface`` or ``gradient`` if supplied.
When the matrix is not invertible, this function clips the context to an
empty path instead of raising an exception.
"""
try:
matrix.invert()
except cairo.Error:
Expand Down
13 changes: 4 additions & 9 deletions cairosvg/surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
filter_, gradient_or_pattern, linear_gradient, marker, mask, paint_mask,
parse_all_defs, pattern, prepare_filter, radial_gradient, use)
from .helpers import (
UNITS, PointError, apply_matrix_transform, clip_rect, node_format,
normalize, paint, preserve_ratio, size, transform)
UNITS, PointError, clip_rect, node_format, normalize, paint,
preserve_ratio, size, transform)
from .image import image
from .parser import Tree
from .path import draw_markers, path
Expand Down Expand Up @@ -205,7 +205,7 @@ def __init__(self, tree, output, dpi, parent_surface=None,
self.context.scale(
self.device_units_per_user_units, self.device_units_per_user_units)
# Initial, non-rounded dimensions
self.set_context_size(width, height, viewbox, scale, tree)
self.set_context_size(width, height, viewbox, tree)
self.context.move_to(0, 0)
self.draw(tree)

Expand All @@ -229,7 +229,7 @@ def _create_surface(self, width, height):
cairo_surface = self.surface_class(self.output, width, height)
return cairo_surface, width, height

def set_context_size(self, width, height, viewbox, scale, tree):
def set_context_size(self, width, height, viewbox, tree):
"""Set the Cairo context size, set the SVG viewport size."""
if viewbox:
rect_x, rect_y = viewbox[0:2]
Expand All @@ -254,11 +254,6 @@ def set_context_size(self, width, height, viewbox, scale, tree):
self.context_width = rect_width / scale_x
self.context_height = rect_height / scale_y

if scale != 1:
matrix = cairo.Matrix()
matrix.scale(scale, scale)
apply_matrix_transform(self, matrix)

def finish(self):
"""Read the surface content."""
self.cairo.finish()
Expand Down
2 changes: 1 addition & 1 deletion cairosvg/svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ def svg(surface, node):
"""Draw a svg ``node``."""
if node.parent is not None:
width, height, viewbox = node_format(surface, node)
surface.set_context_size(width, height, viewbox, 1, node)
surface.set_context_size(width, height, viewbox, node)

0 comments on commit c030149

Please sign in to comment.