Code Monkey home page Code Monkey logo

ccspritefloodfill's Introduction

CCSpriteFloodFill

CCSpriteFloodFill is a cocos2d-based implementation for flood fill.

It is based upon the code posted here: http://www.cocos2d-iphone.org/forum/topic/25446 by Jeston Furqueron, which in time relies on CCTexture2DMutable, by @manucorporat. I have applied some optimizations on that code and synthesized it into an easy to add class.

It's fairly simple to use, you need to create your sprite instance using

// Create the CCSpriteFloodFill from a UIImage instance

UIImage * image = someImageOfYours;

CCSpriteFloodFill * sprite = [CCSpriteFloodFill spriteWithImage:image];
[sprite setPosition:ccp(someX, someY)];
[self addChild sprite];

// Fill it by specifying a position and a color

[sprite fillFromPoint:ccp(someX, someY) withColor:ccc4(r, g, b, a)];

I have tested this class on an iPad 2 using this image: placehold.it/1024x768 and it took 0.79 secs to fill it. It works pretty decent on smaller areas.

Feel free to fork and optimize further this code. If you find this class helpful, I'd love to hear about it. Drop me a line @ignacioinglese.

ccspritefloodfill's People

Contributors

ininja avatar

Watchers

James Cloos 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.