Giter Club home page Giter Club logo

svgkit's Introduction

SVGKit

SVGKit is a Cocoa framework for rendering SVG files as Core Animation layers. All shapes are represented by instances of the CAShapeLayer class, and are, by design, animatable. SVGKit is compatible with the latest Mac OS X and iOS SDK's. To use SVGKit in your iOS application, simply drag the Core and iOS folders into your Xcode project. See SVGPad for a working sample. To use SVGKit in your Mac OS X application, build the SVGKit Xcode project and link your application against the built framework. Since CAShapeLayer does not support gradient fills, support for gradients has been temporarily removed.

Usage

First, initialize an instance of SVGDocument, the model object which encompasses the entire SVG element tree. This can be accomplished using the initWithContentsOfFile: initializer. To load a SVG file which resides in your application bundle, use the documentNamed: class method and pass in a file name (without the extension). The SVGDocument class encapsulates certain document metadata, including width, height, version, title, and description.

SVGDocument *document = [SVGDocument documentNamed:@"Monkey"]; // located in the application bundle

To render the document in a view, we need to access the document's Core Animation layer tree. On Mac OS X, make sure your instance of NSView is layer-backed. The layer tree can be accessed using the layerTree method on SVGDocument, for example:

NSView *ourView = ... ;
[ourView setWantsLayer:YES];
[ourView.layer addSublayer:[document layerTree]];

Your SVG file should now be rendered on-screen. You can query for specific layers by using the layerWithIdentifier: method, also defined on SVGDocument. The identifier corresponds to the id attribute defined on elements. Once a reference to a subclass of CALayer is returned, its properties can be animated using implicit or explicit Core Animation animations.

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

svgkit's People

Contributors

mattrajca avatar

Stargazers

 avatar David Diaz avatar Hank Chen avatar Brad Pillow avatar Nigel Timothy Barber avatar Jesse Armand avatar Dirk Holtwick avatar

Watchers

Nigel Timothy Barber avatar James Cloos avatar  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.