ril icon indicating copy to clipboard operation
ril copied to clipboard

Polygon incorrect offset

Open fantasyzhjk opened this issue 2 years ago • 1 comments

code example

let mut image = Image::new(100, 100, Rgba::white());
Polygon {
    vertices: vec![(0,100), (100,100), (100,0), (0,0)],
    ..Polygon::default()
}.with_fill(Rgba::black()).draw(&mut image);

output image

new

and if you turn on the antialias, rust will panic

❯ RUST_BACKTRACE=1 cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.15s
     Running `target\debug\image.exe`
thread 'main' panicked at 'invalid bounding box', D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\draw.rs:925:9
stack backtrace:
   0: std::panicking::begin_panic_handler
             at /rustc/e0098a5cc3a87d857e597af824d0ce1ed1ad85e0/library\std\src\panicking.rs:575
   1: core::panicking::panic_fmt
             at /rustc/e0098a5cc3a87d857e597af824d0ce1ed1ad85e0/library\core\src\panicking.rs:65
   2: ril::draw::Rectangle<ril::pixel::Rgba>::from_bounding_box<ril::pixel::Rgba>
             at D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\draw.rs:925
   3: ril::draw::Line<ril::pixel::Rgba>::plot_perfect_line<ril::pixel::Rgba>
             at D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\draw.rs:351
   4: ril::draw::impl$7::draw<ril::pixel::Rgba,ref_mut$<ril::image::Image<ril::pixel::Rgba> > >
             at D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\draw.rs:511
   5: ril::image::Image<ril::pixel::Rgba>::draw<ril::pixel::Rgba,ril::draw::Line<ril::pixel::Rgba> >
             at D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\image.rs:1079
   6: ril::draw::impl$10::draw<ril::pixel::Rgba,ref_mut$<ril::image::Image<ril::pixel::Rgba> > >
             at D:\scoop\persist\rustup\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-df7c3c540f42cdbd\ril-0.9.0\src\draw.rs:818
   7: imagers_roundcorner::main
             at .\src\main.rs:5
   8: core::ops::function::FnOnce::call_once<enum2$<core::result::Result<tuple$<>,enum2$<ril::error::Error> > > (*)(),tuple$<> >
             at /rustc/e0098a5cc3a87d857e597af824d0ce1ed1ad85e0\library\core\src\ops\function.rs:507
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\image.exe` (exit code: 101)

fantasyzhjk avatar Dec 15 '22 05:12 fantasyzhjk

the antialias panicking error should be fixed in the latest commit, I'll still have to look into inaccurate polygon vertices though

jay3332 avatar Dec 19 '22 16:12 jay3332