Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docs] wrong usage of color in raylib example. #68

Open
Ghibranalj opened this issue May 10, 2022 · 1 comment
Open

[docs] wrong usage of color in raylib example. #68

Ghibranalj opened this issue May 10, 2022 · 1 comment
Assignees
Labels

Comments

@Ghibranalj
Copy link

Ghibranalj commented May 10, 2022

in this page's example for raylib the function draw_title() uses float for color.Raylib's color uses char. also the range for color in raylib is (i think) 0 - 255, where as here the value of opacity here is 0-1.

void draw_tile(void *image, unsigned int sx, unsigned int sy, unsigned int sw, unsigned int sh,
               unsigned int dx, unsigned int dy, float opacity, unsigned int flags) {

 // here the opacity has the value between 0-1, raylibs color is 0-255
  DrawTextureRec((Texture2D*)image, (Rectangle) {sx, sy, sw, sh}, (Vector2) {dx, dy}, (Color) {opacity, opacity, opacity, opacity});
}

maybe something like this is the solution, idk if there is a better one.

    .....
    float norm_opacity = opacity * 255;
    char color = (char)norm_opacity;
    DrawTextureRec(texture, (Rectangle){sx, sy, sw, sh}, (Vector2){dx, dy},
                   (Color){color, color, color, color});
@baylej
Copy link
Owner

baylej commented May 10, 2022

@baylej baylej self-assigned this Mar 13, 2023
@baylej baylej added the bug label Mar 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants