Ask for a Size in Frame::new
This commit is contained in:
parent
b0825ce38b
commit
2381a9310c
2 changed files with 8 additions and 10 deletions
|
|
@ -61,7 +61,7 @@ impl Cache {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut frame = Frame::new(new_bounds.width, new_bounds.height);
|
let mut frame = Frame::new(new_bounds);
|
||||||
input.draw(&mut frame);
|
input.draw(&mut frame);
|
||||||
|
|
||||||
let primitive = Arc::new(frame.into_primitive());
|
let primitive = Arc::new(frame.into_primitive());
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,7 @@ use crate::{
|
||||||
/// [`Canvas`]: struct.Canvas.html
|
/// [`Canvas`]: struct.Canvas.html
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct Frame {
|
pub struct Frame {
|
||||||
width: f32,
|
size: Size,
|
||||||
height: f32,
|
|
||||||
buffers: lyon::tessellation::VertexBuffers<triangle::Vertex2D, u32>,
|
buffers: lyon::tessellation::VertexBuffers<triangle::Vertex2D, u32>,
|
||||||
primitives: Vec<Primitive>,
|
primitives: Vec<Primitive>,
|
||||||
transforms: Transforms,
|
transforms: Transforms,
|
||||||
|
|
@ -36,10 +35,9 @@ impl Frame {
|
||||||
/// top-left corner of its bounds.
|
/// top-left corner of its bounds.
|
||||||
///
|
///
|
||||||
/// [`Frame`]: struct.Frame.html
|
/// [`Frame`]: struct.Frame.html
|
||||||
pub fn new(width: f32, height: f32) -> Frame {
|
pub fn new(size: Size) -> Frame {
|
||||||
Frame {
|
Frame {
|
||||||
width,
|
size,
|
||||||
height,
|
|
||||||
buffers: lyon::tessellation::VertexBuffers::new(),
|
buffers: lyon::tessellation::VertexBuffers::new(),
|
||||||
primitives: Vec::new(),
|
primitives: Vec::new(),
|
||||||
transforms: Transforms {
|
transforms: Transforms {
|
||||||
|
|
@ -57,7 +55,7 @@ impl Frame {
|
||||||
/// [`Frame`]: struct.Frame.html
|
/// [`Frame`]: struct.Frame.html
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn width(&self) -> f32 {
|
pub fn width(&self) -> f32 {
|
||||||
self.width
|
self.size.width
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the width of the [`Frame`].
|
/// Returns the width of the [`Frame`].
|
||||||
|
|
@ -65,7 +63,7 @@ impl Frame {
|
||||||
/// [`Frame`]: struct.Frame.html
|
/// [`Frame`]: struct.Frame.html
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn height(&self) -> f32 {
|
pub fn height(&self) -> f32 {
|
||||||
self.height
|
self.size.height
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the dimensions of the [`Frame`].
|
/// Returns the dimensions of the [`Frame`].
|
||||||
|
|
@ -73,7 +71,7 @@ impl Frame {
|
||||||
/// [`Frame`]: struct.Frame.html
|
/// [`Frame`]: struct.Frame.html
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn size(&self) -> Size {
|
pub fn size(&self) -> Size {
|
||||||
Size::new(self.width, self.height)
|
self.size
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the coordinate of the center of the [`Frame`].
|
/// Returns the coordinate of the center of the [`Frame`].
|
||||||
|
|
@ -81,7 +79,7 @@ impl Frame {
|
||||||
/// [`Frame`]: struct.Frame.html
|
/// [`Frame`]: struct.Frame.html
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn center(&self) -> Point {
|
pub fn center(&self) -> Point {
|
||||||
Point::new(self.width / 2.0, self.height / 2.0)
|
Point::new(self.size.width / 2.0, self.size.height / 2.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Draws the given [`Path`] on the [`Frame`] by filling it with the
|
/// Draws the given [`Path`] on the [`Frame`] by filling it with the
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue