Update denormalise function
This commit is contained in:
parent
8a30e64696
commit
4a0ec9e5e7
@ -9,7 +9,7 @@
|
||||
|
||||
u32 colour_to_u32(colour_t colour);
|
||||
u32 index_from_coordinates(window_t *wnd, u32 x, u32 y);
|
||||
i32 denormalise(i32 value, u32 max, u32 abs_normalised);
|
||||
i32 denormalise(i32 value, u32 max, u32 abs_half);
|
||||
void set_screen_pixel(window_t *wnd, u32 x, u32 y, colour_t colour);
|
||||
|
||||
bool init_window(window_t *wnd, u32 width, u32 height, const char *title) {
|
||||
@ -132,14 +132,14 @@ u32 index_from_coordinates(window_t *wnd, u32 x, u32 y) {
|
||||
return y * wnd->width + x;
|
||||
}
|
||||
|
||||
i32 denormalise(i32 value, u32 max, u32 abs_normalised) {
|
||||
i32 normalised_min = -abs_normalised;
|
||||
i32 normalised_max = abs_normalised;
|
||||
|
||||
i32 denormalise(i32 value, u32 max, u32 abs_half) {
|
||||
if (max == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
i32 normalised_min = -abs_half;
|
||||
i32 normalised_max = abs_half;
|
||||
|
||||
i32 denormalised = (i32)(((value - normalised_min) * max) /
|
||||
(normalised_max - normalised_min));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user