MaddTheSane / SVGKit

A Cocoa framework for rendering SVG files as Core Animation layers
http://mattrajca.com
Other
47 stars 19 forks source link

Fixing SVGGradientLayer display and -renderInContext: #11

Closed DigitalExegete closed 8 years ago

DigitalExegete commented 9 years ago

@MaddTheSane -- I've fixed the SVGKit's gradient rendering in OS X. (Haven't tested on iOS yet). Hope you get a chance to check it out. Here's a little narrative of how I found out what the issues were.

Some SVG images I am using have a Gradient to make some screws look a little more realistic, and so I tried to figure out why the gradients weren't showing up when displayed on screen, and when rendered.

As far as being displayed on screen, the gradients weren't being scaled using the viewport, but only the view box. This meant that the SVGGradientLayers were never shrunk to the same size as the use may have inputed when setting the SVGKImage's size.

When it was time for the SVGGradientLayer to be rendered in -renderInContext:, it seems that the layer.mask property was interfering with the rendering process.

I've attached two images to show the results. The first a crop of the graphic that I'm using as it's displayed on screen. The second is the image in a PDF that was drawn using -renderInContext:. screen shot 2014-12-21 at 14 23 51

screen shot 2014-12-21 at 14 24 51