AwesomeNode
AwesomeNode copied to clipboard
Extended cocos2dx DrawNode with tessellation and AntiAliasing for smooth drawing. ๐
awesome node
Cocos2d-x tessellation library for drawing smooth anti-aliased curves.
Make drawing great again!
Implementation details Medium Post
Setup
Just grab AwesomeNode.h and AwesomeNode.cpp into your cocos2d-x based project and youโre all set! (AwesomeNode donโt expose any cocos namespaces to global scope).
Donโt forget to add AwesomeNode.cpp to LOCAL_SRC_FILES section
at Android.mk on android. Projects for Android Studio and MSVC are also provided.
Usage
Initialise the node and add it to scene..
auto node = AwesomeNode::create();
addChild(node);
โฆand you can start drawing.
Given that w - is the line thickness you want and pts is cocos PointArray you can do the following:
drawALine(A, B, w, Color4F::GREEN);
node->drawACardinalSpline(pts, 0.5, 360, w, Color4F::GREEN);
node->drawAFilledCardinalSpline(pts, 0.5, 360, w, Color4F::GREEN, bottom, Color4F::RED);
last one generate curve with color filling from curve to the given Y level, like you can see at sample.
Also you can draw a triangle (drawTriangle) with each vertex can has its own color and opacity so OpenGL can provide color interpolation at vertex shader. Tessellation is basically a smart way to represent line by a set of triangles so this one is used all across the library.
Simple implementation for dashed (drawADashedLine) and dash-dotted (drawADashDottedLine) lines are also included.
Uncomment #define AWESOMEDEBUG to see tessellation highlights.
Metal-backend currently doesn't work
coffee โ๏ธ