Giter Club home page Giter Club 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

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ccsvg's Issues

CCSVG on Cocos2D 2.x

Luke,

I'm finally getting around to updating MonkVG to be compatible with both OpenGL ES 1.1 AND OpenGL ES 2.0. (you can see the current work in the gles-2.0 branch in MonkVG). I was planning on making sure that CCSVG then works with Cocos2D 2.0.

How would you want to structure these sorts of changes? I'm thinking I should create a fork of your repository and then you can peruse the changes and decide how you want to integrate them sometime later. Or we can work a little more closely and we can figure out a way to make sure CCSVG works both on Cocos2D 1.x and 2.x. Thoughts?

Even can't download

On use SourceTree:

git -c diff.mnemonicprefix=false -c core.quotepath=false clone --recursive https://github.com/lukelutman/CCSVG /Users/vyachaslav/Documents/CCSVG
warning: templates not found /usr/local/git/share/git-core/templates
Permission denied (publickey).
fatal: The remote end hung up unexpectedly
Clone of '[email protected]:lukelutman/MonkSVG.git' into submodule path 'external/MonkSVG' failed
Cloning into '/Users/vyachaslav/Documents/CCSVG'...
Submodule 'external/MonkSVG' ([email protected]:lukelutman/MonkSVG.git) registered for path 'external/MonkSVG'
Submodule 'external/MonkVG' ([email protected]:lukelutman/MonkVG.git) registered for path 'external/MonkVG'
Submodule 'external/cocos2d-iphone' (git://github.com/cocos2d/cocos2d-iphone.git) registered for path 'external/cocos2d-iphone'
Cloning into 'external/MonkSVG'...
fatal: destination path '/Users/vyachaslav/Documents/CCSVG' already exists and is not an empty directory.
Completed with errors, see above

On use Terminal:
git clone [email protected]:lukelutman/CCSVG.git
Cloning into 'CCSVG'...
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

And the result is an unworkable project

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.