tui_color_test.rs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. use dioxus::prelude::*;
  2. fn main() {
  3. dioxus::tui::launch_cfg(
  4. app,
  5. dioxus::tui::Config {
  6. rendering_mode: dioxus::tui::RenderingMode::Ansi,
  7. },
  8. );
  9. }
  10. fn app(cx: Scope) -> Element {
  11. let steps = 50;
  12. cx.render(rsx! {
  13. div{
  14. width: "100%",
  15. height: "100%",
  16. flex_direction: "column",
  17. (0..=steps).map(|x|
  18. {
  19. let hue = x as f32*360.0/steps as f32;
  20. cx.render(rsx! {
  21. div{
  22. width: "100%",
  23. height: "100%",
  24. flex_direction: "row",
  25. (0..=steps).map(|y|
  26. {
  27. let alpha = y as f32*100.0/steps as f32;
  28. cx.render(rsx! {
  29. div {
  30. left: "{x}px",
  31. top: "{y}px",
  32. width: "10%",
  33. height: "100%",
  34. background_color: "hsl({hue}, 100%, 50%, {alpha}%)",
  35. }
  36. })
  37. }
  38. )
  39. }
  40. })
  41. }
  42. )
  43. }
  44. })
  45. }