New issue
 Projects > js > Issues > Feature #3129

Add methods "drawSolidCircle" and "drawSolidArc"

Feature #3129 [New]
ZippoLag 2013-11-07 21:30 . Updated almost 3 years ago

Currently it is only possible to draw circular lines that have no fill, I propose that methods “drawSolidCircle” and “drawSolidArc” are added to the drawing primitives.

In my own applications I’m currently using code like this:

var drawSolidCircle = function(center, radius, segments){
var i;
for(i=0; i<radius; i++){
cc.drawingUtil.drawCircle(cc.p(0,0), i, 0, segments, false);

And this:

var drawSolidArc= function(center, radius, degrees, segments){
var i;
for(i=0; i<degrees;i++){
cc.drawingUtil.drawCircle(center, radius, cc.DEGREES_TO_RADIANS(-i+90), segments, true);

I don’t know if it’s the best way to do it, but it works consistently with what’s already implemented.

ZippoLag 2013-11-07 21:53

Correction: this would be a better (more flexible) way to implement drawSolidArc:

var drawSolidArc= function(center, radius, degreesFrom, degreesTo, segments){
var temp = degreesTo;
degreesTo = degreesFrom;
degreesFrom = temp;
var i;
for(i=degreesFrom; i<=degreesTo;i++){
cc.drawingUtil.drawCircle(center, radius, cc.DEGREES_TO_RADIANS(-i+90), segments, true);

Note: the “-degree+90” is for moving the “0” from the confusing “3 o’ clock” to the more logical “12 o’ clock”. Increment in degrees is clockwise (I think a flag for going clockwise or counterclockwise would be overkill).

Atom PDF

Start date:2013-11-07
Due date:
% Done:


Target version:-

Sign up for our newsletter to keep up with the latest developments, releases and updates for Cocos2d-x.