gg: use html5_canvas_name as the name of the canvas in gg.js.v too, similarly to gg.c.v

This commit is contained in:
Delyan Angelov 2023-08-13 17:45:19 +03:00
parent 33965bc29b
commit be1270540b
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
3 changed files with 7 additions and 7 deletions

View File

@ -190,7 +190,7 @@ fn main() {
create_window: true
resizable: false
window_title: 'snek'
canvas: 'canvas'
html5_canvas_name: 'canvas'
)
app.gg.run()

View File

@ -171,7 +171,7 @@ fn main() {
user_data: game
frame_fn: frame
event_fn: on_event
canvas: 'canvas'
html5_canvas_name: 'canvas'
)
game.init_game()
game.gg.run() // Run the render loop in the main thread

View File

@ -250,9 +250,9 @@ pub:
native_rendering bool // Cocoa on macOS/iOS, GDI+ on Windows
// drag&drop
enable_dragndrop bool // enable file dropping (drag'n'drop), default is false
max_dropped_files int = 1 // max number of dropped files to process (default: 1)
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
canvas string
max_dropped_files int = 1 // max number of dropped files to process (default: 1)
max_dropped_file_path_length int = 2048 // max length in bytes of a dropped UTF-8 file path (default: 2048)
html5_canvas_name string = 'canvas' // the id/name of the canvas element, that will be used to render GG apps
}
const size = Size{0, 0}
@ -330,8 +330,8 @@ pub fn new_context(cfg Config) &Context {
g.config = cfg
g.window = dom.window()
document := dom.document
canvas_elem := document.getElementById(cfg.canvas.str) or {
panic('gg: cannot get canvas element')
canvas_elem := document.getElementById(cfg.html5_canvas_name.str) or {
panic('gg: cannot get canvas element from cfg.html5_canvas_name.str')
}
canvas := get_canvas(canvas_elem)
g.canvas = canvas