Skip to content

Commit

Permalink
Some work on colors and images
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkleiny committed Jul 13, 2024
1 parent 78637be commit 57b3c90
Show file tree
Hide file tree
Showing 17 changed files with 120 additions and 222 deletions.
5 changes: 3 additions & 2 deletions backends/sdl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
use std::ffi::{c_int, CString};

use common::FastHashSet;
use graphics::Image;
pub use sdl2_sys as sys;
use sdl2_sys::{
SDL_GLattr::{
Expand Down Expand Up @@ -34,7 +35,7 @@ pub struct WindowSettings {
pub width: u32,
pub height: u32,
pub vsync_enabled: bool,
pub icon: Option<graphics::Color32Image>,
pub icon: Option<Image>,
}

impl Default for WindowSettings {
Expand Down Expand Up @@ -117,7 +118,7 @@ impl Window {
}

/// Sets the window icon.
pub fn set_window_icon(&self, icon: &graphics::Color32Image) {
pub fn set_window_icon(&self, icon: &Image) {
use sdl2_sys::*;

unsafe {
Expand Down
6 changes: 0 additions & 6 deletions crates/common/src/abstractions/assets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ pub enum AssetError {
/// Represents an asset that can be loaded and used by the engine
pub trait Asset {}

/// An entry in the asset manager
enum AssetEntry {
Unloaded,
Loaded(Box<dyn Asset>),
}

/// A manager for assets
#[derive(Default)]
pub struct AssetManager {}
2 changes: 2 additions & 0 deletions crates/common/src/maths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
pub use angles::*;
pub use cameras::*;
pub use colors::*;
pub use curves::*;
pub use geometry::*;
pub use hex::*;
Expand All @@ -19,6 +20,7 @@ pub use time::*;

mod angles;
mod cameras;
mod colors;
mod curves;
mod geometry;
mod hex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
use std::ops::{Div, Index, Mul};

use common::{ApproxEq, FromRandom, Lerp, Random, Scalar, ToVirtualPath};
use super::*;
use crate::ToVirtualPath;

/// Represents a type of pixel.
pub trait Pixel: Copy + Default {
Expand Down Expand Up @@ -88,10 +89,10 @@ impl PartialEq for Color {
impl Lerp for Color {
fn lerp(a: Color, b: Color, t: f32) -> Self {
Color::rgba(
f32::lerp(a.r, b.r, t),
f32::lerp(a.g, b.g, t),
f32::lerp(a.b, b.b, t),
f32::lerp(a.a, b.a, t),
<f32 as Lerp>::lerp(a.r, b.r, t),
<f32 as Lerp>::lerp(a.g, b.g, t),
<f32 as Lerp>::lerp(a.b, b.b, t),
<f32 as Lerp>::lerp(a.a, b.a, t),
)
}
}
Expand Down
4 changes: 1 addition & 3 deletions crates/graphics/src/animations.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
//! Animation support.
use common::{FastHashMap, Lerp, Quat, StringName, TimeSpan, Vec2, Vec3};

use crate::{Color, Color32};
use common::{Color, Color32, FastHashMap, Lerp, Quat, StringName, TimeSpan, Vec2, Vec3};

/// Represents a type that can be animated by an animation tree.
pub trait Animatable<V> {
Expand Down
2 changes: 1 addition & 1 deletion crates/graphics/src/geometry.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Geometry batching for common shapes and polygon rendering.
use common::{vec2, Rectangle, Vec2};
use common::{vec2, Color32, Rectangle, Vec2};

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion crates/graphics/src/headless.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use std::sync::atomic::{AtomicU32, Ordering};

use common::{Rectangle, UVec2};
use common::{Color, Rectangle, UVec2};

use super::*;

Expand Down
Loading

0 comments on commit 57b3c90

Please sign in to comment.