Comments (8)
There are some other alternatives:
- The palette modules could be added to the prelude, so you could write
css::RED
in any module that importsbevy::prelude::*
- Bevy methods that accept concrete color types can be changed to instead take any
impl Into<Color>
- If I understood the proposed design correctly, BSN will perform automatic conversion via
From
/Into
for field values, so waiting for BSN to be implemented would also be a viable alternative
from bevy.
- In my opinion,
css
andbasic
are too generic to be in the prelude, considering they specifically apply to color presets. - That would require passing colors through functions that accept
Into<Color>
. You're correct in that this would be solved with BSN, but... - Sometimes, especially in debug contexts, we want to use colors outside the
Bundle
/Component
paradigm. See here for an example.
from bevy.
Definitely strongly opposed to adding the palettes to the prelude :) I think BSN will help a lot here, but I can see why it may not be a full fix.
from bevy.
Alternatively, maybe we can just get rid of palettes
.
I don't think basic
/css
/tailwind
are too generic inside the bevy::color
scope.
So then the presets would be shortened too:
let color = bevy::color::css:RED.into()
That + BSN may be a good enough compromise to solve this issue with minimal cost for standard Bevy.
I would argue maybe we even push the basic
palette up to bevy::color
(via pub use basic::*
). So then bevy::color::RED
is just bevy::color::basic::RED
.
I could then see color!
being implemented as a third party crate, if needed.
from bevy.
I don't understand why use bevy::color::palletes::css;
or use bevy::color::palletes::css::*
isn't an acceptable solution. This is clear, terse and requires only a small amount of setup.
from bevy.
#[cfg(feature = "debug")]
{
painter.color = bevy::color::palettes::css::LIMEGREEN.into();
painter.line(p0, p1);
painter.color = bevy::color::palettes::basic::RED.into();
painter.line(p1, p2);
painter.color = bevy::color::palettes::tailwind::INDIGO_100.into();
painter.line(p2, p3);
}
vs.
#[cfg(feature = "debug")]
{
painter.color = color!(css::LIMEGREEN);
painter.line(p0, p1);
painter.color = color!(RED);
painter.line(p1, p2);
painter.color = color!(tailwind::INDIGO_100);
painter.line(p2, p3);
}
Multiplied by the number of occurrences in a codebase. 10? 100? 1000?
I don't want to expose bevy::color::palettes::css::*
or bevy::color::palettes::css
to my entire codebase just to support my debug draw code.
from bevy.
This should work FWIW:
#[cfg(feature = "debug")]
{
use bevy::color::palettes::{css, basic::*, tailwind};
painter.color = css::LIMEGREEN.into();
painter.line(p0, p1);
painter.color = RED.into();
painter.line(p1, p2);
painter.color = tailwind::INDIGO_100.into();
painter.line(p2, p3);
}
from bevy.
Or cfg flag the glob import. Closing this out: I don't think this is worth the complexity <3
from bevy.
Related Issues (20)
- Subassets of subassets do not work. HOT 1
- `cargo run -p ci` doesn't handle doc tests properly
- action.yml is not valid (schema)
- Render/Light layers data in shader example
- UI Grid Placement Styles should hold the calculated values during runtime. HOT 2
- Panic when using spawn command within Trigger<OnRemove> observer HOT 1
- move `BorderRect` into `bevy_math` HOT 2
- Add a safe, typed equivalent to `EntityWorldMut::insert_by_ids` HOT 1
- Make the use case for configuring `TimeUpdateStrategy` and `Time<Real>` more clear
- Consider removing `Return::Unit` HOT 1
- Add `init_resource_with_descriptor`
- CI should check for properly formatted wgsl HOT 2
- Rename `UiPickingBackend` to `UiPickingBackendPlugin` HOT 2
- Rename `init_component` and `init_component_with_desciptor`
- The underlying API or device in use does not support enough features to be a fully compliant implementation of WebGPU. HOT 2
- Allow registering components/resources from `ReflectComponent/Resource`
- Allow use of systems for custom time handling HOT 1
- use more levels of spans than always info
- Follow up on Retained Rendering HOT 3
- Tracking Issue: MVP `no_std` Bevy HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bevy.