plotters-wxdragon
plotters-wxdragon is a backend for Plotters, to draw plots in a GUI window
managed by wxDragon.
wxDragon is a binding of wxWidgets for rust. wxWidgets is a cross-platform GUI library toolkit for desktop applications, that uses the native GUI toolkit on Windows, macOS, and Linux.
Plotters is a Rust drawing library focusing on data plotting for both WASM and native applications.
Examples of bitmaps produced with this backend:
Getting started
Quick start
-
Follow wxDragon instructions to install the
wxdragoncrate. You will need the wxWidgets library for your OS so be sure to follow the instructions. -
Clone this repository and run the
x2plotting example to check that it works for you.This will open a new window displaying a simple
y=x^2plot.
Integrating with a project
-
Add the following to your
Cargo.tomlfile:[] = "0.9" = "0.3" = "0.1" -
Create an app with a
wxdragon::Panel, and use the panel'son_painthandler to create a newwxdragon::AutoBufferedPaintDC(device context) each time, wrap it in aWxBackendand then draw on it.use *; use ; use WxBackend; use ;You can find more details in the examples for how to integrate a plot in your wxWidgets application:
x2: simpley=x^2plot in a wxWidgets frametext: a single window that shows various text orientations and a toolbar that can modify application state
There are also more tests, that illustrate that most existing plotters examples work without change. In these tests we write to to an in-memory device context instead of a device context linked to a
Panel, and compare to a reference png images to ensure non-regression.
How this works
This crate implements a backend for Plotters. It uses the existing drawing context of wxWidgets, and maps plotters drawing primitives to corresponding calls fo the wxWidgets API.
See also plotters-backend for reference on implementing a backend for
plotters.
Roadmap
This project is in its early stages. Future plans include:
- Canvas interaction with the mouse (zoom/pan).
- Canvas interaction with toolbar buttons (zoom/pan/reset/select).
- Test the
blit_bitmapfunction (no working example found yet). - Performance benchmark.
- Make default font size more consistent with Plotters.
- Find a way to use wxGLCanvas for hardware acceleration?
License
This project is dual-licensed under Apache 2.0 and
MIT terms.
Contributions
Unless explicitly stated otherwise, contributions to this project, as defined in the Apache 2.0 license, are dual-licensed under Apache 2.0 and MIT. You do not need to explicitly state this when contributing. To opt out, please explicitly state "Not a Contribution" with your submission.
This project follows the following guidelines:
- Format the code with
cargo fmt. - For any changes in markdown files, use
rumdl fmt. - Lint your code with
cargo check,cargo test,cargo clippy, andcargo doc. - Use conventional commits.