Use Color in View
This commit is contained in:
parent
097f4ee548
commit
f3f8af39d4
2 changed files with 6 additions and 4 deletions
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{Buffer, Rect, Vec2};
|
||||
use crate::{Buffer, Color, Rect, Vec2};
|
||||
|
||||
// TODO Add Orientation (from inkfo)
|
||||
|
||||
|
|
@ -38,10 +38,12 @@ impl<'a, C> View<'a, C> {
|
|||
pub fn at(&self, pos: Vec2) -> Option<&C> {
|
||||
self.buffer.at(self.pos_to_buffer_pos(pos))
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Color> View<'_, C> {
|
||||
pub fn set(&mut self, pos: Vec2, color: C) {
|
||||
if let Some(pixel) = self.buffer.at_mut(self.pos_to_buffer_pos(pos)) {
|
||||
*pixel = color;
|
||||
*pixel = color.over(*pixel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
use crate::{BoxedWidget, Vec2, Widget};
|
||||
use crate::{BoxedWidget, Color, Vec2, Widget};
|
||||
|
||||
pub struct Background<C> {
|
||||
inner: BoxedWidget<C>,
|
||||
|
|
@ -11,7 +11,7 @@ impl<C> Background<C> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<C: Copy> Widget<C> for Background<C> {
|
||||
impl<C: Color> Widget<C> for Background<C> {
|
||||
fn size(&self, max_width: Option<i32>, max_height: Option<i32>) -> crate::Vec2 {
|
||||
self.inner.size(max_width, max_height)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue