Git Product home page Git Product logo

pocketsvg's Introduction

PocketSVG

Platforms Build Status Swift Package Manager CocoaPods Compatible Carthage compatible Code Coverage code size license Swift Forums

A simple toolkit for displaying and manipulating SVGs on iOS and macOS in a performant manner.

The goal of this project is not to be a fully compliant SVG parser/renderer. But rather to use SVG as a format for serializing CG/UIPaths, meaning it only supports SVG features that can be represented by CG/UIPaths.

Thoroughly documented.

Features

  • Support for SVG elements: path, line, polyline, polygon, rect, circle, ellipse
  • Support for SVG named colors.
  • Fully working iOS and macOS demos.
  • Straightforward API for typical SVG rendering as a UIImageView/NSImageView or CALayer subclass.
  • Access every shape within your SVG as a CGPath for more fine-grained manipulation.

Installation

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/pocketsvg/PocketSVG.git", .upToNextMajor(from: "2.6.0"))
]

Cocoapods

Add this to your Podfile:

pod 'PocketSVG', '~> 2.6'

Then run pod install

Carthage

Add this to your Cartfile:

github "pocketsvg/PocketSVG" >= 2.7.2

Then run carthage update --use-xcframeworks

Usage

Render an SVG file using SVGImageView

let url = Bundle.main.url(forResource: "tiger", withExtension: "svg")!
let svgImageView = SVGImageView.init(contentsOf: url)
svgImageView.frame = view.bounds
svgImageView.contentMode = .scaleAspectFit
view.addSubview(svgImageView)

Output image

Note: By default, SVGLayer has shouldRasterize set to YES when running on iOS. If you need to animate changes to the layer's transform you might want to reset that to NO.

Manually render each path of an SVG file using CAShapeLayer

view.backgroundColor = .white

let svgURL = Bundle.main.url(forResource: "tiger", withExtension: "svg")!
let paths = SVGBezierPath.pathsFromSVG(at: svgURL)
let tigerLayer = CALayer()
for (index, path) in paths.enumerated() {
    let shapeLayer = CAShapeLayer()
    shapeLayer.path = path.cgPath
    if index%2 == 0 {
        shapeLayer.fillColor = UIColor.black.cgColor
    }
    else if index%3 == 0 {
        shapeLayer.fillColor = UIColor.darkGray.cgColor
    }
    else {
        shapeLayer.fillColor = UIColor.gray.cgColor
    }
    tigerLayer.addSublayer(shapeLayer)
}

var transform = CATransform3DMakeScale(0.4, 0.4, 1.0)
transform = CATransform3DTranslate(transform, 200, 400, 0)
tigerLayer.transform = transform
view.layer.addSublayer(tigerLayer)

Output image

Contributing

Bug Reports & Feature Requests

Please use the issue tracker to report any bugs or file feature requests.

Developing

PRs are welcome.

pocketsvg's People

Contributors

anback avatar arielelkin avatar cl3m avatar codeforrabbit avatar cysp avatar danicoello avatar elisar4 avatar fjolnir avatar fpillet avatar georgmay avatar halseth avatar hamin avatar iamdoron avatar kwabford avatar locknic avatar mcianni avatar mciuba avatar mossuru777 avatar nathanfjohnson avatar nealyoung avatar noahsark769 avatar randomsequence avatar samus avatar sbaropeak avatar scottsykora avatar sebastianludwig avatar solidfox avatar yonilevy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pocketsvg's Issues

parsing problem

hi, thanks for sharing pocketsvg - it's great.

found a small issue which may cause parsing problems:
in file PocketSVG.m line 117 there should be a space in "d=" like
NSArray *components = [mySVGString componentsSeparatedByString:@" d="];
otherwise the code tries to parse standard svg elements like id="...
i had this problem with svg files generated from inkscape.

regards, klaus

PocketSVG Error: No d attribute found in SVG file

Hi 你好
I have a svg file

<svg xmlns="http://www.w3.org/2000/svg" width="138" height="138"><rect x="0" y="0" width="100%" height="100%" fill="rgb(131, 201, 59)"  /> ... </svg>

my swift code

            let patch = PocketSVG.pathFromSVGFileNamed("test").takeUnretainedValue()
            let myShapeLayer = CAShapeLayer()
            myShapeLayer.path = patch
            self.view.layer.addSublayer(myShapeLayer)

then

PocketSVG Error: No d attribute found in SVG file.
PocketSVG Error: Path string is empty of tokens

Failed to parse.

Thanks for your great code!

I tried to use it, however, I got the "PocketSVG Error: Invalid parameter count in L style token" failed message.



Created by potrace 1.11, written by Peter Selinger 2001-2013




This is my svg file.
Would you please let me know what is the problem?

Regards,
Yun.

Multiple paths

I create the SVG file and read it using the example project. I can only see the last path in the file. How can I get all the paths in the SVG?

Gracefully handle missing SVG files

Currently, when I use UIImage+SVG (https://github.com/Label305/UIImage-SVG), powered by PocketSVG, to load an SVG that cannot be found in the application bundle, I get a horrible crash:

screen shot 2014-05-15 at 14 51 42

Stacktrace:

in -[RXMLElement tag] at BLAH/Pods/RaptureXML/RaptureXML/RXMLElement.m:145
in -[PocketSVG parseSVG:] at BLAH/Pods/UIImage+SVG/Classes/PocketSVG.m:198
in -[PocketSVG initFromSVGFile:] at BLAH/Pods/UIImage+SVG/Classes/PocketSVG.m:115
in +[UIImage(SVG) imageWithSVGNamed:targetSize:fillColor:cache:] at BLAH/Pods/UIImage+SVG/Classes/UIImage+SVG.m:38

During development and otherwise, it's useful to have resources missing. All I would do is log those to the console as warnings and fix them up later on.

How can I handle these exceptions for now?

Or is this actually an issue with RaptureXML parser; that it doesn't throw exceptions?

SVG file not rendering Ellipses

I'm rendering the following svg file (compressed into a zip file because github doesn't allow uploading svg files)
firetruck.svg.zip

and what I get is the following

simulator screen shot nov 30 2016 9 06 42 pm

It seems that the library doesn't support the ellipse shape, am I correct?

PocketSVG Line Width

I have tried everything to change the line width of the path.
PocketSVG *svgPathDrawing = [[PocketSVG alloc] initFromSVGFileNamed:svgPath];
svgPathDrawing.bezier.lineWidth = 1;

Even trying to change the width of the CAShapeLayer is not working.

File Not Loaded. It passed by SVN V1.1.

I want to load the big size of SVG file whose _viewBox is "0 0 6585.629 3663.362" is not loaded.
Can you tell the issue why this file is not loaded on my view.

Few finding in this project:
I found that the code is load for rectangle tag but, but you have added that code in "SVGEngine" line#658 "NSNumberFormatter *fmt" is not initialed "dispatch_once" when I initial than I can show the rect tag.

Not displaying correct shape?

I downloaded a play icon svg, but when I render it, it shows up as a square.

Here's the SVG markup

<?xml version="1.0" ?>
<svg height="48" viewBox="0 0 48 48" width="48" xmlns="http://www.w3.org/2000/svg">
  <path d="M-838-2232H562v3600H-838z" fill="none"/>
  <path d="M16 10v28l22-14z"/>
  <path d="M0 0h48v48H0z" fill="none"/>
</svg>

Here's the swift code

let playIconPath = PocketSVG.pathFromSVGFileNamed("play").takeUnretainedValue()
let iconShapeLayer = CAShapeLayer()
iconShapeLayer.path = playIconPath
iconShapeLayer.strokeColor = UIColor.whiteColor().CGColor
iconShapeLayer.lineWidth = 3
iconShapeLayer.fillColor = UIColor.whiteColor().CGColor
iconShapeLayer.position.x = CGRectGetMidX(self.frame)
iconShapeLayer.position.y = CGRectGetMidY(self.frame)
self.view!.layer.addSublayer(iconShapeLayer)

Here's a screenshot of what I see...

screen shot 2016-06-16 at 9 48 05 am

About supporting iOS 8

I would like to use PocketSVG in my project, however I notice that in the .podspec file, the iOS deployment target has been set to iOS 9.

Is there any reason that make PocketSVG drop support for iOS 8?
If I fork it and change the deployment target to iOS 8, what problem will I facing?

Thx

Implement support for named colors

I tried to load an svn with a 'black' stroke. The SVGEngine tries to interpret this as a triplet, and asserts.

According to section 11.2 of SVG1.1, colour names are valid.

The error is around SVGEngine:287.

'none' looks to be handled correctly, but not named colours.

Broken.svg.zip

I'm raising this for your edification, so priority is very low, and I'll be happy with a won't fix. Since I'm only looking for the path, I'll just preprocess my svgs to strip out the colours.

Unable to build the version 2.0.0. Its giving linker command failed with exit code 1 (use -v to see invocation)

Undefined symbols for architecture arm64:
"operator new(unsigned long)", referenced from:
std::__1::__split_buffer<float, std::__1::allocator&>::__split_buffer(unsigned long, unsigned long, std::__1::allocator&) in libPocketSVG.a(SVGEngine.o)
"std::__1::__vector_base_common::__throw_length_error() const", referenced from:
void std::__1::vector<float, std::__1::allocator >::__push_back_slow_path<float const&>(float const&&&) in libPocketSVG.a(SVGEngine.o)
"___cxa_begin_catch", referenced from:
__clang_call_terminate in libPocketSVG.a(SVGEngine.o)
"operator delete(void
)", referenced from:
std::__1::__vector_base<float, std::__1::allocator >::__vector_base() in libPocketSVG.a(SVGEngine.o)
std::__1::__split_buffer<float, std::__1::allocator&>::
__split_buffer() in libPocketSVG.a(SVGEngine.o)
"std::terminate()", referenced from:
___clang_call_terminate in libPocketSVG.a(SVGEngine.o)
"gxx_personality_v0", referenced from:
svgParser::svgParser(NSString
) in libPocketSVG.a(SVGEngine.o)
svgParser::svgParser(NSString
) in libPocketSVG.a(SVGEngine.o)
svgParser::parse(NSMapTable
autoreleasing) in libPocketSVG.a(SVGEngine.o)
svgParser::readPathTag() in libPocketSVG.a(SVGEngine.o)
svgParser::readPolygonTag() in libPocketSVG.a(SVGEngine.o)
svgParser::readRectTag() in libPocketSVG.a(SVGEngine.o)
svgParser::pushGroup(NSDictionary
) in libPocketSVG.a(SVGEngine.o)
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Note:- When adding s.library = 'xml2', 'stdc++' to the podspec the linker error get resolved.

Found float where expecting command at token 0 in path new,0,0,30.667,47.

Can you explain the steps I should take if I wish to export a .svg from Illustrator?

Here is my SVG code:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="30.667px" height="47px" viewBox="0 0 30.667 47" enable-background="new 0 0 30.667 47" xml:space="preserve">
<line fill="none" stroke="#000000" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" x1="12.67" y1="34.073" x2="21.863" y2="8.704"/>
</svg>

I'm receiving the error:
*** PocketSVG Error: Path string parse error: found float where expecting command at token 0 in path new,0,0,30.667,47.

A few missing SVG commands

Can you add support for the following SVG commands?

Q = quadratic Bézier curve
T = smooth quadratic Bézier curveto
A = elliptical Arc

A simple path taken from SVG is given below for testing

d="M318.357,35.882 Q313.38,28.763 308.97,26.716 C308.088,26.306 307.206,25.928 306.292,25.582 308.088,30.527 309.096,35.756 309.348,41.332 309.411,42.497 309.442,43.663 309.411,44.828 309.348,53.018 309.19,61.208 308.938,69.398 308.718,77.305 307.111,84.991 304.15,92.52 301.095,100.269 296.275,105.939 289.691,109.561 287.455,110.79 285.124,111.672 282.635,112.239 L282.509,112.365 C283.738,113.94 285.187,115.263 286.856,116.334 290.479,118.57 294.448,118.948 298.763,117.468 303.079,115.987 306.481,112.365 308.938,106.6 311.332,100.962 313.38,95.103 315.112,89.023 316.782,83.196 317.884,77.116 318.451,70.847 318.924,65.303 319.27,59.728 319.491,54.089 319.617,50.152 319.459,45.899 319.018,41.332 318.861,39.694 318.64,38.024 318.42,36.323 318.388,36.166 318.388,36.04 318.357,35.882z"

Thanks!

How install PocketSVG version 2?

Hello.
pod PocketSVG - install version 0.7
pod 'PocketSVG', '~>2.0' - not work
how install version 2.0 in my project?
Thanks!

Getting path is slow

Hi,

I am using pathFromSVGFileNamed and it takes 50-90 ms for a svg to get path. I am working with multiple svg images so it became really slow. There is something wrong or it is normal to take a long time to render?

Thanks

typo in SVGLayer.m

File SVGLayer.m .
Line 126 :
"- (void)setSvgName:(NSString *)svgName {
....
NSPredicate * const pred = [NSPredicate predicateWithFormat:@"lastPathComponent LIKE[c] %@", [aFileName stringByAppendingPathExtension:@"svg"]];
"

I suppose it should be :
"- (void)setSvgName:(NSString *)svgName {
....
NSPredicate * const pred = [NSPredicate predicateWithFormat:@"lastPathComponent LIKE[c] %@", [svgName stringByAppendingPathExtension:@"svg"]];
"
error : "Use of undeclared identifier 'aFileName'"

I have installed PocketSVG pod latest version.
Somehow this issue not appear in build time.I got it on "Report navigation" interface builder section when tried use some custom IBDesignable view(Not from pod).
In the result in Interface builder IBDesignable views always failed.

The proper way to convert SVG to UIImage

I'm trying to pre-render SVG in background thread and save it to disk as PNG for later using.
So I need to convert SVG to UIImage, currently I found a way to do that is making a snapshot of SVGImageView:

private func snapshotImage(for view: UIView) -> UIImage? {
    UIGraphicsBeginImageContextWithOptions(view.bounds.size, false, UIScreen.main.scale)
    guard let context = UIGraphicsGetCurrentContext() else { return nil }
    view.layer.render(in: context)
    let image = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image
}

Since SVGImageView use SVGLayer as it's layerClass, SVGLayer render SVG in the layout process, it need to layout before making a snapshot:

let imageView = UIImageView()

imageView.translatesAutoresizingMaskIntoConstraints = false
imageView.contentMode = .scaleAspectFit
view.addSubview(imageView)

imageView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
imageView.leftAnchor.constraint(equalTo: view.leftAnchor).isActive = true
imageView.rightAnchor.constraint(equalTo: view.rightAnchor).isActive = true

DispatchQueue.global(qos: .background).async {
    let url = Bundle.main.url(forResource: "tiger", withExtension: "svg")!
    //initialise a view that parses and renders an SVG file in the bundle:
    let svgImageView = SVGImageView(contentsOf: url)
    //layout the view:
    svgImageView.frame = CGRect(x: 0, y: 0, width: 100, height: 100)
    svgImageView.layoutIfNeeded()

    let image = self.snapshotImage(for: svgImageView)

    DispatchQueue.main.async {
        imageView.image = image
    }
}

I wonder if there is a better way to do that?
Something like drawing SVGLayer or SVGBezierPath on image context directly?

How can I use pathFromDAttribute in V2?

Hey there, we had an app that was using pathFromDAttribute in PocketSVG v1. We tried to upgrade the Pod to v2 and noticed this function is missing. How can we achieve this functionality in V2?

Resizable SVG

I don't see any way to tell PocketSVG which SVG size I want.

When use svg files exported by Sketch

The SVG file exported by Sketch has following content:
" <path d="M161,321 C249.365564,321 321,249.365564...."
So,to suport this kind of SVG file, I think the PocketSVG.m should be changed like:

NSString* const separatorCharString = @"-,CcMmLlHhVvZzqQaAsS";

change to:

NSString* const separatorCharString = @"-, CcMmLlHhVvZzqQaAsS";

2.in "-(NSString *)parseSVGNamed:(NSString *)nameOfSVG " method,

NSArray *dStringWithPossibleWhiteSpace = [dString componentsSeparatedByCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

change to:

NSArray *dStringWithPossibleWhiteSpace = [dString componentsSeparatedByCharactersInSet:[NSCharacterSet newlineCharacterSet]];

3.in "- (NSMutableArray *)parsePath:(NSString *)attr" method

NSMutableArray *stringTokens = [NSMutableArray arrayWithCapacity: maxPathComplexity];
NSInteger index = 0;
while (index < [attr length]) {
NSMutableString *stringToken = [[NSMutableString alloc] initWithCapacity:maxTokenLength];
[stringToken setString:@""];
unichar charAtIndex = [attr characterAtIndex:index];
if (charAtIndex != ',') {
[stringToken appendString:[NSString stringWithFormat:@"%c", charAtIndex]];
}

change to:

NSMutableArray *stringTokens = [NSMutableArray arrayWithCapacity: maxPathComplexity];
NSInteger index = 0;
while (index < [attr length]) {
unichar charAtIndex = [attr characterAtIndex:index];
//Jagie:Skip whitespace
if (charAtIndex == 32) {
index ++;
continue;
}
NSMutableString *stringToken = [[NSMutableString alloc] initWithCapacity:maxTokenLength];
[stringToken setString:@""];

    if (charAtIndex != ',') {
        [stringToken appendString:[NSString stringWithFormat:@"%c", charAtIndex]];
    }

pod install doesn't work?

Got really excited to use this. Updated my Podfile to be:

platform :ios, '7.0'
pod 'AFNetworking', '~> 2.0'
pod 'DTFoundation/UIKit_BlocksAdditions'
pod 'PPTopMostController'
pod 'PocketSVG'

Basically, just added the last line. Did a pod install, but all I ever get is:

[!] Unable to find a specification for `PocketSVG`

Is it not entirely available as a pod yet? (I'm pretty new to pod stuff, I just put lines in there and it usually works)

Offer proper error handling

Thanks for PocketSVG. If you feed it the right SVG data, works fine.

When you ask it to load erroneous SVG data, which very often is the case in an application, I was pretty alarmed to find my application just decided to QUIT without warning. No stack trace. No crash. Just quit.

It didn't take long for me to realise the culprit was PocketSVG's exit(EXIT_FAILURE); sprinkled all over the place. Have a look:

    // PocketSVG.m
    if (rootXML == nil)
    {
        NSLog(@"*** PocketSVG Error: Root element nil");
        exit(EXIT_FAILURE);
    }
    if (![rootXML.tag isEqualToString: @"svg"])
    {
        NSLog(@"*** PocketSVG Error: Root element not equal to \"svg\", instead %@:", rootXML.tag);
        exit(EXIT_FAILURE);
    }

    // get the width and height
    NSString *widthString = [rootXML attribute: @"width"];
    NSString *heightString = [rootXML attribute: @"height"];
    if (widthString == nil)
    {
        NSLog(@"width empty");
        exit(EXIT_FAILURE);
    }    
    if (heightString == nil)
    {
        NSLog(@"height empty");
        exit(EXIT_FAILURE);
    }

Far better to use NSError * and provide a reason for failure than to completely close the application down.

Not render my svg file.

Hi.

  1. Run with current demo
  2. Add my file(please unzip attachment into Sample SVG Files)
    1.svg.zip
  3. Change name tigerto 1 in ViewController.swift
  4. Get project failed.
2016-11-26 12:57:16.503 Demo-iOS[89178:3866804] *** Assertion failure in hexTriplet::hexTriplet(NSString *__strong)(), /data/IosPlaygrounds/PocketSVG/SVGEngine.mm:571
2016-11-26 12:57:16.666 Demo-iOS[89178:3866804] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: [str hasPrefix:@"#"]'

Please help me.

Shapes loaded seem to be rotated by 180°

I was wondering why my shapes look different from what i saw in the SVG loaded in my browser.
It looks like PocketSVG is loading the path somehow rotated.
In order to get it printed as seen on the browser i need to tranform the shape by 180°.
Did i miss something here or is this is a bug?

My code is very simple:

let svg = PocketSVG.pathFromSVGFileNamed("example").takeUnretainedValue()
let sh = SKShapeNode( path: svg, centered: true)
self.addChild(sh)

The code above works fine, but the shape is printed in a 180° rotated state.

KanjiVG loop animations

Following the instructions I can get an array of cashapelayer, add an animation that show how to draw the stroke to every layer, and add the layer to view. When launch the app I can see the animation, but only one time. How can I loop the entire animation? The animation show how draw every stroke of kanji and it do it stroke by stroke. But when finish I want that everything is cleaned and the animation restarts. How can I do it?

App crash when returned CGPath is released, CGPath ownership

Who owns the returned CGPath from my SVG? I assumed I was under ownership. However, when I use that CGPath inside drawRect, there is an app crash when the view controller is popped from the navigation stack.

Note, the actual release statement I call successfully releases the object. The crash occurs after the view controller is popped from the navigation stack. This does not occur if I remove my own release statement. I'm guessing it's released again somewhere, hence the question about ownership.

Multiple path

Hi everyone,

i know that actually this class support only one path (last path, precisely), but i need to animate the KanjiVG's files that are SVG file representing order stroke kanji (japanese ideograms) and this SVG has more one path. How can I get the array containing the paths?

CocoaPods shows dropped OS X support?

The latest podspec in the master repo shows only support for iOS for both v0.5 and v0.6:

{
  "name": "PocketSVG",
  "version": "0.6",
  "summary": "An Objective-C class that converts Scalable Vector Graphics into Core Graphics elements.",
  "homepage": "https://github.com/arielelkin/PocketSVG",
  "license": {
    "type": "MIT",
    "file": "LICENSE"
  },
  "authors": {
    "Ponderwell, Ariel Elkin, and Contributors": "https://github.com/arielelkin/PocketSVG"
  },
  "source": {
    "git": "https://github.com/arielelkin/PocketSVG.git",
    "tag": "v0.6"
  },
  "platforms": {
    "ios": "5.0"
  },
  "requires_arc": true,
  "frameworks": "QuartzCore",
  "source_files": "PocketSVG.{h,m}"
}

UIBezierCurve???

There is no such thing as a UIBezierCurve. You probably mean UIBezierPath. You might want to fix your front-page blurb.

Creative Commons License is Unfit for Software

Creative Commons themselves state the following:

Can I apply a Creative Commons license to software?

We do not recommend it. Creative Commons licenses should not be used for software. We strongly encourage you to use one of the very good software licenses which are already available.

Please consider an appropriate license.

Not able to get the Cicrle path

I have test the below image , I am not able to get the correct path. Which tool we can use to create svg image which support the circle or curve path

Please let us know which tool we would be use to create SVG image.
Cicle.zip

Fails to render shapes... is only looking for paths..

for example....

<?xml version="1.0"?> <svg xmlns="http://www.w3.org/2000/svg"> <g style="fill-opacity:0.7; stroke:black; stroke-width:0.1cm;"> <circle cx="6cm" cy="2cm" r="100" style="fill:red;" transform="translate(0,50)" /> <circle cx="6cm" cy="2cm" r="100" style="fill:blue;" transform="translate(70,150)" /> <circle cx="6cm" cy="2cm" r="100" style="fill:green;" transform="translate(-70,150)"/> </g> </svg>

fails to find any content.

Initializing with Swift?

Hi,

I'm trying to initialize PocketSVG in a Swift project but the compiler doesn't seems to recognize the pathFromSVGFileNamed argument. Here's my code and the error I get:

let myShape: CGPathRef = PocketSVG(pathFromSVGFileNamed: "BezierCurve1");
ViewController.swift:25:41: Extra argument 'pathFromSVGFileNamed' in call

When I remove the argument I get that error:

ViewController.swift:25:41: Missing argument for parameter 'fromSVGFileNamed' in call

And then, trying with the suggested fromSVGFileNamed argument name, I get that error:

ViewController.swift:25:32: Cannot invoke 'init' with an argument list of type '(fromSVGFileNamed: StringLiteralConvertible)'

Am I missing something here?

imageWithSVGNamed non existent image

Please send an error to console if imageWithSVGNamed is called with a non existent image.

Instead, I am getting an unhelpful crash from:

- (NSString *)tag {
    return [NSString stringWithUTF8String:(const char *)node_->name];
}

Here, node is nil and the error is it is dereferencing null.

SVG circle element does not work

Release 2.0.0 of PocketSVG displays all my SVG files except it stubbornly refuses to display circle elements. The following is contents from a simple SVG file that uses a circle element. It works on Inkscape, Internet Explorer, Irfanview and other applications. But PocketSVG will not display the circle.

rdf:RDF<cc:Work
rdf:about="">dc:formatimage/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />dc:title</dc:title></cc:Work></rdf:RDF>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.