-
Notifications
You must be signed in to change notification settings - Fork 487
[Question] What are x_bounds and y_bounds in Canvas? #286
Comments
Those are used to define the viewport of the canvas. Only the points whose coordinates are within the viewport are displayed. When you render the canvas using For example, when we draw the entire world map, the bounds are the ranges for latitude and longitude as floats: let canvas = Canvas::default()
.block(Block::default().borders(Borders::ALL).title("World"))
.paint(|ctx| {
ctx.draw(&Map {
color: Color::White,
resolution: MapResolution::High,
});
ctx.print(app.x, -app.y, "You are here", Color::Yellow);
})
.x_bounds([-180.0, 180.0])
.y_bounds([-90.0, 90.0]);
f.render_widget(canvas, chunks[0]); If you were to "zoom" to a certain part of the world you may want to choose different bounds. |
Great explanation. Is it possible to add that explanation to the docs for x_bounds and y_bounds? |
was thinking the same |
First time, I am working on any UI app so I don't know much about it. I tried to go through examples but unable to understand what are x or y bounds.
Also hacking on my first Rust project :)
Thanks in advance.
The text was updated successfully, but these errors were encountered: