Giter Site home page Giter Site logo

ccsvg's Introduction

CCSVG - Display SVG images on iOS using Cocos2D

Overview

CCSVG provides an API for loading, displaying and animating SVG images on iOS using Cocos2D.

// load an svg image
CCSVGSource *source;
source = [CCSVGSource sourceWithFile:@"player_idle.svg"];

// display an svg image
CCSVGSprite *sprite;
sprite = [CCSVGSprite spriteWithSource:source];
sprite.position = ccp(240,160);

// create an svg animation
CCSVGAnimation *animation;
animation = [CCSVGAnimation animationWithSourcesNamed:@"player_walk_%04d.svg" 
                                                count:2 
                                                delay:1.0/15.0];

// run the animation on the sprite
CCSVGAnimate *animate;
animate = [CCSVGAnimate actionWithSVGAnimation:animation];
[sprite runAction:[CCRepeatForever actionWithAction:animate]]; 

Benefits

SVG images are displayed as vector data, not textures. Each file is tesselated and cached in a vertex buffer object, so the peformance penalty of tesselating and uploading the geometry to OpenGL only happens once when the file is first loaded.

  • Resolution-independence.
  • Smaller file size.
  • Smaller memory footprint.
  • Faster load times.

Drawbacks

There is a significant performance penalty for using images with transparent fills or strokes (drawing them properly means turning on blending in OpenGL). Avoid them where possible.

  • Incomplete SVG support (see what is implemented in MonkVG).
  • Antialiasing requires multisampling to be enabled, which has a performance penalty.

Installation

git clone [email protected]:lukelutman/CCSVG.git
git submodule init
git submodule update

Dependencies

Resources

ccsvg's People

Contributors

lukelutman avatar

Watchers

 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.