// src/canvas.mbt
// Import Canvas 2D APIs from JS
fn js_clear_rect(x : Double, y : Double, w : Double, h : Double) = "canvas" "clear_rect"
fn js_fill_rect(x : Double, y : Double, w : Double, h : Double) = "canvas" "fill_rect"
fn js_stroke_rect(x : Double, y : Double, w : Double, h : Double) = "canvas" "stroke_rect"
fn js_set_fill_color(r : Int, g : Int, b : Int) = "canvas" "set_fill_color"
fn js_set_stroke_color(r : Int, g : Int, b : Int) = "canvas" "set_stroke_color"
fn js_set_line_width(w : Double) = "canvas" "set_line_width"
fn js_play_sound(sound_type : Int) = "canvas" "play_sound"
pub fn clear_rect(x : Double, y : Double, w : Double, h : Double) -> Unit {
js_clear_rect(x, y, w, h)
}
pub fn fill_rect(x : Double, y : Double, w : Double, h : Double) -> Unit {
js_fill_rect(x, y, w, h)
}
pub fn stroke_rect(x : Double, y : Double, w : Double, h : Double) -> Unit {
js_stroke_rect(x, y, w, h)
}
pub fn set_fill_color(r : Int, g : Int, b : Int) -> Unit {
js_set_fill_color(r, g, b)
}
pub fn set_stroke_color(r : Int, g : Int, b : Int) -> Unit {
js_set_stroke_color(r, g, b)
}
pub fn set_line_width(w : Double) -> Unit {
js_set_line_width(w)
}
pub fn play_sound(sound_type : Int) -> Unit {
js_play_sound(sound_type)
}
// To avoid WASM FFI string type limitations, we define these as native MoonBit functions
// that do not call FFI. The JS side will handle text rendering in the render loop.
pub fn fill_text(_text : String, _x : Double, _y : Double) -> Unit {
// Native placeholder
}
pub fn set_font(_font : String) -> Unit {
// Native placeholder
}