Skip to content

Graphics.drawCircle 3rd arg ("radius") is actually diameter #1454

@HeatherSoron

Description

@HeatherSoron

While trying to whip up a quick conveyor belt using the Graphics object, I discovered that the third argument (called "radius" in the docs) actually defines the circle's diameter. Not too difficult to deal with once I know about it, but guys, that's not what radius means :P.

Observed in Phaser v2.2.1.

Probably a Pixi bug? Want me to cross-file it over there?

Have some sample code below, which should demonstrate the issue nicely:

function addConveyor(x, y, width) {
    var rad = 10;
    var conveyor = game.add.graphics(x, y);
    conveyor.beginFill(0xdddddd, 1);

    // draw circles to represent wheels on both ends of the conveyor

    // circle 1: assume that arg #3 is radius (as per docs). Ends up drawing half the height of the conveyor.
    conveyor.drawCircle(rad, rad, rad); // offset circle by radius in both directions
    // circle 2: assume that arg #3 is diameter. Ends up drawing the same height as the conveyor.
    conveyor.drawCircle(rad + width, rad, rad * 2);

    // draw a rect for the body of the conveyor belt
    conveyor.drawRect(rad, 0, width, rad * 2);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions