fixes around syscalls
This commit is contained in:
@@ -133,6 +133,8 @@ impl Gfx {
|
||||
color: Color,
|
||||
mode: BlendMode,
|
||||
) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
let fw = self.w as i32;
|
||||
let fh = self.h as i32;
|
||||
|
||||
@@ -160,6 +162,7 @@ impl Gfx {
|
||||
|
||||
/// Draws a single pixel.
|
||||
pub fn draw_pixel(&mut self, x: i32, y: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
if x >= 0 && x < self.w as i32 && y >= 0 && y < self.h as i32 {
|
||||
self.back[y as usize * self.w + x as usize] = color.0;
|
||||
}
|
||||
@@ -167,6 +170,8 @@ impl Gfx {
|
||||
|
||||
/// Draws a line between two points using Bresenham's algorithm.
|
||||
pub fn draw_line(&mut self, x0: i32, y0: i32, x1: i32, y1: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
let dx = (x1 - x0).abs();
|
||||
let sx = if x0 < x1 { 1 } else { -1 };
|
||||
let dy = -(y1 - y0).abs();
|
||||
@@ -193,6 +198,8 @@ impl Gfx {
|
||||
|
||||
/// Draws a circle outline using Midpoint Circle Algorithm.
|
||||
pub fn draw_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
if r < 0 { return; }
|
||||
let mut x = 0;
|
||||
let mut y = r;
|
||||
@@ -223,6 +230,8 @@ impl Gfx {
|
||||
|
||||
/// Draws a filled circle.
|
||||
pub fn fill_circle(&mut self, xc: i32, yc: i32, r: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
if r < 0 { return; }
|
||||
let mut x = 0;
|
||||
let mut y = r;
|
||||
@@ -255,6 +264,8 @@ impl Gfx {
|
||||
|
||||
/// Draws a rectangle outline.
|
||||
pub fn draw_rect(&mut self, x: i32, y: i32, w: i32, h: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
if w <= 0 || h <= 0 { return; }
|
||||
self.draw_horizontal_line(x, x + w - 1, y, color);
|
||||
self.draw_horizontal_line(x, x + w - 1, y + h - 1, color);
|
||||
@@ -269,6 +280,8 @@ impl Gfx {
|
||||
}
|
||||
|
||||
fn draw_horizontal_line(&mut self, x0: i32, x1: i32, y: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
if y < 0 || y >= self.h as i32 { return; }
|
||||
let start = x0.max(0);
|
||||
let end = x1.min(self.w as i32 - 1);
|
||||
@@ -279,6 +292,8 @@ impl Gfx {
|
||||
}
|
||||
|
||||
fn draw_vertical_line(&mut self, x: i32, y0: i32, y1: i32, color: Color) {
|
||||
if color == Color::COLOR_KEY { return; }
|
||||
|
||||
if x < 0 || x >= self.w as i32 { return; }
|
||||
let start = y0.max(0);
|
||||
let end = y1.min(self.h as i32 - 1);
|
||||
|
||||
@@ -62,7 +62,12 @@ impl Color {
|
||||
}
|
||||
|
||||
pub const fn hex(self) -> i32 {
|
||||
self.0 as i32
|
||||
let (r5, g6, b5) = Self::unpack_to_native(self.0);
|
||||
let r8 = ((r5 as u32) << 3) | ((r5 as u32) >> 2);
|
||||
let g8 = ((g6 as u32) << 2) | ((g6 as u32) >> 4);
|
||||
let b8 = ((b5 as u32) << 3) | ((b5 as u32) >> 2);
|
||||
let hex = r8 << 16 | g8 << 8 | b8;
|
||||
hex as i32
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ dist = true
|
||||
include = [
|
||||
"../../VERSION.txt",
|
||||
"../../dist-staging/devtools/debugger-protocol",
|
||||
"../../dist-staging/devtools/prometeu-sdk"
|
||||
"../../dist-staging/devtools/typescript-sdk"
|
||||
]
|
||||
|
||||
[dependencies]
|
||||
|
||||
Reference in New Issue
Block a user