add readme

This commit is contained in:
kieran 2025-01-11 03:06:31 +00:00
parent a5cf8679c3
commit e54cf8a1bd
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
4 changed files with 14 additions and 9 deletions

View File

@ -4,8 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
egui = { version = "0.29.1", default-features = false }
egui = { version = "0.29.0", default-features = false }
qrcode = { version = "0.14.1", default-features = false }
[dev-dependencies]
eframe = "0.29.1"
eframe = "0.29.0"

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# egui_qr
Simple egui painter that renders QR Codes
## Example
```rust
QrCodeWidget::from_data(b"https://google.com")?
.ui(ui);
```

View File

@ -6,7 +6,7 @@ fn main() {
let _ = eframe::run_native(
"egui_qr",
NativeOptions::default(),
Box::new(|_| Box::new(App::new())),
Box::new(|_| Ok(Box::new(App::new()))),
);
}

View File

@ -40,12 +40,7 @@ impl Widget for QrCodeWidget<'_> {
let (response, painter) =
ui.allocate_painter(vec2(w as f32 * scale, w as f32 * scale), Sense::click());
painter.rect(
response.rect,
Rounding::ZERO,
Color32::WHITE,
Stroke::NONE,
);
painter.rect(response.rect, Rounding::ZERO, Color32::WHITE, Stroke::NONE);
let mut ctr = 0;
for c in code_ref.to_colors() {
let row = ctr / w;