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

Support for automatic theme generation from wallpaper #27

Closed
avanisubbiah opened this issue Jul 28, 2022 · 32 comments · Fixed by #95
Closed

Support for automatic theme generation from wallpaper #27

avanisubbiah opened this issue Jul 28, 2022 · 32 comments · Fixed by #95
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@avanisubbiah
Copy link

I created a script here that creates a preset.json file with color definitions from any provided image (Created using material-color-utilities).

I was wondering if it would be possible to integrate this functionality into AdwCustomizer as a section in the themes drop down to allow the user to select an automatically generated light or dark theme using their wallpaper. I don't know if it will be entirely possible because I had to write the script in JavaScript because material-color-utils doesn't currently have a Python library yet.

@daudix
Copy link
Member

daudix commented Jul 28, 2022

I have done Mockup for this in #25, I really want it too.

@avanisubbiah
Copy link
Author

I published an npm package for the script here so the script could be integrated by having main.py checking if the npm package has been installed, if not run npm install -g adwaita-materialu, and then run gen-materialu-theme -i <Path to image file> -t <Theme type (dark|light)> to create the auto generated presets.

However, I am not sure if a flatpak can install an npm package within itself.

@daudix
Copy link
Member

daudix commented Jul 28, 2022

I am not a developer (for now), but i think we can add this script directly in the project, or like with blueprint-compiler, pull it from git repo

@ArtyIF
Copy link
Contributor

ArtyIF commented Jul 28, 2022

I'll probably do it one day. I think it'll be better to rewrite the program so it was more oomox-like for easier integration of new features.

@avanisubbiah
Copy link
Author

I am not a developer (for now), but i think we can add this script directly in the project, or like with blueprint-compiler, pull it from git repo

I looked into some solutions, but there really isn't any good way to get around the dependency of requiring all of NodeJS installed to run the script because the material-color-utilities JavaScript package is only usable with ES6 and pkg only compiles JavaScript packages that use ES5 and below. Some other options like ncc and caxa package it into a single file but still require Node to be installed locally on the system to run it. This is a bit of a problem for it to be usable in flatpak because there isn't a flatpak distribution of NodeJS available, so the user would have to manually install that through their package manager.

I'm currently working on porting material-color-utilities to Python in this repo so this script can be run without Node.

@daudix
Copy link
Member

daudix commented Jul 29, 2022

Good luck!

@ArtyIF ArtyIF added the enhancement New feature or request label Jul 29, 2022
@avanisubbiah
Copy link
Author

Good luck!

Progress went very well. I have ported the whole material-color-utilities library to Python (available here).

It should be very easy now to integrate this into the project. The only dependency it uses is pillow because I could not find any other obvious way to iterate through pixels in an image and convert formats without it. Also there is some usage examples of how to generate themes or source colors from images on the repo README.

@daudix
Copy link
Member

daudix commented Jul 29, 2022

This is just amazing!

@0xMRTT
Copy link
Member

0xMRTT commented Aug 10, 2022

Hi @avanishsubbiah.

Do you want to add this repo to the org, it will be more easy to integrate your amazing tool with Adwaita Manager.

@0xMRTT 0xMRTT pinned this issue Aug 10, 2022
@avanisubbiah
Copy link
Author

Hi @avanishsubbiah.

Do you want to add this repo to the org, it will be more easy to integrate your amazing tool with Adwaita Manager.

Hello, I'm currently working on updating the code to follow Google's Python guidelines so it can be added into the material-color-utilities repo (pr here). The current code works just fine, it just needs some variables renamed so feel free to fork and use it.

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

Thanks 👍🙏. I'll include ur generator in the UI redisgn

@0xMRTT 0xMRTT self-assigned this Aug 11, 2022
@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

I'm working on.

@daudix-UFO: I need to add a combobox for selecting the tone. If the tone is low, the color will be darker, if the tone is high, the color will be lighter
Screenshot from 2022-08-11 12-34-52
image

@daudix
Copy link
Member

daudix commented Aug 11, 2022

OK, looks nice! But can you add radio buttons (circles that becomes blue when selected)?

@daudix
Copy link
Member

daudix commented Aug 11, 2022

Or segmented slider

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

I generated palette from this background :

background_test_monet

With tone = 1:
Screenshot from 2022-08-11 14-36-36
With tone=50:
Screenshot from 2022-08-11 14-37-02
With tone=95
Screenshot from 2022-08-11 14-37-25

I think that i will remove very low tone because it's bad

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

OK, looks nice! But can you add radio buttons (circles that becomes blue when selected)?

Where should i add radio buttons ??

@0xMRTT 0xMRTT linked a pull request Aug 11, 2022 that will close this issue
@daudix
Copy link
Member

daudix commented Aug 11, 2022

OK, looks nice! But can you add radio buttons (circles that becomes blue when selected)?

Where should i add radio buttons ??

Nevermind, just checked, you maked it correctly

@daudix
Copy link
Member

daudix commented Aug 11, 2022

I think tones works pretty good, but first one is too dark

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

Yes, i am removing tone 1. I need to try all others tone to determine which one is better and set this one as default

@avanisubbiah
Copy link
Author

I generated palette from this background :

background_test_monet

With tone = 1: Screenshot from 2022-08-11 14-36-36 With tone=50: Screenshot from 2022-08-11 14-37-02 With tone=95 Screenshot from 2022-08-11 14-37-25

I think that i will remove very low tone because it's bad

There is some extra processing used beyond the palette to make a cohesive scheme with Material You. I recommend picking tokens from here: https://m3.material.io/styles/color/the-color-system/tokens, and there might be a way to have it brighten the tone of the generated tokens for tone selection.

As an example here are some token to adwaita mappings.

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

@daudix-UFO I also need to add another combo box to select if the theme will be light or dark

@daudix
Copy link
Member

daudix commented Aug 11, 2022

@daudix-UFO I also need to add another combo box to select if the theme will be light or dark

I think we need to make automatic, see #12

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

Yes, but we can also let user choice

Adwaita Manager can automaticly select dark or light following user preferences and the user can change it if he want

@daudix
Copy link
Member

daudix commented Aug 11, 2022

Yes, but we can also let user choice

Also correct!

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

It's working

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

Also added automatic choice

@0xMRTT 0xMRTT added this to the 0.1.0 milestone Aug 11, 2022
@daudix
Copy link
Member

daudix commented Aug 11, 2022

Also, maybe wiered question, but any idea why there is a huge difference in performance between material you GNOME extension and in-app generator?

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

Material you is written in JavaScript with the original library by google. Adwaita Manager use a port in python. Just created 14 days ago

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

It's a goal for the next release

@avanisubbiah
Copy link
Author

Also, maybe wiered question, but any idea why there is a huge difference in performance between material you GNOME extension and in-app generator?

By default the extension resizes the wallpaper to 64x64 before processing it because it barely makes any visible difference to the colors picked. Also the Python port I made is slower than the JavaScript version of the material-color-utilities library. Either of these or both could contribute to performance differences.

@daudix
Copy link
Member

daudix commented Aug 11, 2022

Thank you for detailed explanation!

@0xMRTT
Copy link
Member

0xMRTT commented Aug 11, 2022

#108 will improve performance

@GradienceBot GradienceBot unpinned this issue Aug 12, 2022
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
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants