Commit e5f7c627 authored by Rahix's avatar Rahix 🦀
Browse files

colors: Add RC3 colors as constants in Rust as well

Copy the constants from www/src/_rc3-colors.scss to a rust module as
well.
parent 10dc1fcf
#![allow(unused_attributes)]
#![rustfmt::skip]
use crate::resources::Color;
pub const BACKGROUND: Color = Color { red: 0.063, green: 0.055, blue: 0.137, alpha: 1.0};
pub const PRIMARY1_SHADE1: Color = Color { red: 0.698, green: 0.224, blue: 1.000, alpha: 1.0};
pub const PRIMARY1_SHADE2: Color = Color { red: 0.404, green: 0.008, blue: 0.624, alpha: 1.0};
pub const PRIMARY1_SHADE3: Color = Color { red: 0.267, green: 0.000, blue: 0.412, alpha: 1.0};
pub const PRIMARY1_SHADE4: Color = Color { red: 0.141, green: 0.000, blue: 0.220, alpha: 1.0};
pub const PRIMARY2_SHADE1: Color = Color { red: 0.408, green: 0.000, blue: 0.906, alpha: 1.0};
pub const PRIMARY2_SHADE2: Color = Color { red: 0.255, green: 0.000, blue: 0.545, alpha: 1.0};
pub const PRIMARY2_SHADE3: Color = Color { red: 0.165, green: 0.000, blue: 0.369, alpha: 1.0};
pub const PRIMARY2_SHADE4: Color = Color { red: 0.078, green: 0.000, blue: 0.184, alpha: 1.0};
pub const PRIMARY3_SHADE1: Color = Color { red: 0.020, green: 0.725, blue: 0.925, alpha: 1.0};
pub const PRIMARY3_SHADE2: Color = Color { red: 0.000, green: 0.463, blue: 0.663, alpha: 1.0};
pub const PRIMARY3_SHADE3: Color = Color { red: 0.008, green: 0.365, blue: 0.518, alpha: 1.0};
pub const PRIMARY3_SHADE4: Color = Color { red: 0.000, green: 0.165, blue: 0.227, alpha: 1.0};
use crate::colors;
use crate::components; use crate::components;
use crate::resources; use crate::resources;
use legion::IntoQuery; use legion::IntoQuery;
...@@ -28,7 +29,7 @@ pub fn draw_edges( ...@@ -28,7 +29,7 @@ pub fn draw_edges(
rendering.begin_path(); rendering.begin_path();
rendering.set_line_width(7.0); rendering.set_line_width(7.0);
rendering.set_stroke_style(&resources::Color::with_rgb(0.164, 0.0, 0.367)); rendering.set_stroke_style(&colors::PRIMARY2_SHADE3);
rendering.move_to(pos1.0.x as f64, pos1.0.y as f64); rendering.move_to(pos1.0.x as f64, pos1.0.y as f64);
rendering.line_to(pos2.0.x as f64, pos2.0.y as f64); rendering.line_to(pos2.0.x as f64, pos2.0.y as f64);
rendering.stroke(); rendering.stroke();
......
use crate::colors;
use crate::components; use crate::components;
use crate::resources; use crate::resources;
...@@ -54,7 +55,7 @@ pub fn draw_nodes( ...@@ -54,7 +55,7 @@ pub fn draw_nodes(
) { ) {
// TODO: Replace by proper API // TODO: Replace by proper API
rendering.begin_path(); rendering.begin_path();
rendering.set_fill_style(&resources::Color::with_rgb(0.63, 0.54, 0.137)); rendering.set_fill_style(&colors::BACKGROUND);
rendering.arc( rendering.arc(
pos.0.x as f64, pos.0.x as f64,
pos.0.y as f64, pos.0.y as f64,
...@@ -66,7 +67,7 @@ pub fn draw_nodes( ...@@ -66,7 +67,7 @@ pub fn draw_nodes(
rendering.begin_path(); rendering.begin_path();
rendering.set_line_width(5.0); rendering.set_line_width(5.0);
rendering.set_stroke_style(&resources::Color::with_rgb(0.254, 0.0, 0.543)); rendering.set_stroke_style(&colors::PRIMARY2_SHADE2);
rendering.arc( rendering.arc(
pos.0.x as f64, pos.0.x as f64,
pos.0.y as f64, pos.0.y as f64,
...@@ -77,7 +78,7 @@ pub fn draw_nodes( ...@@ -77,7 +78,7 @@ pub fn draw_nodes(
rendering.stroke(); rendering.stroke();
let time = clock.wall_time(); let time = clock.wall_time();
let node_color = resources::Color::with_hex_string("#6800e7").unwrap(); let node_color = colors::PRIMARY2_SHADE1;
if let Some(amount_completed) = node.amount_completed(time) { if let Some(amount_completed) = node.amount_completed(time) {
rendering.begin_path(); rendering.begin_path();
rendering.set_stroke_style(&node_color); rendering.set_stroke_style(&node_color);
......
use crate::colors;
use crate::components; use crate::components;
use crate::resources; use crate::resources;
...@@ -12,7 +13,7 @@ pub fn draw_thesun( ...@@ -12,7 +13,7 @@ pub fn draw_thesun(
) { ) {
// TODO: Replace by proper API // TODO: Replace by proper API
rendering.begin_path(); rendering.begin_path();
rendering.set_fill_style(&resources::Color::with_rgb(0.695, 0.223, 1.0)); rendering.set_fill_style(&colors::PRIMARY1_SHADE1);
rendering.arc( rendering.arc(
pos.0.x as f64, pos.0.x as f64,
pos.0.y as f64, pos.0.y as f64,
...@@ -26,7 +27,7 @@ pub fn draw_thesun( ...@@ -26,7 +27,7 @@ pub fn draw_thesun(
rendering.set_line_width(10.0); rendering.set_line_width(10.0);
rendering.begin_path(); rendering.begin_path();
rendering.set_stroke_style(&resources::Color::with_rgb(0.402, 0.008, 0.621)); rendering.set_stroke_style(&colors::PRIMARY1_SHADE2);
rendering.arc( rendering.arc(
pos.0.x as f64, pos.0.x as f64,
pos.0.y as f64, pos.0.y as f64,
...@@ -37,7 +38,7 @@ pub fn draw_thesun( ...@@ -37,7 +38,7 @@ pub fn draw_thesun(
rendering.stroke(); rendering.stroke();
rendering.begin_path(); rendering.begin_path();
rendering.set_stroke_style(&resources::Color::with_rgb(0.266, 0.0, 0.410)); rendering.set_stroke_style(&colors::PRIMARY1_SHADE3);
rendering.arc( rendering.arc(
pos.0.x as f64, pos.0.x as f64,
pos.0.y as f64, pos.0.y as f64,
......
use wasm_bindgen::prelude::*; use wasm_bindgen::prelude::*;
pub mod colliders; pub mod colliders;
pub mod colors;
pub mod components; pub mod components;
pub mod resources; pub mod resources;
pub mod state; pub mod state;
......
use crate::colors;
use crate::components; use crate::components;
use crate::resources; use crate::resources;
use crate::state; use crate::state;
...@@ -97,7 +98,7 @@ impl state::State for HeavenState { ...@@ -97,7 +98,7 @@ impl state::State for HeavenState {
fn update(&mut self) -> state::Transition { fn update(&mut self) -> state::Transition {
{ {
let rendering = self.resources.get_mut::<resources::Rendering>().unwrap(); let rendering = self.resources.get_mut::<resources::Rendering>().unwrap();
rendering.set_fill_style(&resources::Color::with_rgb(0.0625, 0.06, 0.125)); rendering.set_fill_style(&colors::BACKGROUND);
rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0); rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0);
} }
......
use crate::colors;
use crate::resources; use crate::resources;
use crate::state; use crate::state;
use crate::svg_loader; use crate::svg_loader;
...@@ -51,10 +52,10 @@ impl state::State for InGameState { ...@@ -51,10 +52,10 @@ impl state::State for InGameState {
} }
fn deinit(&mut self) { fn deinit(&mut self) {
self.resources.get::<resources::Rendering>() self.resources
.get::<resources::Rendering>()
.unwrap() .unwrap()
.set_transform( .set_transform(1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
1.0, 0.0, 0.0, 1.0, 0.0, 0.0);
self.gui_svg self.gui_svg
.style() .style()
.set_property("display", "none") .set_property("display", "none")
...@@ -64,7 +65,7 @@ impl state::State for InGameState { ...@@ -64,7 +65,7 @@ impl state::State for InGameState {
fn update(&mut self) -> state::Transition { fn update(&mut self) -> state::Transition {
{ {
let rendering = self.resources.get::<resources::Rendering>().unwrap(); let rendering = self.resources.get::<resources::Rendering>().unwrap();
rendering.set_fill_style(&resources::Color::with_hex_string("#100e23").unwrap()); rendering.set_fill_style(&colors::BACKGROUND);
rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0); rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0);
} }
self.schedule.execute(&mut self.world, &mut self.resources); self.schedule.execute(&mut self.world, &mut self.resources);
......
use std::cell; use std::cell;
use std::rc; use std::rc;
use crate::colors;
use crate::components; use crate::components;
use crate::resources; use crate::resources;
use crate::state; use crate::state;
...@@ -57,7 +58,7 @@ impl state::State for LevelLoadingState { ...@@ -57,7 +58,7 @@ impl state::State for LevelLoadingState {
fn update(&mut self) -> state::Transition { fn update(&mut self) -> state::Transition {
{ {
let rendering = self.resources.get_mut::<resources::Rendering>().unwrap(); let rendering = self.resources.get_mut::<resources::Rendering>().unwrap();
rendering.set_fill_style(&resources::Color::with_rgb(0.0625, 0.06, 0.125)); rendering.set_fill_style(&colors::BACKGROUND);
rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0); rendering.fill_rect(0.0, 0.0, 1920.0, 1080.0);
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment