Fixed lint issues & cleaned up some documentation.
This commit is contained in:
parent
1eb8d972ba
commit
cb7c467654
24 changed files with 33 additions and 40 deletions
|
|
@ -1,6 +1,6 @@
|
|||
use iced::executor;
|
||||
use iced::widget::canvas::{
|
||||
Cache, Cursor, Geometry, LineCap, Path, Stroke, Style,
|
||||
Cache, Cursor, Geometry, LineCap, Path, Stroke, stroke,
|
||||
};
|
||||
use iced::widget::{canvas, container};
|
||||
use iced::{
|
||||
|
|
@ -111,7 +111,7 @@ impl<Message> canvas::Program<Message> for Clock {
|
|||
let thin_stroke = || -> Stroke {
|
||||
Stroke {
|
||||
width,
|
||||
style: Style::Solid(Color::WHITE),
|
||||
style: stroke::Style::Solid(Color::WHITE),
|
||||
line_cap: LineCap::Round,
|
||||
..Stroke::default()
|
||||
}
|
||||
|
|
@ -120,7 +120,7 @@ impl<Message> canvas::Program<Message> for Clock {
|
|||
let wide_stroke = || -> Stroke {
|
||||
Stroke {
|
||||
width: width * 3.0,
|
||||
style: Style::Solid(Color::WHITE),
|
||||
style: stroke::Style::Solid(Color::WHITE),
|
||||
line_cap: LineCap::Round,
|
||||
..Stroke::default()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,5 +7,4 @@ publish = false
|
|||
|
||||
[dependencies]
|
||||
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
|
||||
iced_graphics = { path = "../../graphics" }
|
||||
rand = "0.8.5"
|
||||
rand = "0.8.5"
|
||||
|
|
|
|||
|
|
@ -1,13 +1,12 @@
|
|||
use rand::{Rng, thread_rng};
|
||||
use crate::canvas::{Cursor, Geometry};
|
||||
use iced::widget::canvas::{Cache, Fill, Frame, Gradient};
|
||||
use iced::widget::canvas::{Cache, Fill, Frame, Gradient, fill};
|
||||
use iced::widget::{canvas, Canvas};
|
||||
use iced::Settings;
|
||||
use iced::{
|
||||
executor, Application, Color, Command, Element, Length, Point, Rectangle,
|
||||
Renderer, Size, Theme,
|
||||
};
|
||||
use iced_graphics::widget::canvas::fill;
|
||||
|
||||
fn main() -> iced::Result {
|
||||
ModernArt::run(Settings {
|
||||
|
|
@ -139,4 +138,4 @@ fn generate_box(frame: &mut Frame, bounds: Size) -> bool {
|
|||
};
|
||||
|
||||
solid
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use iced::executor;
|
|||
use iced::theme::{self, Theme};
|
||||
use iced::time;
|
||||
use iced::widget::canvas;
|
||||
use iced::widget::canvas::{Cursor, Path, Stroke};
|
||||
use iced::widget::canvas::{Cursor, Path, Stroke, stroke};
|
||||
use iced::window;
|
||||
use iced::{
|
||||
Application, Color, Command, Element, Length, Point, Rectangle, Settings,
|
||||
|
|
@ -19,7 +19,6 @@ use iced::{
|
|||
};
|
||||
|
||||
use std::time::Instant;
|
||||
use crate::canvas::Style;
|
||||
|
||||
pub fn main() -> iced::Result {
|
||||
SolarSystem::run(Settings {
|
||||
|
|
@ -85,7 +84,7 @@ impl Application for SolarSystem {
|
|||
}
|
||||
|
||||
fn subscription(&self) -> Subscription<Message> {
|
||||
time::every(std::time::Duration::from_millis(10)).map(Message::Tick)
|
||||
time::every(time::Duration::from_millis(10)).map(Message::Tick)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -179,7 +178,7 @@ impl<Message> canvas::Program<Message> for State {
|
|||
frame.stroke(
|
||||
&orbit,
|
||||
Stroke {
|
||||
style: Style::Solid(Color::from_rgba8(0, 153, 255, 0.1)),
|
||||
style: stroke::Style::Solid(Color::from_rgba8(0, 153, 255, 0.1)),
|
||||
width: 1.0,
|
||||
line_dash: canvas::LineDash {
|
||||
offset: 0,
|
||||
|
|
|
|||
|
|
@ -47,4 +47,4 @@ void main() {
|
|||
fragColor = color_stops[color_stops_size - 2];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ uniform vec4 color;
|
|||
|
||||
void main() {
|
||||
fragColor = color;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,4 +6,4 @@ out vec2 raw_position;
|
|||
void main() {
|
||||
gl_Position = u_Transform * vec4(i_Position, 0.0, 1.0);
|
||||
raw_position = i_Position;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
//! Draw meshes of triangle.
|
||||
//! Draw meshes of triangles.
|
||||
mod gradient;
|
||||
mod solid;
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ pub struct SolidProgram {
|
|||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct SolidUniformData {
|
||||
struct SolidUniformData {
|
||||
pub color: Color,
|
||||
pub color_location: <Context as HasContext>::UniformLocation,
|
||||
pub transform: Transformation,
|
||||
|
|
@ -74,10 +74,10 @@ impl SolidProgram {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn use_program(&mut self, gl: &glow::Context, color: &Color, transform: &Transformation) {
|
||||
pub fn use_program(&mut self, gl: &Context, color: &Color, transform: &Transformation) {
|
||||
unsafe {
|
||||
gl.use_program(Some(self.program))
|
||||
}
|
||||
self.write_uniforms(gl, color, transform)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,4 +29,3 @@ impl Gradient {
|
|||
linear::Builder::new(start, end)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -68,4 +68,4 @@ impl Builder {
|
|||
color_stops: stops
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -256,4 +256,4 @@ pub fn attribute_count_of<'a>(meshes: &'a [Mesh<'a>]) -> (usize, usize) {
|
|||
.fold((0, 0), |(total_v, total_i), (v, i)| {
|
||||
(total_v + v, total_i + i)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ pub enum Image {
|
|||
/// The bounds of the image.
|
||||
bounds: Rectangle,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,4 +36,4 @@ impl <'a> Into<Style> for Gradient {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,4 +27,4 @@ pub struct Quad {
|
|||
unsafe impl bytemuck::Zeroable for Quad {}
|
||||
|
||||
#[allow(unsafe_code)]
|
||||
unsafe impl bytemuck::Pod for Quad {}
|
||||
unsafe impl bytemuck::Pod for Quad {}
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ pub struct Text<'a> {
|
|||
|
||||
/// The vertical alignment of the [`Text`].
|
||||
pub vertical_alignment: alignment::Vertical,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,4 +56,4 @@ impl Into<Mat4> for Transformation {
|
|||
fn into(self) -> Mat4 {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,4 +16,4 @@ pub struct Mesh2D {
|
|||
pub struct Vertex2D {
|
||||
/// The vertex position in 2D space.
|
||||
pub position: [f32; 2],
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use std::mem;
|
|||
const DEFAULT_STATIC_BUFFER_COUNT: wgpu::BufferAddress = 128;
|
||||
|
||||
/// A generic buffer struct useful for items which have no alignment requirements
|
||||
/// (e.g. Vertex, Index buffers) and are set once and never changed until destroyed.
|
||||
/// (e.g. Vertex, Index buffers) & no dynamic offsets.
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct StaticBuffer<T> {
|
||||
//stored sequentially per mesh iteration; refers to the offset index in the GPU buffer
|
||||
|
|
@ -17,7 +17,6 @@ pub(crate) struct StaticBuffer<T> {
|
|||
label: &'static str,
|
||||
usages: wgpu::BufferUsages,
|
||||
gpu: wgpu::Buffer,
|
||||
//the static size of the buffer
|
||||
size: wgpu::BufferAddress,
|
||||
_data: PhantomData<T>,
|
||||
}
|
||||
|
|
@ -75,11 +74,9 @@ impl<T: Pod + Zeroable> StaticBuffer<T> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Writes the current vertex data to the gpu buffer if it is currently writable with a memcpy &
|
||||
/// stores its offset.
|
||||
/// Writes the current vertex data to the gpu buffer with a memcpy & stores its offset.
|
||||
///
|
||||
/// This will return either the offset of the written bytes, or `None` if the GPU buffer is not
|
||||
/// currently writable.
|
||||
/// Returns the size of the written bytes.
|
||||
pub fn write(
|
||||
&mut self,
|
||||
device: &wgpu::Device,
|
||||
|
|
@ -125,4 +122,4 @@ impl<T: Pod + Zeroable> StaticBuffer<T> {
|
|||
pub fn clear(&mut self) {
|
||||
self.offsets.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@
|
|||
pub mod settings;
|
||||
pub mod triangle;
|
||||
pub mod window;
|
||||
pub mod buffers;
|
||||
|
||||
mod buffers;
|
||||
mod backend;
|
||||
mod quad;
|
||||
mod text;
|
||||
|
|
|
|||
|
|
@ -85,4 +85,4 @@ fn fs_gradient(input: VertexOutput) -> @location(0) vec4<f32> {
|
|||
}
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ fn vs_main(@location(0) input: vec2<f32>) -> @builtin(position) vec4<f32> {
|
|||
@fragment
|
||||
fn fs_solid() -> @location(0) vec4<f32> {
|
||||
return solid_uniforms.color;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ pub(crate) struct Pipeline {
|
|||
pipelines: TrianglePipelines,
|
||||
}
|
||||
|
||||
/// Supported triangle pipelines for different fills. Both use the same vertex shader.
|
||||
/// Supported triangle pipelines for different fills.
|
||||
pub(crate) struct TrianglePipelines {
|
||||
solid: SolidPipeline,
|
||||
gradient: GradientPipeline,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use glam::{IVec4, Vec4};
|
|||
use iced_graphics::gradient::Gradient;
|
||||
use iced_graphics::Transformation;
|
||||
|
||||
pub(super) struct GradientPipeline {
|
||||
pub struct GradientPipeline {
|
||||
pipeline: wgpu::RenderPipeline,
|
||||
pub(super) uniform_buffer: DynamicBuffer<GradientUniforms>,
|
||||
pub(super) storage_buffer: DynamicBuffer<GradientStorage>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue