a little bit of gfx
This commit is contained in:
+1
-6
@@ -1,10 +1,5 @@
|
||||
[BuiltinType(name = "Color", version = 1)]
|
||||
declare builtin type Color(
|
||||
pub r: int,
|
||||
pub g: int,
|
||||
pub b: int,
|
||||
pub a: int
|
||||
pub raw: int
|
||||
) {
|
||||
[IntrinsicCall(name = "core.color.pack", version = 1)]
|
||||
fn pack() -> int;
|
||||
}
|
||||
|
||||
+105
-3
@@ -1,7 +1,109 @@
|
||||
import { Color } from @core:color;
|
||||
|
||||
declare host Gfx {
|
||||
[Host(module = "gfx", name = "draw_pixel", version = 1)]
|
||||
declare host LowGfx {
|
||||
[Host(module = "gfx", name = "clear", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_pixel(x: int, y: int, color: Color) -> void;
|
||||
fn clear(color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "fill_rect", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn fill_rect(x: int, y: int, w: int, h: int, color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "draw_line", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_line(x1: int, y1: int, x2: int, y2: int, color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "draw_circle", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_circle(x: int, y: int, r: int, color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "draw_disc", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_disc(x: int, y: int, r: int, border_color: Color, fill_color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "draw_square", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_square(x: int, y: int, w: int, h: int, border_color: Color, fill_color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "set_sprite", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn set_sprite(
|
||||
asset_name: str,
|
||||
index: int,
|
||||
x: int,
|
||||
y: int,
|
||||
tile_id: int,
|
||||
palette_id: int,
|
||||
active: bool,
|
||||
flip_x: bool,
|
||||
flip_y: bool,
|
||||
priority: int
|
||||
) -> int;
|
||||
|
||||
[Host(module = "gfx", name = "draw_text", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn draw_text(x: int, y: int, message: str, color: Color) -> void;
|
||||
|
||||
[Host(module = "gfx", name = "clear_565", version = 1)]
|
||||
[Capability(name = "gfx")]
|
||||
fn clear_565(color_565: int) -> void;
|
||||
}
|
||||
|
||||
declare service Gfx
|
||||
{
|
||||
fn clear(color: Color) -> void
|
||||
{
|
||||
LowGfx.clear(color);
|
||||
}
|
||||
|
||||
fn fill_rect(x: int, y: int, w: int, h: int, color: Color) -> void
|
||||
{
|
||||
LowGfx.fill_rect(x, y, w, h, color);
|
||||
}
|
||||
|
||||
fn draw_line(x1: int, y1: int, x2: int, y2: int, color: Color) -> void
|
||||
{
|
||||
LowGfx.draw_line(x1, y1, x2, y2, color);
|
||||
}
|
||||
|
||||
fn draw_circle(x: int, y: int, r: int, color: Color) -> void
|
||||
{
|
||||
LowGfx.draw_circle(x, y, r, color);
|
||||
}
|
||||
|
||||
fn draw_disc(x: int, y: int, r: int, border_color: Color, fill_color: Color) -> void
|
||||
{
|
||||
LowGfx.draw_disc(x, y, r, border_color, fill_color);
|
||||
}
|
||||
|
||||
fn draw_square(x: int, y: int, w: int, h: int, border_color: Color, fill_color: Color) -> void
|
||||
{
|
||||
LowGfx.draw_square(x, y, w, h, border_color, fill_color);
|
||||
}
|
||||
|
||||
fn set_sprite(
|
||||
asset_name: str,
|
||||
index: int,
|
||||
x: int,
|
||||
y: int,
|
||||
tile_id: int,
|
||||
palette_id: int,
|
||||
active: bool,
|
||||
flip_x: bool,
|
||||
flip_y: bool,
|
||||
priority: int
|
||||
) -> int
|
||||
{
|
||||
return LowGfx.set_sprite(asset_name, index, x, y, tile_id, palette_id, active, flip_x, flip_y, priority);
|
||||
}
|
||||
|
||||
fn draw_text(x: int, y: int, message: str, color: Color) -> void
|
||||
{
|
||||
LowGfx.draw_text(x, y, message, color);
|
||||
}
|
||||
|
||||
fn clear_565(color_565: int) -> void
|
||||
{
|
||||
LowGfx.clear_565(color_565);
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -1 +1,2 @@
|
||||
pub host Gfx;
|
||||
mod host LowGfx;
|
||||
pub service Gfx;
|
||||
|
||||
Reference in New Issue
Block a user