add get set fill macro
This commit is contained in:
parent
3c27917afa
commit
8d5e408653
6 changed files with 86 additions and 83 deletions
|
@ -1,18 +1,20 @@
|
|||
use crate::macros::{
|
||||
wrap_get_set_fill_2d, wrap_uniffi_object, wrap_width_height,
|
||||
};
|
||||
use servicepoint::{DataRef, Grid};
|
||||
use std::sync::{Arc};
|
||||
use crate::macros::{wrap_width_height, wrap_uniffi_object};
|
||||
use std::sync::Arc;
|
||||
|
||||
wrap_uniffi_object!(Bitmap);
|
||||
wrap_width_height!(Bitmap);
|
||||
wrap_get_set_fill_2d!(Bitmap, bool);
|
||||
|
||||
#[uniffi::export]
|
||||
impl Bitmap {
|
||||
#[uniffi::constructor]
|
||||
pub fn new(width: u64, height: u64) -> Arc<Self> {
|
||||
Self::internal_new(servicepoint::Bitmap::new(
|
||||
width as usize,
|
||||
height as usize,
|
||||
).unwrap())
|
||||
Self::internal_new(
|
||||
servicepoint::Bitmap::new(width as usize, height as usize).unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
#[uniffi::constructor]
|
||||
|
@ -22,28 +24,12 @@ impl Bitmap {
|
|||
|
||||
#[uniffi::constructor]
|
||||
pub fn load(width: u64, height: u64, data: Vec<u8>) -> Arc<Self> {
|
||||
Self::internal_new(servicepoint::Bitmap::load(
|
||||
width as usize,
|
||||
height as usize,
|
||||
&data,
|
||||
).unwrap())
|
||||
Self::internal_new(
|
||||
servicepoint::Bitmap::load(width as usize, height as usize, &data)
|
||||
.unwrap(),
|
||||
)
|
||||
}
|
||||
|
||||
pub fn set(&self, x: u64, y: u64, value: bool) {
|
||||
self.actual
|
||||
.write()
|
||||
.unwrap()
|
||||
.set(x as usize, y as usize, value)
|
||||
}
|
||||
|
||||
pub fn get(&self, x: u64, y: u64) -> bool {
|
||||
self.actual.read().unwrap().get(x as usize, y as usize)
|
||||
}
|
||||
|
||||
pub fn fill(&self, value: bool) {
|
||||
self.actual.write().unwrap().fill(value)
|
||||
}
|
||||
|
||||
pub fn equals(&self, other: &Bitmap) -> bool {
|
||||
let a = self.actual.read().unwrap();
|
||||
let b = other.actual.read().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue