Giter Club home page Giter Club logo

Comments (8)

SludgePhD avatar SludgePhD commented on September 27, 2024

There are some other alternatives:

  • The palette modules could be added to the prelude, so you could write css::RED in any module that imports bevy::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.

Zeenobit avatar Zeenobit commented on September 27, 2024
  • In my opinion, css and basic 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.

alice-i-cecile avatar alice-i-cecile commented on September 27, 2024

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.

Zeenobit avatar Zeenobit commented on September 27, 2024

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.

alice-i-cecile avatar alice-i-cecile commented on September 27, 2024

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.

Zeenobit avatar Zeenobit commented on September 27, 2024
#[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.

ItsDoot avatar ItsDoot commented on September 27, 2024

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.

alice-i-cecile avatar alice-i-cecile commented on September 27, 2024

Or cfg flag the glob import. Closing this out: I don't think this is worth the complexity <3

from bevy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.