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

issue #141 Color::get_color(i32) should use u32 #143

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion raylib/src/core/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ impl Color {

/// Returns a Color struct from hexadecimal value
#[inline]
pub fn get_color(hex_value: i32) -> Color {
pub fn get_color(hex_value: u32) -> Color {
unsafe { ffi::GetColor(hex_value).into() }
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ pub fn run(rl: &mut RaylibHandle, thread: &RaylibThread) -> crate::SampleOut {
// Draw
//----------------------------------------------------------------------------------
let mut d = rl.begin_drawing(&thread);
let hex = d.gui_get_style(DEFAULT, BACKGROUND_COLOR as i32);
let hex = d.gui_get_style(DEFAULT, BACKGROUND_COLOR as u32);
d.clear_background(Color::get_color(hex));

// raygui: controls drawing
Expand Down
4 changes: 2 additions & 2 deletions showcase/src/example/image_exporter/image_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub fn run(rl: &mut RaylibHandle, thread: &RaylibThread) -> crate::SampleOut {
d.draw_texture_ex(&texture, rvec2(screen_width / 2 - (texture.width() as f32 * imageScale / 2.0) as i32, screen_height / 2 - (texture.height() as f32 * imageScale / 2.0) as i32), 0.0, imageScale, Color::WHITE);

d.draw_rectangle_lines_ex(imageRec, 1, if imageRec.check_collision_point_rec(d.get_mouse_position()) {Color::RED } else { Color::DARKGRAY});
d.draw_text(&format!("SCALE: {:.2}", imageScale * 100.0), 20, screen_height - 40, 20, Color::get_color(d.gui_get_style(raylib::consts::GuiControl::DEFAULT, raylib::consts::GuiDefaultProperty::LINE_COLOR as i32)));
d.draw_text(&format!("SCALE: {:.2}", imageScale * 100.0), 20, screen_height - 40, 20, Color::get_color(d.gui_get_style(raylib::consts::GuiControl::DEFAULT, raylib::consts::GuiDefaultProperty::LINE_COLOR as u32)));
}
else
{
Expand All @@ -199,7 +199,7 @@ pub fn run(rl: &mut RaylibHandle, thread: &RaylibThread) -> crate::SampleOut {
//-----------------------------------------------------------------------------
if windowBoxActive
{
d.draw_rectangle(0, 0, screen_width, screen_height, Color::get_color(d.gui_get_style(raylib::consts::GuiControl::DEFAULT, raylib::consts::GuiDefaultProperty::BACKGROUND_COLOR as i32)).fade( 0.7));
d.draw_rectangle(0, 0, screen_width, screen_height, Color::get_color(d.gui_get_style(raylib::consts::GuiControl::DEFAULT, raylib::consts::GuiDefaultProperty::BACKGROUND_COLOR as u32)).fade( 0.7));
windowBoxActive = !d.gui_window_box(rrect(windowBoxRec.x, windowBoxRec.y, 220, 190), Some(rstr!("Image Export Options")));

d.gui_label(rrect(windowBoxRec.x + 10.0, windowBoxRec.y + 35.0, 60, 25), Some(rstr!("File format:")));
Expand Down