Skip to content

Colour doesn't appear to work correctly with circle functions #1502

@Guddler

Description

@Guddler

I have been trying to use filled_circle from gfx::primitives. I am not sure if iI'm doing something wrong, but if I try to draw 4 circles, two red and two black. One each using the predefined colours and one each using RGBA values the results are not as expected. I haven't included all the boiler plate code but I can provide a full example if needed.

At first sight it seems that the endianness of the colour is reversed but I don't think it is as simple as that because I ran my same code on a Big Endian PowrPC system and got different results again!

The below code and comment is from MacOS

// Renders a red circle
let _= canvas.filled_circle(200, 200, 75, Color::RED);
// Does not render - or more accurately, renders but is invisible due to alpha of 0
let _= canvas.filled_circle(600, 200, 75, Color::BLACK);
// Renders correctly - but is potentially ambiguous
let _= canvas.filled_circle(200, 400, 75, Color::RGBA(255, 0, 0, 255)); 
// Renders correctly, but clearly the RGBA values are reversed to what I assume they should be
let _ = canvas.filled_circle(600, 400, 75, Color::RGBA(255, 0, 0, 0));

Am I missing something fundamental here?

[EDIT]

Just to follow up here, the only way I can get the correct colours on either of my systems is by reversing the bytes as per the following. This works correctly on both big endian system and little endian system, so not sure if this is a bug or I'm missing a step:

let c = Color::BLUE;
let _= canvas.filled_circle(200, 200, 75, Color::RGBA(c.a, c.b, c.g, c.r));

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