ASCII Art for Cocos2D iOS 1.1, 2.0 and 2.1. Supports ARC.
CCCaca was designed as a screen filter to render your Cocos2D applications in ASCII art using different predefined color sets. It uses a dumbed down version of libCaca called hayCaca (i-caca) under the hood.
The filter speed depends on device and font size, the smaller the font, the slower the render. On an iPhone 4S I found a font size of 7 to be a good compromise between quality and speed.
Mostly, for fun.
Add the "src" folder to your project, then:
#import "CCCacaScreenFilter.h"
// ... code code code code ... //
CCCacaScreenFilter *screenFilter = [[CCCacaScreenFilter alloc] initWithFontSize:fontSize];
[screenFilter enable];
That's all, enjoy ASCII! Make sure to keep a pointer to your screenFilter variable so you can disable the filter later using:
[screenFilter disable];
Maybe?
- Be aware that CCCaca uses two memory buffers equal to the number of pixels on the device's screen in 32bit.
- The rendering is multithreaded, be carful if you modify it.
- CCCaca depends on having an untouched CCDirectorIOS drawScene method, it uses method swizzling to plugin itself.
- Changing the gamma property only affects colors using the kCCCacaRenderLibCacaColor render color mode.
- CCCacaScreenFilter inherits from CCScene, you can add other nodes to it and they won't be filtered. There are other crazy ways to use this functionality.
libCaca and hayCaca are released under the Do What the Fuck You Want to Public License (WTFPL). CCCaca might be released under the compatible MIT license, it doesn't have one yet.