🎉 initial commit: Nyash Programming Language完成版
🚀 主要機能: • Everything is Box哲学による革新的アーキテクチャ • WebAssemblyブラウザー対応プレイグラウンド • アーティスト協同制作デモ - 複数Boxインスタンス実証 • 視覚的デバッグシステム - DebugBox完全統合 • static box Mainパターン - メモリ安全設計 ⚡ 言語機能: • NOT/AND/OR/除算演算子完全実装 • ジェネリクス/テンプレートシステム • 非同期処理(nowait/await) • try/catchエラーハンドリング • Canvas統合グラフィックス 🎨 ブラウザー体験: • 9種類のインタラクティブデモ • リアルタイムコード実行 • WebCanvas/WebConsole/WebDisplay • モバイル対応完了 🤖 Built with Claude Code collaboration Ready for public release!
This commit is contained in:
49
src/wasm_test.rs
Normal file
49
src/wasm_test.rs
Normal file
@ -0,0 +1,49 @@
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub mod wasm_test {
|
||||
use wasm_bindgen::prelude::*;
|
||||
use web_sys::{window, HtmlCanvasElement, CanvasRenderingContext2d};
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn test_direct_canvas_draw() -> Result<(), JsValue> {
|
||||
// Get window and document
|
||||
let window = window().ok_or("no window")?;
|
||||
let document = window.document().ok_or("no document")?;
|
||||
|
||||
// Get canvas element
|
||||
let canvas = document
|
||||
.get_element_by_id("test-canvas")
|
||||
.ok_or("canvas not found")?
|
||||
.dyn_into::<HtmlCanvasElement>()?;
|
||||
|
||||
// Set canvas size
|
||||
canvas.set_width(400);
|
||||
canvas.set_height(300);
|
||||
|
||||
// Get 2D context
|
||||
let context = canvas
|
||||
.get_context("2d")?
|
||||
.ok_or("no 2d context")?
|
||||
.dyn_into::<CanvasRenderingContext2d>()?;
|
||||
|
||||
// Draw black background
|
||||
context.set_fill_style(&JsValue::from_str("black"));
|
||||
context.fill_rect(0.0, 0.0, 400.0, 300.0);
|
||||
|
||||
// Draw red rectangle
|
||||
context.set_fill_style(&JsValue::from_str("red"));
|
||||
context.fill_rect(50.0, 50.0, 100.0, 80.0);
|
||||
|
||||
// Draw blue circle
|
||||
context.set_fill_style(&JsValue::from_str("blue"));
|
||||
context.begin_path();
|
||||
context.arc(250.0, 100.0, 40.0, 0.0, 2.0 * std::f64::consts::PI)?;
|
||||
context.fill();
|
||||
|
||||
// Draw text
|
||||
context.set_font("20px Arial");
|
||||
context.set_fill_style(&JsValue::from_str("white"));
|
||||
context.fill_text("Hello Direct Canvas!", 100.0, 200.0)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user