Giter Site home page Giter Site logo

nocross / svgkit Goto Github PK

View Code? Open in Web Editor NEW

This project forked from svgkit/svgkit

0.0 0.0 0.0 5.82 MB

Display and interact with SVG Images on iOS / OS X, using native rendering (CoreAnimation)

Home Page: (currently only supported for iOS - OS X code needs updating)

License: MIT License

svgkit's Introduction

SVGKit

SVGKit is a Cocoa framework for rendering SVG files natively: it's fast and powerful.

Versions:

  • v1.x = current "in development" branch with latest changes, fixes, features
    • NB: this is now automatically selected in GitHub as the "default" branch when you visit SVGKit's project page
  • v1.1.0 = most recent "stable" release; works with iOS7, has fixes + adds basic (slow) Text support
  • v1.0 = Major refactor/re-write at start of 2013, approximately 90% coverage of the SVG spec. Stable and quite fast - https://github.com/SVGKit/SVGKit/tree/v1.0

Forks:

  • MaddTheSane : this fork adds a complete working build of SVGKit for Mac OS X, and a (very) large number of tweaks (over 10k lines of code). We need help integrating + checking these changes against master / 1.x - please get in touch (create an issue, or email adam.m.s.martin at gmail) if you can help.

Xcode Projects Included

For 2013, we have a major refactor/rewrite of the core SVGKit, fixing many bugs, adding many features, and making SVGKit much closer to meeting the SVG official Specification - http://www.w3.org/TR/SVG/

Because so much has changed, Adam wrote a series of blog posts to explain how to use the latest versions:

Ultra-quick 'getting started' (iPhone/iPad)


Open the project "Demo-iOS", select your preferred simulator (or device, if it's plugged in), build and run. Try the sample SVG's packaged with SVGKit.

To use SVGKit, either CREATE AND DISPLAY AN IMAGE ON SCREEN:

[self.view addSubview: [[SVGKFastImageView alloc] initWithSVGKImage: [SVGKImage imageNamed:@"mySVGfile.svg"]]];

or LOAD AN IMAGE AND CONVERT TO A UIIMAGE OBJECT:

UIImage* newImage = [SVGKImage imageNamed:@"mySVGfile"].UIImage;

WARNING: Due to some bugs in Apple's renderer, SVGKFastImageView doesn't render gradient-fills for anything except rectangles, and cannot use CoreAnimation. For higher accuracy (but slightly worse performance), use SVGKLayeredImageView instead.

Key methods / properties you might find useful:

  1. SVGKImage - all the magic happens here
  2. SVGKImage.DOMTree - a complete DOM tree of the "parsed" SVG/XML document, with ALL TAGS (even if unsupported by current SVGKit - they will be parsed anyway!)
  3. SVGKImage.CALayerTree - a complete, renderable, tree of Apple CALayer objects (only contains layers for features currently supported - if you find something missing, please submit a fix!)

Advanced Features (this branch/fork only!) (iPhone/iPad)

There are many new features in this version (2013) of SVGKit. Read the blog posts above for more detail, but briefly:

  • use an SVG just like it's a normal PNG file: use SVGKFastImageView like it's UIImageView:
  • load an SVG from web, or from disk
  • search an SVG file for particular tags / nodes / elements:
  • automatic scaling of your SVG to fit their on-screen size (often reduces the memory required)
  • Access to the DOM Document Object Model
  • Retrieve any part of your SVG document positioned correctly in space
  • detailed information on whether and WHY parsing failed:

Usage - OS X

UNSUPPORTED: the code exists, but none of the maintainers have used it recently, so we're not even sure if the OS X build still works!

OS X: ...this needs updating; some minor code changes are needed to "fix" this project. The OS X framework currently DOES NOT BUILD because iOS classes are being referenced in a couple of places.

Feel free to report any issues or suggest improvements in the issue tracker

Installation

There is a sample project you can examine which embeds the entire SVGKit project into an application project. Many people like working this way (although Xcode isn't very good at it. Open the "Demo-iOS" project and poke around.

Alternatively, most people like to compile an embeddable library:

  1. Open the project "SVGKit-iOS"

  2. Select the target "SVGKit Library" from the dropdown build selector at top left

  3. Build 4a. (open the Products section on left hand bar in Xcode, right click the product, and select "Show in Finder". THEN GO UP ONE DIRECTORY! You MUST NOT USE the Product that Xcode shows you - it IS WRONG, it is a BUG IN APPLE'S XCODE)

  4. Look in your output directory for a folder named "debug-universal" - this contains a library + headers for: iPhone, iPad, iOS Simulator

  5. Drag/drop the library file, and the headers folder (should be called "usr") into your iPhone/iPad project.

  6. Edit your build settings and set "C/C++ Compiler Version" = "LLVM Compiler 2.0"

  7. Edit your build settings and add "Other Linker Flags" = "-ObjC"

  8. Add all the REQUIRED APPLE FRAMEWORKS (see below)

  9. (Optional but recommended): Edit your build settings and add "Header Search Paths" = "/usr/include/libxml2"

  10. (Optional but recommended): Add the framework "libxml2.dylib"

REQUIRED APPLE FRAMEWORKS

You must add the following frameworks for SVGKit to compile - unless you are embedding the whole project file (in which case Apple does it automatically)

  • CoreText
  • CoreImage
  • QuartzCore
  • CoreGraphics
  • UIKit

(only the first two are unusual - the rest you probably have by default in your iOS project template)

svgkit's People

Contributors

adamgit avatar alejandro-isaza avatar couloirr avatar dblandin avatar joeldev avatar mattrajca avatar meric avatar notjosh avatar qwzybug avatar rhcad avatar stich avatar tsaizhenling avatar

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.