-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbd1b1d
commit 7bb14fd
Showing
23 changed files
with
591 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,5 +88,4 @@ fn app() -> impl Widget { | |
})), | ||
))), | ||
)) | ||
.contain_margins(true) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
use tracing_subscriber::{ | ||
prelude::__tracing_subscriber_SubscriberExt, registry, util::SubscriberInitExt, EnvFilter, | ||
}; | ||
use tracing_tree::HierarchicalLayer; | ||
use violet::core::{ | ||
style::{colors::EMERALD_500, secondary_background, spacing_medium, Background, SizeExt}, | ||
unit::Unit, | ||
widget::{Positioned, Rectangle, Stack}, | ||
Widget, | ||
}; | ||
|
||
pub fn main() -> anyhow::Result<()> { | ||
registry() | ||
.with( | ||
HierarchicalLayer::default() | ||
.with_deferred_spans(true) | ||
.with_span_retrace(true) | ||
.with_indent_lines(true), | ||
) | ||
.with(EnvFilter::from_default_env()) | ||
.init(); | ||
|
||
violet_wgpu::AppBuilder::new().run(app()) | ||
} | ||
|
||
fn app() -> impl Widget { | ||
Stack::new( | ||
Positioned::new( | ||
Rectangle::new(EMERALD_500) | ||
.with_min_size(Unit::px2(100.0, 100.0)) | ||
.with_margin(spacing_medium()), | ||
) | ||
.with_offset(Unit::px2(10.0, 10.0)), | ||
) | ||
.with_padding(spacing_medium()) | ||
.with_background(Background::new(secondary_background())) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
use futures::StreamExt; | ||
use futures_signals::signal::Mutable; | ||
use glam::{vec2, Vec2}; | ||
use itertools::Itertools; | ||
use palette::{FromColor, Hsl, Hsv, IntoColor, Oklcha, Srgba}; | ||
use tracing_subscriber::{ | ||
prelude::__tracing_subscriber_SubscriberExt, registry, util::SubscriberInitExt, EnvFilter, | ||
}; | ||
use tracing_tree::HierarchicalLayer; | ||
use violet::core::{ | ||
style::{spacing_small, SizeExt}, | ||
unit::Unit, | ||
widget::{col, Rectangle}, | ||
Widget, | ||
}; | ||
use violet_core::{ | ||
state::{State, StateStream}, | ||
style::{colors::AMBER_500, secondary_background, spacing_medium, Background}, | ||
widget::{label, Button, Checkbox, Scroll, StreamWidget}, | ||
}; | ||
|
||
pub fn main() -> anyhow::Result<()> { | ||
registry() | ||
.with( | ||
HierarchicalLayer::default() | ||
.with_deferred_spans(true) | ||
.with_span_retrace(true) | ||
.with_indent_lines(true), | ||
) | ||
.with(EnvFilter::from_default_env()) | ||
.init(); | ||
|
||
violet_wgpu::AppBuilder::new().run(app()) | ||
} | ||
|
||
#[derive(Debug, Clone, Copy, PartialEq, Eq)] | ||
enum ColorSpace { | ||
Oklcha, | ||
Hsv, | ||
Hsl, | ||
} | ||
|
||
fn app() -> impl Widget { | ||
let color_space = Mutable::new(ColorSpace::Oklcha); | ||
col(( | ||
Checkbox::label( | ||
"Oklch", | ||
color_space.clone().map( | ||
|v| v == ColorSpace::Oklcha, | ||
|v| { | ||
if v { | ||
ColorSpace::Oklcha | ||
} else { | ||
ColorSpace::Hsv | ||
} | ||
}, | ||
), | ||
), | ||
Scroll::new( | ||
StreamWidget(color_space.stream().map(|color_space| { | ||
col((0..180) | ||
.map(|v| { | ||
let hue = v as f32 * 2.0; | ||
|
||
let color: Srgba = match color_space { | ||
ColorSpace::Oklcha => Oklcha::new(0.5, 0.37, hue, 1.0).into_color(), | ||
ColorSpace::Hsv => Hsv::new(hue, 1.0, 1.0).into_color(), | ||
ColorSpace::Hsl => Hsl::new(hue, 1.0, 0.5).into_color(), | ||
}; | ||
|
||
Rectangle::new(color) | ||
// .with_margin(spacing_medium()) | ||
.with_min_size(Unit::px2(100.0, 20.0)) | ||
.with_maximize(Vec2::X) | ||
}) | ||
.collect_vec()) | ||
.with_padding(spacing_medium()) | ||
})), | ||
// .with_background(Background::new(violet_core::style::accent_background())) | ||
), | ||
Button::label("Button"), | ||
)) | ||
.with_background(Background::new(secondary_background())) | ||
.with_padding(spacing_medium()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
use flax::{EntityRef, World}; | ||
|
||
use crate::components::children; | ||
|
||
pub struct OrderedDfsIterator<'a> { | ||
world: &'a World, | ||
// queue: VecDeque<EntityRef<'a>>, | ||
stack: Vec<EntityRef<'a>>, | ||
} | ||
|
||
impl<'a> OrderedDfsIterator<'a> { | ||
pub fn new(world: &'a World, stack: EntityRef<'a>) -> Self { | ||
Self { | ||
world, | ||
stack: vec![stack], | ||
} | ||
} | ||
} | ||
|
||
impl<'a> Iterator for OrderedDfsIterator<'a> { | ||
type Item = EntityRef<'a>; | ||
|
||
fn next(&mut self) -> Option<Self::Item> { | ||
let entity = self.stack.pop()?; | ||
if let Ok(children) = entity.get(children()) { | ||
self.stack.extend( | ||
children | ||
.iter() | ||
.rev() | ||
.map(|&id| self.world.entity(id).unwrap()), | ||
); | ||
} | ||
|
||
Some(entity) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.