Automatic generation of tag color

Bug #644993 reported by Izidor Matušov on 2010-09-22
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Getting Things GNOME!
Wishlist
Atit Anand

Bug Description

I love using the tag color feature. It makes GTG nicer and more useful. However, I have problem with choosing colors for tags. In the end, I use almost same colors for each tag. I would like to have a following feature in GTG:

1, I do a right click on tag and choose command generate color
2, Generate a color for the tag:
  - take colors of the current tag set
  - find the biggest "gap" between colors
  - random choose a color from the gap
3, set the color

I'm not an expert of graphics therefore my algorithm is a quite vivid.

On Wed, Sep 22, 2010 at 08:24:12AM -0000, Izidor Matušov wrote:
> Public bug reported:
>
> I love using the tag color feature. It makes GTG nicer and more useful.
> However, I have problem with choosing colors for tags. In the end, I use
> almost same colors for each tag. I would like to have a following
> feature in GTG:
>
> 1, I do a right click on tag and choose command generate color
> 2, Generate a color for the tag:
> - take colors of the current tag set
> - find the biggest "gap" between colors
> - random choose a color from the gap
> 3, set the color
>

An alternative approach (maybe there's a bug on this already?) would be
to ship a pre-defined color palette and when the user goes to select a
color for the tag, present them with the next color from the subset of
unused colors from the palette.

A nice effect of this is that we can provide a set of colors that look
good (e.g. avoiding dark colors, or shades that will be
indistinguishable).

The palette should be loadable. This would permit users who don't like
our choice of colors to select another. E.g., one palette could provide
vibrant primary colors, another one focuses on more subtle pastels, etc.
This also would permit distros to provide a palette that fits with their
distro default color scheme if they desire.

The one problem I had with this idea was that a palette would have a
finite set of colors. However, using Izidor's idea might solve that -
once # tags > # colors-in-palette, generate new colors by selecting ones
in between.

Bryce Harrington (bryce) wrote :

Here's another idea along these lines:

When a tag is a sub-tag of another tag that has a color set for it,
provide the user with a selection of unused shades of the parent color
to use.

In fact, this is how I set up my own color system manually. I pick
shades of blue for different x.org packages I work on, shades of yellow
for projects related to my work on launchpad, shades of grey for
household chores, etc.

Izidor Matušov (izidor) wrote :

I've played a little bit with this idea and it's implementation. There is no known algorithm which is able to generate different colors (without a predefined list of colors). [Source: http://stackoverflow.com/questions/2328339/how-to-generate-n-different-colors-for-any-natural-number-n ].

I've tried to think my own algorithm but it is not so much more efficient against the simple random generation of color. I make a small GUI tool for playing - http://gist.github.com/643865 (It read your current tag set from ~/.local/share/gtg/tags.xml, show colors and allow you to generate a new ones). I have just a while for playing with this, therefore I implement the random generator.

The attached patch is for current stable code 0.2.4, so you can enjoy this little feature already :-)

Izidor Matušov (izidor) on 2011-04-07
Changed in gtg:
assignee: nobody → Izidor Matušov (izidor)
Izidor Matušov (izidor) wrote :

I did another search for maybe suitable algortihms and these pages pop out of google:

http://stackoverflow.com/questions/2328339/how-to-generate-n-different-colors-for-any-natural-number-n

http://en.wikipedia.org/wiki/Color_difference

http://stackoverflow.com/questions/2103368/color-logic-algorithm

http://epub.wu.ac.at/1692/

It really does not seen to be easy to create generate distinguish color on the fly. I think usage of predefined list of colors could be better solution. The good thing about it is possiblity to define your own "color scheme" as Bryce told

Lionel Dricot (ploum) on 2011-08-07
Changed in gtg:
milestone: none → 0.3
status: New → Confirmed
importance: Undecided → Wishlist
Izidor Matušov (izidor) on 2011-11-28
Changed in gtg:
assignee: Izidor Matušov (izidor) → nobody
Izidor Matušov (izidor) on 2012-02-13
Changed in gtg:
milestone: 0.3 → 0.3.2
Izidor Matušov (izidor) on 2012-07-18
Changed in gtg:
milestone: 0.3.2 → 0.4
Izidor Matušov (izidor) wrote :

I stumpled upon an interesting article: http://99designs.com/tech-blog/blog/2012/05/11/color-analysis/

Heuristic could be:
  * generate N colors
     (you can inspire yourself at http://www.kareno.org/js/colors/ )
  * choose the color which is the most different from other colors

tags: added: love
Changed in gtg:
assignee: nobody → Atit Anand (atit-anand-cs)
Atit Anand (atit-anand-cs) wrote :

Izidor >
 I have tried generating random colors using HSV color model.I have played a little with the "generate_tag_color()" from your patch.Evenly sperated random colors are generated with similar brightness using this code: http://paste.ubuntu.com/6958863/

Nimit Shah (nimit-svnit) wrote :

Atit,
Good that you have generated random colors, now how are you planning to work on this issue? I mean in terms of User Experience.

Atit Anand (atit-anand-cs) wrote :

Nimit>

In terms of User Experience I have thought this:

1.Right click on tag----->choose " generate color"

2.gtg will generate N random colors.
            ---gtg will select any color from the randonmly generated set.
           ---To increase the randomness,gtg will check if selected color matches any of the recently 5 used tag color.
           ---If yes:goto step 2

3.set the color.

note:background,brightness of the generated color can be controlled using h,s,v attributes of "generate_tag_color()"

Atit Anand (atit-anand-cs) wrote :

Nimit>

This is the implementation of above idea.

Parin Porecha (parinporecha) wrote :

Atit >

I skimmed through the patch and it looks good (But, I haven't tested it yet).

some nitpicks -
- remove variable self.mi_cc1, use different name or use self.mi_cc instead. Names like this cause maintenance problems in the long run.
- Don't import all the functions into the namespace like this - from GTG.gtk.colors import *. Import only the function you need, or import the whole file like - from GTG.gtk import colors, or something like that
- Remove your comments from the code.
- Your editor is setting wrong indentation. Lines like these -

-
+

should not be in a patch

Atit Anand (atit-anand-cs) wrote :

Parin>

Thanks for looking into the patch.I have modified my code according to the stuffs you told.

Nimit had told to me to create a branch and share it,so here's the link : lp:~atit-anand-cs/gtg/randomize_tag_color

Nimit Shah (nimit-svnit) wrote :

Hi Atit,
The algorithm seems to generate a fixed set of colors everytime. It cycles from green,pink,blue,orange a few shades of them.

Atit Anand (atit-anand-cs) wrote :

Heya Nimit,

I have modified the code(updated the branch),it now generates set of different random colors rather just few random colors.

while using any random function, values repeats sometime.That is why my function generates same color sometimes.

Nimit Shah (nimit-svnit) on 2014-02-23
Changed in gtg:
status: Confirmed → In Progress
Nimit Shah (nimit-svnit) wrote :

Fixed in rev 1356

Changed in gtg:
status: In Progress → Fix Committed
milestone: 0.4 → 0.3.2
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers