Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect colors from file name #87

Open
unlimitedbacon opened this issue Mar 11, 2024 · 1 comment
Open

Detect colors from file name #87

unlimitedbacon opened this issue Mar 11, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@unlimitedbacon
Copy link
Owner

STL files do not have any way of storing color information, but perhaps we could render files in different colors by detecting strings in the filename. Here are some ideas.

Color Names
red, green, blue, etc.

HTML/Hex Color Codes
#1a2b3c

Voron Naming Scheme
Accent color files are prefixed with [a]. Primary color files have no prefix.

@unlimitedbacon unlimitedbacon added the enhancement New feature or request label Mar 11, 2024
@gyscos
Copy link
Contributor

gyscos commented Sep 13, 2024

Could potentially use a config file to describe a set of rules and the colors to pick in each case. This could totally be a wrapper script around stl-thumb itself (but wouldn't hurt to include it directly there).

For example, a list of regexes and resulting colors - here's a quick mockup:

[[patterns]]
regex = '''\[a\]'''
ambient = "#123456"
diffuse = "#789012"
specular = "#345678"
background = "#901234"

[default]
ambient = "blue"
diffuse = "grey"
specular = "white"

With a config like:

#[derive(Deserialize)]
struct PatternConfig {
    patterns: Vec<Pattern>,
    default: Option<Colors>
}

#[derive(Deserialize)]
struct Pattern {
    regex: String,

    #[serde(flatten)]
    color: Colors,
}

#[derive(Deserialize)]
struct Colors {
    background: Option<String>,
    ambient:  Option<String>,
    diffuse:  Option<String>,
    specular:  Option<String>,
}

Main drawbacks:

  • Most likely needs a crate like config to find the config file regardless of the OS.
  • Need serde to parse the config + some config format (toml? json? yaml?)
  • Need regex

Maybe arbitrary regexes are a bit overkill/too powerful/complex and just checking for the presence of a substring/glob is enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants