Skip to content

Commit

Permalink
gg: use html5_canvas_name as the name of the canvas in gg.js.v to…
Browse files Browse the repository at this point in the history
…o, similarly to `gg.c.v`
  • Loading branch information
spytheman committed Aug 13, 2023
1 parent 33965bc commit be12705
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion examples/snek/snek.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ fn main() {
create_window: true
resizable: false
window_title: 'snek'
canvas: 'canvas'
html5_canvas_name: 'canvas'
)

app.gg.run()
Expand Down
2 changes: 1 addition & 1 deletion examples/tetris/tetris.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions vlib/gg/gg.js.v
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit be12705

Please sign in to comment.