| 1 | use plotters_backendrust-analyzer cargo plotters-backend 0.3.7 crate/::{ |
| 2 | BackendColorrust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#, BackendCoordrust-analyzer cargo plotters-backend 0.3.7 BackendCoord#, BackendStylerust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#, DrawingBackendrust-analyzer cargo plotters-backend 0.3.7 DrawingBackend#, DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#, |
| 3 | }; |
| 4 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::markerrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/::PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#; |
| 5 | |
| 6 | use craterust-analyzer cargo plotters-bitmap 0.3.7 crate/::bitmap_pixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/::{PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#, RGBPixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/rgb/RGBPixel#}; |
| 7 | use craterust-analyzer cargo plotters-bitmap 0.3.7 crate/::errorrust-analyzer cargo plotters-bitmap 0.3.7 error/::BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#; |
| 8 | |
| 9 | #[cfg(all(not(target_arch = "wasm32"), feature = "image"))] |
| 10 | mod image_encoding_supportrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/image_encoding_support/ { |
| 11 | pub(superrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/) use imagerust-analyzer cargo image 0.25.10 crate/::{ImageBufferrust-analyzer cargo image 0.25.10 images/buffer/ImageBuffer#, Rgbrust-analyzer cargo image 0.25.10 color/Rgb#}; |
| 12 | pub(superrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/) use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/::Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#; |
| 13 | pub(superrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/) type BorrowedImagerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/image_encoding_support/BorrowedImage#<'a> = ImageBufferrust-analyzer cargo image 0.25.10 images/buffer/ImageBuffer#<Rgbrust-analyzer cargo image 0.25.10 color/Rgb#<u8>, &'a mut [u8]>; |
| 14 | } |
| 15 | |
| 16 | #[cfg(all(not(target_arch = "wasm32"), feature = "image"))] |
| 17 | use image_encoding_supportrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/image_encoding_support/::*; |
| 18 | |
| 19 | mod targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/; |
| 20 | |
| 21 | use targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/::{Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#, Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#}; |
| 22 | |
| 23 | /// The backend that drawing a bitmap |
| 24 | /// |
| 25 | /// # Warning |
| 26 | /// |
| 27 | /// You should call [`.present()?`](plotters_backend::DrawingBackend::present) on a |
| 28 | /// `BitMapBackend`, not just `drop` it or allow it to go out of scope. |
| 29 | /// |
| 30 | /// If the `BitMapBackend` is just dropped, it will make a best effort attempt to write the |
| 31 | /// generated charts to the output file, but any errors that occur (such as inability to |
| 32 | /// create the output file) will be silently ignored. |
| 33 | pub struct BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'a, P: PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat# = RGBPixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/rgb/RGBPixel#> { |
| 34 | /// The path to the image |
| 35 | #[allow(dead_code)] |
| 36 | targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#target.: Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#<'a>, |
| 37 | /// The size of the image |
| 38 | sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size.: (u32, u32), |
| 39 | /// The data buffer of the image |
| 40 | bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer.: Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#<'a>, |
| 41 | /// Flag indicates if the bitmap has been saved |
| 42 | savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved.: bool, |
| 43 | _pantomdatarust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#_pantomdata.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#<P>, |
| 44 | } |
| 45 | |
| 46 | impl<'a, P: PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#> BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'a, P> { |
| 47 | /// The number of bytes per pixel |
| 48 | const PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE.: usize = P::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#PIXEL_SIZE.; |
| 49 | } |
| 50 | |
| 51 | impl<'a> BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'a, RGBPixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/rgb/RGBPixel#> { |
| 52 | /// Create a new bitmap backend |
| 53 | #[cfg(all(not(target_arch = "wasm32"), feature = "image"))] |
| 54 | pub fn newrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]new().<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#> + ?Sizedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/Sized#>(path: &'a T, (w, h): (u32, u32)) -> Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`] { |
| 55 | Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`] { |
| 56 | targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#target.: Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Filerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#File#(path.as_refrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#as_ref().()), |
| 57 | sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size.: (w, h), |
| 58 | bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer.: Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#::Ownedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#Owned#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). (w *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). h) as usize]), |
| 59 | savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved.: false, |
| 60 | _pantomdatarust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#_pantomdata.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | /// Create a new bitmap backend that generate GIF animation |
| 65 | /// |
| 66 | /// When this is used, the bitmap backend acts similar to a real-time rendering backend. |
| 67 | /// When the program finished drawing one frame, use `present` function to flush the frame |
| 68 | /// into the GIF file. |
| 69 | /// |
| 70 | /// - `path`: The path to the GIF file to create |
| 71 | /// - `dimension`: The size of the GIF image |
| 72 | /// - `speed`: The amount of time for each frame to display |
| 73 | #[cfg(all(feature = "gif", not(target_arch = "wasm32"), feature = "image"))] |
| 74 | pub fn gifrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]gif().<T: AsRefrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/AsRef#<Pathrust-analyzer cargo std https://github.com/rust-lang/rust/library/std path/Path#>>( |
| 75 | path: T, |
| 76 | (w, h): (u32, u32), |
| 77 | frame_delay: u32, |
| 78 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`], BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#> { |
| 79 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`] { |
| 80 | targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#target.: Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Gifrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#Gif#(Boxrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/Box#::newrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc boxed/impl#[`Box<T>`]new().(craterust-analyzer cargo plotters-bitmap 0.3.7 crate/::gif_supportrust-analyzer cargo plotters-bitmap 0.3.7 gif_support/::GifFilerust-analyzer cargo plotters-bitmap 0.3.7 gif_support/GifFile#::newrust-analyzer cargo plotters-bitmap 0.3.7 gif_support/impl#[GifFile]new().( |
| 81 | path, |
| 82 | (w, h), |
| 83 | frame_delay, |
| 84 | )?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().)), |
| 85 | sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size.: (w, h), |
| 86 | bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer.: Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#::Ownedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#Owned#(vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0; Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). (w *rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). h) as usize]), |
| 87 | savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved.: false, |
| 88 | _pantomdatarust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#_pantomdata.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 89 | }) |
| 90 | } |
| 91 | |
| 92 | /// Create a new bitmap backend which only lives in-memory |
| 93 | /// |
| 94 | /// When this is used, the bitmap backend will write to a user provided [u8] array (or `Vec<u8>`) |
| 95 | /// in RGB pixel format. |
| 96 | /// |
| 97 | /// Note: This function provides backward compatibility for those code that assumes Plotters |
| 98 | /// uses RGB pixel format and manipulates the in-memory framebuffer. |
| 99 | /// For more pixel format option, use `with_buffer_and_format` instead. |
| 100 | /// |
| 101 | /// - `buf`: The buffer to operate |
| 102 | /// - `dimension`: The size of the image in pixels |
| 103 | /// - **returns**: The newly created bitmap backend |
| 104 | pub fn with_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]with_buffer().(buf: &'a mut [u8], (w, h): (u32, u32)) -> Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`] { |
| 105 | Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a>`]::with_buffer_and_formatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]with_buffer_and_format().(buf, (w, h)).expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]expect().("Wrong buffer size") |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | impl<'a, P: PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#> BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'a, P> { |
| 110 | /// Create a new bitmap backend with a in-memory buffer with specific pixel format. |
| 111 | /// |
| 112 | /// Note: This can be used as a way to manipulate framebuffer, `mmap` can be used on the top of this |
| 113 | /// as well. |
| 114 | /// |
| 115 | /// - `buf`: The buffer to operate |
| 116 | /// - `dimension`: The size of the image in pixels |
| 117 | /// - **returns**: The newly created bitmap backend |
| 118 | pub fn with_buffer_and_formatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]with_buffer_and_format().( |
| 119 | buf: &'a mut [u8], |
| 120 | (w, h): (u32, u32), |
| 121 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`], BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#> { |
| 122 | if (w rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().h) as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().buf.lenrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]len().() { |
| 123 | return Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#::InvalidBufferrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#InvalidBuffer#); |
| 124 | } |
| 125 | |
| 126 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`] { |
| 127 | targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#target.: Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#Buffer#(PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#), |
| 128 | sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size.: (w, h), |
| 129 | bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer.: Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#::Borrowedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Buffer#Borrowed#(buf), |
| 130 | savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved.: false, |
| 131 | _pantomdatarust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#_pantomdata.: PhantomDatarust-analyzer cargo core https://github.com/rust-lang/rust/library/core marker/PhantomData#, |
| 132 | }) |
| 133 | } |
| 134 | |
| 135 | #[inline(always)] |
| 136 | pub(craterust-analyzer cargo plotters-bitmap 0.3.7 crate/) fn get_raw_pixel_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]get_raw_pixel_buffer().(&mut self) -> &mut [u8] { |
| 137 | self.bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer..borrow_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/impl#[`Buffer<'a>`]borrow_buffer().() |
| 138 | } |
| 139 | |
| 140 | /// Split a bitmap backend vertically into several sub drawing area which allows |
| 141 | /// multi-threading rendering. |
| 142 | /// |
| 143 | /// - `area_size`: The size of the area |
| 144 | /// - **returns**: The split backends that can be rendered in parallel |
| 145 | pub fn splitrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]split().(&mut self, area_size: &[u32]) -> Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<P>> { |
| 146 | let (w, h) = self.get_sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]get_size().(); |
| 147 | let buf = self.get_raw_pixel_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]get_raw_pixel_buffer().(); |
| 148 | |
| 149 | let base_addr = &mut buf[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). as *mut u8; |
| 150 | let mut split_points = vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc macros/vec!![0]; |
| 151 | for size in area_size { |
| 152 | let next = split_points.lastrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]last().().unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]unwrap().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Add<Self>`]add().size; |
| 153 | if next rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().h { |
| 154 | break; |
| 155 | } |
| 156 | split_points.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(next); |
| 157 | } |
| 158 | split_points.pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(h); |
| 159 | |
| 160 | split_points |
| 161 | .iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().() |
| 162 | .ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(split_points.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().().skiprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#skip().(1)) |
| 163 | .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(|(begin, end)| { |
| 164 | let actual_buf = unsafe { |
| 165 | stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::slicerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc slice/::from_raw_parts_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/raw/from_raw_parts_mut().( |
| 166 | base_addr.offsetrust-analyzer cargo core https://github.com/rust-lang/rust/library/core ptr/mut_ptr/impl#[`*mut T`]offset().((begin rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Mul<u32>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Mul<u32>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Mul<u32>`]mul().w) as isize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[isize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. as isize), |
| 167 | ((end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub().begin) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[u32][`Mul<Self>`]mul().w) as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE., |
| 168 | ) |
| 169 | }; |
| 170 | Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]::with_buffer_and_formatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]with_buffer_and_format().(actual_buf, (w, end rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[`&u32`][`Sub<Self>`]sub().begin)).unwraprust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]unwrap().() |
| 171 | }) |
| 172 | .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().() |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | impl<'a, P: PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#> DrawingBackendrust-analyzer cargo plotters-backend 0.3.7 DrawingBackend# for BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'a, P> { |
| 177 | type ErrorTyperust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]ErrorType# = BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#; |
| 178 | |
| 179 | fn get_sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]get_size().(&self) -> (u32, u32) { |
| 180 | self.sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size. |
| 181 | } |
| 182 | |
| 183 | fn ensure_preparedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]ensure_prepared().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#>> { |
| 184 | self.savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved. = false; |
| 185 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 186 | } |
| 187 | |
| 188 | #[cfg(any(target_arch = "wasm32", not(feature = "image")))] |
| 189 | fn present(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#>> { |
| 190 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 191 | } |
| 192 | |
| 193 | #[cfg(all(not(target_arch = "wasm32"), feature = "image"))] |
| 194 | fn presentrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]present().(&mut self) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#>> { |
| 195 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().P::can_be_savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#can_be_saved().() { |
| 196 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 197 | } |
| 198 | let (w, h) = self.get_sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]get_size().(); |
| 199 | match &mut self.targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#target. { |
| 200 | Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Filerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#File#(path) => { |
| 201 | if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(img) = BorrowedImagerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/image_encoding_support/BorrowedImage#::from_rawrust-analyzer cargo image 0.25.10 images/buffer/impl#[`ImageBuffer<P, Container>`]from_raw().(w, h, self.bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer..borrow_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/impl#[`Buffer<'a>`]borrow_buffer().()) { |
| 202 | img.saverust-analyzer cargo image 0.25.10 images/buffer/impl#[`ImageBuffer<P, Container>`]save().(&path).map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(|x| { |
| 203 | DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#::DrawingErrorrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#DrawingError#(BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#::ImageErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#ImageError#(x)) |
| 204 | })?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 205 | self.savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved. = true; |
| 206 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 207 | } else { |
| 208 | Errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Err#(DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#::DrawingErrorrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#DrawingError#( |
| 209 | BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#::InvalidBufferrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#InvalidBuffer#, |
| 210 | )) |
| 211 | } |
| 212 | } |
| 213 | Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#Buffer#(_) => Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()), |
| 214 | |
| 215 | #[cfg(all(feature = "gif", not(target_arch = "wasm32"), feature = "image"))] |
| 216 | Targetrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#::Gifrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/Target#Gif#(target) => { |
| 217 | target |
| 218 | .flush_framerust-analyzer cargo plotters-bitmap 0.3.7 gif_support/impl#[GifFile]flush_frame().(self.bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#buffer..borrow_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/target/impl#[`Buffer<'a>`]borrow_buffer().()) |
| 219 | .map_errrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`]map_err().(DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#::DrawingErrorrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#DrawingError#)?rust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/impl#[`Result<T, E>`][Try]branch().; |
| 220 | self.savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved. = true; |
| 221 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 222 | } |
| 223 | } |
| 224 | } |
| 225 | |
| 226 | fn draw_pixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]draw_pixel().( |
| 227 | &mut self, |
| 228 | point: BackendCoordrust-analyzer cargo plotters-backend 0.3.7 BackendCoord#, |
| 229 | color: BackendColorrust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#, |
| 230 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<BitMapBackendErrorrust-analyzer cargo plotters-bitmap 0.3.7 error/BitMapBackendError#>> { |
| 231 | if point.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 |
| 232 | || point.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().<rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialOrd<Self>`]lt().0 |
| 233 | || point.0 as u32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().self.sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size..0 |
| 234 | || point.1 as u32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialOrd<Self>`]ge().self.sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#size..1 |
| 235 | { |
| 236 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 237 | } |
| 238 | |
| 239 | let alpha = color.alpharust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#alpha.; |
| 240 | let rgb = color.rgbrust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#rgb.; |
| 241 | |
| 242 | P::draw_pixelrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#draw_pixel().(self, point, rgb, alpha); |
| 243 | |
| 244 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 245 | } |
| 246 | |
| 247 | fn draw_linerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]draw_line().<S: BackendStylerust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#>( |
| 248 | &mut self, |
| 249 | from: (i32, i32), |
| 250 | to: (i32, i32), |
| 251 | style: &S, |
| 252 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::ErrorTyperust-analyzer cargo plotters-backend 0.3.7 DrawingBackend#ErrorType#>> { |
| 253 | let alpha = style.colorrust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#color().().alpharust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#alpha.; |
| 254 | let (r, g, b) = style.colorrust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#color().().rgbrust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#rgb.; |
| 255 | |
| 256 | if (from.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().to.0 || from.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().to.1) && style.stroke_widthrust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#stroke_width().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[u32][`PartialEq<Self>`]eq().1 { |
| 257 | if alpha rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().1.0 { |
| 258 | if from.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().to.1 { |
| 259 | P::fill_rect_fastrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#fill_rect_fast().(self, from, (to.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1, to.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1), r, g, b); |
| 260 | } else { |
| 261 | P::fill_vertical_line_fastrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#fill_vertical_line_fast().(self, from.0, (from.1, to.1), r, g, b); |
| 262 | } |
| 263 | } else { |
| 264 | P::blend_rect_fastrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#blend_rect_fast().(self, from, (to.0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1, to.1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().1), r, g, b, alpha); |
| 265 | } |
| 266 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 267 | } |
| 268 | |
| 269 | plotters_backendrust-analyzer cargo plotters-backend 0.3.7 crate/::rasterizerrust-analyzer cargo plotters-backend 0.3.7 rasterizer/::draw_linerust-analyzer cargo plotters-backend 0.3.7 rasterizer/line/draw_line().(self, from, to, style) |
| 270 | } |
| 271 | |
| 272 | fn draw_rectrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]draw_rect().<S: BackendStylerust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#>( |
| 273 | &mut self, |
| 274 | upper_left: (i32, i32), |
| 275 | bottom_right: (i32, i32), |
| 276 | style: &S, |
| 277 | fill: bool, |
| 278 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::ErrorTyperust-analyzer cargo plotters-backend 0.3.7 DrawingBackend#ErrorType#>> { |
| 279 | let alpha = style.colorrust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#color().().alpharust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#alpha.; |
| 280 | let (r, g, b) = style.colorrust-analyzer cargo plotters-backend 0.3.7 style/BackendStyle#color().().rgbrust-analyzer cargo plotters-backend 0.3.7 style/BackendColor#rgb.; |
| 281 | if fill { |
| 282 | if alpha rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().>=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[f64][`PartialOrd<Self>`]ge().1.0 { |
| 283 | P::fill_rect_fastrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#fill_rect_fast().(self, upper_left, bottom_right, r, g, b); |
| 284 | } else { |
| 285 | P::blend_rect_fastrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#blend_rect_fast().(self, upper_left, bottom_right, r, g, b, alpha); |
| 286 | } |
| 287 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 288 | } |
| 289 | plotters_backendrust-analyzer cargo plotters-backend 0.3.7 crate/::rasterizerrust-analyzer cargo plotters-backend 0.3.7 rasterizer/::draw_rectrust-analyzer cargo plotters-backend 0.3.7 rasterizer/rect/draw_rect().(self, upper_left, bottom_right, style, fill) |
| 290 | } |
| 291 | |
| 292 | fn blit_bitmaprust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]blit_bitmap().( |
| 293 | &mut self, |
| 294 | pos: BackendCoordrust-analyzer cargo plotters-backend 0.3.7 BackendCoord#, |
| 295 | (sw, sh): (u32, u32), |
| 296 | src: &[u8], |
| 297 | ) -> Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<(), DrawingErrorKindrust-analyzer cargo plotters-backend 0.3.7 DrawingErrorKind#<Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::ErrorTyperust-analyzer cargo plotters-backend 0.3.7 DrawingBackend#ErrorType#>> { |
| 298 | let (dw, dh) = self.get_sizerust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]get_size().(); |
| 299 | |
| 300 | let (x0, y0) = pos; |
| 301 | let (x1, y1) = (x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().sw as i32, y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().sh as i32); |
| 302 | |
| 303 | let (x0, y0, x1, y1) = (x0.maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(0), y0.maxrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#max().(0), x1.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(dw as i32), y1.minrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ord#min().(dh as i32)); |
| 304 | |
| 305 | if x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().x1 || y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[i32][`PartialEq<Self>`]eq().y1 { |
| 306 | return Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()); |
| 307 | } |
| 308 | |
| 309 | let mut chunk_size = (x1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().x0) as usize; |
| 310 | let mut num_chunks = (y1 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().y0) as usize; |
| 311 | let dst_gap = dw as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().chunk_size; |
| 312 | let src_gap = sw as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().chunk_size; |
| 313 | |
| 314 | let dst_start = Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().(y0 as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().dw as usize rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().x0 as usize); |
| 315 | |
| 316 | let mut dst = &mut self.get_raw_pixel_bufferrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]get_raw_pixel_buffer().()[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().dst_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().; |
| 317 | |
| 318 | let src_start = |
| 319 | Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE. rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().((sh as i32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().y0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().y1) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Mul<Self>`]mul().sw as i32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().(sw as i32 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Add<Self>`]add().x0 rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[i32][`Sub<Self>`]sub().x1)) as usize; |
| 320 | let mut src = &src[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().src_start..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 321 | |
| 322 | if src_gap rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 && dst_gap rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().0 { |
| 323 | chunk_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign().*=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`MulAssign<Self>`]mul_assign().num_chunks; |
| 324 | num_chunks = 1; |
| 325 | } |
| 326 | for i in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#num_chunks { |
| 327 | dst[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(chunk_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE.)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut(). |
| 328 | .copy_from_slicerust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]copy_from_slice().(&src[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#(chunk_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE.)]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().); |
| 329 | if i rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().!=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]ne().num_chunks rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1 { |
| 330 | dst = &mut dst[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().((chunk_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().dst_gap) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE.)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/IndexMut#index_mut().; |
| 331 | src = &src[rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().((chunk_size rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().+rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Add<Self>`]add().src_gap) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Mul<Self>`]mul().Selfrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]::PIXEL_SIZErust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`]PIXEL_SIZE.)..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/index/Index#index().; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | Okrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#Ok#(()) |
| 336 | } |
| 337 | } |
| 338 | |
| 339 | impl<P: PixelFormatrust-analyzer cargo plotters-bitmap 0.3.7 bitmap_pixel/pixel_format/PixelFormat#> Droprust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/drop/Drop# for BitMapBackendrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#<'_, P> { |
| 340 | fn droprust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'_, P>`][Drop]drop().(&mut self) { |
| 341 | if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.savedrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/BitMapBackend#saved. { |
| 342 | // drop should not panic, so we ignore a failed present |
| 343 | let _ = self.presentrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/impl#[`BitMapBackend<'a, P>`][DrawingBackend]present().(); |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | #[cfg(test)] |
| 349 | mod testrust-analyzer cargo plotters-bitmap 0.3.7 bitmap/test/; |