From cb7c4676543cd508dfae8d4dcbd9cc8b61b1a94e Mon Sep 17 00:00:00 2001 From: shan Date: Thu, 6 Oct 2022 07:28:05 -0700 Subject: Fixed lint issues & cleaned up some documentation. --- examples/clock/src/main.rs | 6 +++--- examples/modern_art/Cargo.toml | 3 +-- examples/modern_art/src/main.rs | 5 ++--- examples/solar_system/src/main.rs | 7 +++---- glow/src/shader/common/gradient.frag | 2 +- glow/src/shader/common/triangle.frag | 2 +- glow/src/shader/common/triangle.vert | 2 +- glow/src/triangle.rs | 2 +- glow/src/triangle/solid.rs | 6 +++--- graphics/src/gradient.rs | 1 - graphics/src/gradient/linear.rs | 2 +- graphics/src/layer.rs | 2 +- graphics/src/layer/image.rs | 2 +- graphics/src/layer/mesh.rs | 2 +- graphics/src/layer/quad.rs | 2 +- graphics/src/layer/text.rs | 2 +- graphics/src/transformation.rs | 2 +- graphics/src/triangle.rs | 2 +- wgpu/src/buffers.rs | 11 ++++------- wgpu/src/lib.rs | 2 +- wgpu/src/shader/triangle_gradient.wgsl | 2 +- wgpu/src/shader/triangle_solid.wgsl | 2 +- wgpu/src/triangle.rs | 2 +- wgpu/src/triangle/gradient.rs | 2 +- 24 files changed, 33 insertions(+), 40 deletions(-) diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs index 06ed44f0..be614201 100644 --- a/examples/clock/src/main.rs +++ b/examples/clock/src/main.rs @@ -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 canvas::Program 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 canvas::Program 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() } diff --git a/examples/modern_art/Cargo.toml b/examples/modern_art/Cargo.toml index 8242f7e4..a48361ae 100644 --- a/examples/modern_art/Cargo.toml +++ b/examples/modern_art/Cargo.toml @@ -7,5 +7,4 @@ publish = false [dependencies] iced = { path = "../..", features = ["canvas", "tokio", "debug"] } -iced_graphics = { path = "../../graphics" } -rand = "0.8.5" \ No newline at end of file +rand = "0.8.5" diff --git a/examples/modern_art/src/main.rs b/examples/modern_art/src/main.rs index a7aa2d8a..6a22b27f 100644 --- a/examples/modern_art/src/main.rs +++ b/examples/modern_art/src/main.rs @@ -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 -} \ No newline at end of file +} diff --git a/examples/solar_system/src/main.rs b/examples/solar_system/src/main.rs index 8d713ce0..5f90245c 100644 --- a/examples/solar_system/src/main.rs +++ b/examples/solar_system/src/main.rs @@ -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 { - 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 canvas::Program 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, diff --git a/glow/src/shader/common/gradient.frag b/glow/src/shader/common/gradient.frag index 89d2d398..ade9c4a1 100644 --- a/glow/src/shader/common/gradient.frag +++ b/glow/src/shader/common/gradient.frag @@ -47,4 +47,4 @@ void main() { fragColor = color_stops[color_stops_size - 2]; } } -} \ No newline at end of file +} diff --git a/glow/src/shader/common/triangle.frag b/glow/src/shader/common/triangle.frag index 0ee65239..ead40fe5 100644 --- a/glow/src/shader/common/triangle.frag +++ b/glow/src/shader/common/triangle.frag @@ -15,4 +15,4 @@ uniform vec4 color; void main() { fragColor = color; -} \ No newline at end of file +} diff --git a/glow/src/shader/common/triangle.vert b/glow/src/shader/common/triangle.vert index 09a4e324..fe505997 100644 --- a/glow/src/shader/common/triangle.vert +++ b/glow/src/shader/common/triangle.vert @@ -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; -} \ No newline at end of file +} diff --git a/glow/src/triangle.rs b/glow/src/triangle.rs index 5e58f4e4..f26d1cea 100644 --- a/glow/src/triangle.rs +++ b/glow/src/triangle.rs @@ -1,4 +1,4 @@ -//! Draw meshes of triangle. +//! Draw meshes of triangles. mod gradient; mod solid; diff --git a/glow/src/triangle/solid.rs b/glow/src/triangle/solid.rs index d5b73eb9..3d4d1968 100644 --- a/glow/src/triangle/solid.rs +++ b/glow/src/triangle/solid.rs @@ -11,7 +11,7 @@ pub struct SolidProgram { } #[derive(Debug)] -pub(crate) struct SolidUniformData { +struct SolidUniformData { pub color: Color, pub color_location: ::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) } -} \ No newline at end of file +} diff --git a/graphics/src/gradient.rs b/graphics/src/gradient.rs index 33453c67..13600fb9 100644 --- a/graphics/src/gradient.rs +++ b/graphics/src/gradient.rs @@ -29,4 +29,3 @@ impl Gradient { linear::Builder::new(start, end) } } - diff --git a/graphics/src/gradient/linear.rs b/graphics/src/gradient/linear.rs index 00f94adc..1ffe7cf9 100644 --- a/graphics/src/gradient/linear.rs +++ b/graphics/src/gradient/linear.rs @@ -68,4 +68,4 @@ impl Builder { color_stops: stops })) } -} \ No newline at end of file +} diff --git a/graphics/src/layer.rs b/graphics/src/layer.rs index 65e70cb3..08f07c0e 100644 --- a/graphics/src/layer.rs +++ b/graphics/src/layer.rs @@ -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) }) -} \ No newline at end of file +} diff --git a/graphics/src/layer/image.rs b/graphics/src/layer/image.rs index 387b60ed..cbba7888 100644 --- a/graphics/src/layer/image.rs +++ b/graphics/src/layer/image.rs @@ -20,4 +20,4 @@ pub enum Image { /// The bounds of the image. bounds: Rectangle, }, -} \ No newline at end of file +} diff --git a/graphics/src/layer/mesh.rs b/graphics/src/layer/mesh.rs index a025675a..8a6b1d70 100644 --- a/graphics/src/layer/mesh.rs +++ b/graphics/src/layer/mesh.rs @@ -36,4 +36,4 @@ impl <'a> Into