Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Columns UI column - colored recentness (Read 11100 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Columns UI column - colored recentness

Maybe you have last_played column but just can't visualize what's the difference between now and then?
This may be silly to someone, but it's easier to spot color in dozen of items than converting date numbers in head:

Code: [Select]
$puts(range,365)

$if(%last_played%,
$puts(sub_year,$sub(%_system_year%,$year(%last_played%)))
$puts(sub_month,$sub(%_system_month%,$month(%last_played%)))
$puts(sub_day,$sub(%_system_day%,$day_of_month(%last_played%)))

$puts(days,
$ifgreater($get(sub_day),-1,
$ifgreater($get(sub_month),-1,
$add($mul($get(sub_year),365),$mul($get(sub_month),30),$add($get(sub_day),1)),
$add($mul($sub($get(sub_year),1),365),$mul($get(sub_month),30),$add($get(sub_day),1))),
$ifgreater($get(sub_month),-1,
$add($mul($get(sub_year),365),$mul($sub($get(sub_month),1),30),$add(%_system_day%,$sub(31,$day_of_month(%last_played%)))),
$add($mul($sub($get(sub_year),1),365),$mul($add(%_system_month%,$sub(12,$month(%last_played%))),30),$add(%_system_day%,$sub(31,$day_of_month(%last_played%))))))
)

$ifgreater($get(range),$get(days),$puts(cent,$add($muldiv($get(days),100,$get(range)),1) ),)

$puts(Rx,$ifgreater($add($get(cent),33),100,$sub($add($get(cent),33),100),$add($get(cent),33)))
$puts(Bx,$ifgreater(0,$sub($get(cent),33),$add($sub($get(cent),33),100),$sub($get(cent),33)))

$ifgreater($get(cent),0,$rgb(
$ifgreater($get(cent),80,$put(R,195),
$ifgreater(100,$mul(6,$get(Rx)),$put(R,$mul(15,$get(Rx))),
$ifgreater(100,$mul(2,$get(Rx)),$put(R,255),
$ifgreater(200,$mul(3,$get(Rx)),$put(R,$mul(15,$sub(66,$get(Rx)))),
))))
,
$ifgreater(100,$mul(6,$get(cent)),$put(G,$mul(15,$get(cent))),
$ifgreater(100,$mul(2,$get(cent)),$put(G,255),
$ifgreater(200,$mul(3,$get(cent)),$put(G,$mul(15,$sub(66,$get(cent)))),
)))
,
$ifgreater($get(cent),80,$put(B,255),
$ifgreater(100,$mul(6,$get(Bx)),$put(B,$mul(15,$get(Bx))),
$ifgreater(100,$mul(2,$get(Bx)),$put(B,255),
$ifgreater(200,$mul(3,$get(Bx)),$put(B,$mul(15,$sub(66,$get(Bx)))),
))))
,
$get(R),$get(G),$get(B)) ▇ $rgb(),))
What's in the code? - approx. difference in days between now and last_played date, and some HSL conversion to RGB, like in example:



red is closer to date and blue/violet further
"make date info" should be enabled in CUI globals preferences, and optionally $puts(range,365) can be changed to any number of days (it's the range where the code will operate)

[edit] forum convertes (R) to ® - it's corrected now

Columns UI column - colored recentness

Reply #1
Code: [Select]
$puts(range,365)

$if(%last_played%,

$puts(days,
$sub($sub($add($add($mul(%_system_year%,365),$mul(%_system_month%,30)),%_system_day%),730000),
$sub($add($add($mul($year(%last_played%),365),$mul($month(%last_played%),30)),$day_of_month(%last_played%)),730000))
)

$ifgreater($get(range),$get(days),$puts(cent,$add($muldiv($get(days),100,$get(range)),1) ),)

$puts(Rx,$ifgreater($add($get(cent),33),100,$sub($add($get(cent),33),100),$add($get(cent),33)))
$puts(Bx,$ifgreater(0,$sub($get(cent),33),$add($sub($get(cent),33),100),$sub($get(cent),33)))

$ifgreater($get(cent),0,$rgb(
$ifgreater($get(cent),80,$put(R,195),
$ifgreater(100,$mul(6,$get(Rx)),$put(R,$mul(15,$get(Rx))),
$ifgreater(100,$mul(2,$get(Rx)),$put(R,255),
$ifgreater(200,$mul(3,$get(Rx)),$put(R,$mul(15,$sub(66,$get(Rx)))),
))))
,
$ifgreater(100,$mul(6,$get(cent)),$put(G,$mul(15,$get(cent))),
$ifgreater(100,$mul(2,$get(cent)),$put(G,255),
$ifgreater(200,$mul(3,$get(cent)),$put(G,$mul(15,$sub(66,$get(cent)))),
)))
,
$ifgreater($get(cent),80,$put(B,255),
$ifgreater(100,$mul(6,$get(Bx)),$put(B,$mul(15,$get(Bx))),
$ifgreater(100,$mul(2,$get(Bx)),$put(B,255),
$ifgreater(200,$mul(3,$get(Bx)),$put(B,$mul(15,$sub(66,$get(Bx)))),
))))
,
$get(R),$get(G),$get(B)) ▇ $rgb(),))

Changed more sane date difference.  Who knows what was I thinking yesterday

Columns UI column - colored recentness

Reply #2
I'm diggin' this, thank you

Columns UI column - colored recentness

Reply #3
thanks God, someone finds this useful

it's interesting also together in combination with hotness column translated in spectra:


Columns UI column - colored recentness

Reply #4
Nice script,

Thanks.

I have tweaked it to add a "out of range color" and put the color directly to a european short date (day/month/year)



Code: [Select]
$puts(range,365)
$puts(outrangecolor,$rgb(255,255,255,255,255,255))

$if(%last_played%,

$puts(days,
$sub($sub($add($add($mul(%_system_year%,365),$mul(%_system_month%,30)),%_system_day%),730000),
$sub($add($add($mul($year(%last_played%),365),$mul($month(%last_played%),30)),$day_of_month(%last_played%)),730000))
)

$ifgreater($get(range),$get(days),$puts(cent,$add($muldiv($get(days),100,$get(range)),1)),$puts(cent,outrange))

$puts(Rx,$ifgreater($add($get(cent),33),100,$sub($add($get(cent),33),100),$add($get(cent),33)))
$puts(Bx,$ifgreater(0,$sub($get(cent),33),$add($sub($get(cent),33),100),$sub($get(cent),33)))

$if($strcmp($get(cent),outrange),$get(outrangecolor),
$ifgreater($get(cent),0,$rgb(
$ifgreater($get(cent),80,$put(R,195),
$ifgreater(100,$mul(6,$get(Rx)),$put(R,$mul(15,$get(Rx))),
$ifgreater(100,$mul(2,$get(Rx)),$put(R,255),
$ifgreater(200,$mul(3,$get(Rx)),$put(R,$mul(15,$sub(66,$get(Rx)))),
))))
,
$ifgreater(100,$mul(6,$get(cent)),$put(G,$mul(15,$get(cent))),
$ifgreater(100,$mul(2,$get(cent)),$put(G,255),
$ifgreater(200,$mul(3,$get(cent)),$put(G,$mul(15,$sub(66,$get(cent)))),
)))
,
$ifgreater($get(cent),80,$put(B,255),
$ifgreater(100,$mul(6,$get(Bx)),$put(B,$mul(15,$get(Bx))),
$ifgreater(100,$mul(2,$get(Bx)),$put(B,255),
$ifgreater(200,$mul(3,$get(Bx)),$put(B,$mul(15,$sub(66,$get(Bx)))),
))))
,
$get®,$get(G),$get(B)),)))
[$day_of_month(%last_played%)/][$month(%last_played%)/][$right($year(%last_played%),2)]

And Happy new year!

Columns UI column - colored recentness

Reply #5
Nice idea, date available and easily spotable

Right now I merged hotness together with above code in one tiny column -30 px:

[a href="http://img9.imageshack.us/img9/6586/sshot6k.png" target="_blank"]

Columns UI column - colored recentness

Reply #6
Very cool idea 2E7AH! 

I don't use playback statistics yet, but this might change my mind

Columns UI column - colored recentness

Reply #7
Thank you 2E7AH for the inspiration. I used it to colour tracknumbers:


Column tracknumber display script:
Code: [Select]
$puts(range,365)

$if(%last_played%,

$puts(days,
$sub($sub($add($add($mul(%_system_year%,365),$mul(%_system_month%,30)),%_system_day%),730000),
$sub($add($add($mul($year(%last_played%),365),$mul($month(%last_played%),30)),$day_of_month(%last_played%)),730000))
)

$ifgreater($get(range),$get(days),$puts(cent,$add($muldiv($get(days),100,$get(range)),1) ),)

$puts(Rx,$ifgreater($add($get(cent),33),100,$sub($add($get(cent),33),100),$add($get(cent),33)))
$puts(Bx,$ifgreater(0,$sub($get(cent),33),$add($sub($get(cent),33),100),$sub($get(cent),33)))

$ifgreater($get(cent),0,$rgb(
$ifgreater($get(cent),80,$put(R,195),
$ifgreater(100,$mul(6,$get(Rx)),$put(R,$mul(15,$get(Rx))),
$ifgreater(100,$mul(2,$get(Rx)),$put(R,255),
$ifgreater(200,$mul(3,$get(Rx)),$put(R,$mul(15,$sub(66,$get(Rx)))),
))))
,
$ifgreater(100,$mul(6,$get(cent)),$put(G,$mul(15,$get(cent))),
$ifgreater(100,$mul(2,$get(cent)),$put(G,255),
$ifgreater(200,$mul(3,$get(cent)),$put(G,$mul(15,$sub(66,$get(cent)))),
)))
,
$ifgreater($get(cent),80,$put(B,255),
$ifgreater(100,$mul(6,$get(Bx)),$put(B,$mul(15,$get(Bx))),
$ifgreater(100,$mul(2,$get(Bx)),$put(B,255),
$ifgreater(200,$mul(3,$get(Bx)),$put(B,$mul(15,$sub(66,$get(Bx)))),
))))
,
$get®,$get(G),$get(B)),))


$ifgreater(%totaldiscs%,1,
$if(%discnumber%,$replace(%discnumber%,0,₀,1,₁,2,₂,3,₃,4,₄,5,₅,6,₆,7,₇,8,₈,9,₉))
.,)
$if(%tracknumber%,$replace(%tracknumber%,0,₀,1,₁,2,₂,3,₃,4,₄,5,₅,6,₆,7,₇,8,₈,9,₉))

An additional style script for this NG playlist column deals with "out of range" values:
Code: [Select]
$set_style(text,$rgb(180,180,180),$rgb(220,220,220))

Columns UI column - colored recentness

Reply #8
this is an excellent script, thanks.

if only all my tracks had proper data- it got reset at some point for some reason. it doesn't know I have listened to everything at least once! Oh well....

Columns UI column - colored recentness

Reply #9
@ojdo: another interesting usage, no new columns, just reuse of available %tracknumber%

@TomBarlow: I don't understand what you are saying, but I guess color is reseted somewhere?

[edit] I'll post corrected script later

Columns UI column - colored recentness

Reply #10
As I see that ojdo and cerAmik made their workaround for "out of range" here is modified script concerning that:

Code: [Select]
$puts(range,365)
$puts(out_range_color,FFFFFF)
// out_range_color = hex BGR value

$if(%last_played%,

$puts(days,
$sub($sub($add($add($mul(%_system_year%,365),$mul(%_system_month%,30)),%_system_day%),730000),
$sub($add($add($mul($year(%last_played%),365),$mul($month(%last_played%),30)),$day_of_month(%last_played%)),730000))
)

$ifgreater($get(days),$get(range),$get(out_range_color)|$get(out_range_color),

$puts(cent,$muldiv($get(days),100,$get(range)))

$puts(Rx,$ifgreater($add($get(cent),33),100,$sub($add($get(cent),33),100),$add($get(cent),33)))
$puts(Bx,$ifgreater(0,$sub($get(cent),33),$add($sub($get(cent),33),100),$sub($get(cent),33)))

$rgb(
$ifgreater(100,$mul(6,$get(Rx)),$put(R,$mul(15,$get(Rx))),
$ifgreater(100,$mul(2,$get(Rx)),$put(R,255),
$ifgreater(200,$mul(3,$get(Rx)),$put(R,$mul(15,$sub(66,$get(Rx)))),
)))
,
$ifgreater(100,$mul(6,$get(cent)),$put(G,$mul(15,$get(cent))),
$ifgreater(100,$mul(2,$get(cent)),$put(G,255),
$ifgreater(200,$mul(3,$get(cent)),$put(G,$mul(15,$sub(66,$get(cent)))),
)))
,
$ifgreater(100,$mul(6,$get(Bx)),$put(B,$mul(15,$get(Bx))),
$ifgreater(133,$mul(2,$get(Bx)),$put(B,255),
$ifgreater(200,$mul(3,$get(Bx)),$put(B,$mul(15,$sub(66,$get(Bx)))),
)))
,
$get(R),$get(G),$get(B)))∎)
even more, if items without %last_played% needs color last line should be changed to:

Code: [Select]
$get(R),$get(G),$get(B))),$rgb(some_color))∎
so that those without %last_played% tag will have "some_color", out of range their out_range_color, and others their calculated color

Also in this script color is calculated a bit better, because HSL wheel ends gradually from violet to red which is also first color, I hammered by hand (R,195), (B,255) values. More correct and elegant would be shifting blue line above 300 at 255, same as red (it's about HSL conversion link picture in OP) as it's done now + corrected wrong color for limit range value

Columns UI column - colored recentness

Reply #11
what an ignorance
foobar has $hsl() function so here is couple of lines final code:

Code: [Select]
$puts(range,365)
$puts(out_range_color,FFFFFF)
// out_range_color = hex BGR value

$if(%last_played%,
$puts(days,
$sub($sub($add($add($mul(%_system_year%,365),$mul(%_system_month%,30)),%_system_day%),730000),
$sub($add($add($mul($year(%last_played%),365),$mul($month(%last_played%),30)),$day_of_month(%last_played%)),730000))
)
$ifgreater($get(days),$get(range),$get(out_range_color)|$get(out_range_color),
$hsl($put(cent,$muldiv($get(days),200,$get(range))),240,120,$get(cent),240,120)
)∎)

user can change lightness (set to 120 here) to prefered lightness

it's interesting that the HSL to RGB conversion from last code produces same result as above code

Columns UI column - colored recentness

Reply #12
So let's shorten it more. The "$puts(days, ...)" code can be also written without subtracting 730000 twice. (I inserted white space and line breaks for readability):

Code: [Select]
$puts(days,$add(
$mul(365,$sub(%_system_year%,         $year(%last_played%))),
$mul(030,$sub(%_system_month%,       $month(%last_played%))),
$mul(001,$sub(%_system_day%,  $day_of_month(%last_played%)))
))



Edit: added forgotten s in puts

Columns UI column - colored recentness

Reply #13
yeah, 730000 isn't needed at all, I overlooked it
it can be used for showing number of days from the year 2000, but we don't need that

Columns UI column - colored recentness

Reply #14
Nice idea. Thanks.
I use it to color my playcounts.

Columns UI column - colored recentness

Reply #15
Thanks guys. 
Here's my finished output.

Code: [Select]
$puts(range,365)
$puts(out_range_color,BABBBE)

$if(%last_played%,
$puts(days,
$add(
$mul(365,$sub(%_system_year%,$year(%last_played%))),
$mul(030,$sub(%_system_month%,$month(%last_played%))),
$mul(001,$sub(%_system_day%,$day_of_month(%last_played%)))
))
$ifgreater($get(days),$get(range),
$get(out_range_color)|$get(out_range_color),
$hsl($put(cent,$muldiv($get(days),100,$get(range))),240,120,$get(cent),240,120)
)
$char(9616))


Changed HSL value to 100(instead of 200) and used $char(9616) to suit my needs.
Gives blended output of four basic colors(red,yellow,green,gray) which are easy to comprehend at a glance.

Columns UI column - colored recentness

Reply #16
just to suggest that you can go to 120 so that green will end up in icy blue at range limit

Columns UI column - colored recentness

Reply #17
This is a really great idea. Does anyone have any idea how to implement it in EL playlist instead of CUI playlists?

Columns UI column - colored recentness

Reply #18
Thanks 2E7AH. Much better now.

 
SimplePortal 1.0.0 RC1 © 2008-2021