Cacti (home)ForumsRepositoryDocumentation
Cacti: offical forums and support  

 FAQFAQ   SearchSearch   MemberlistMemberlist    RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    


[PATCH] Feature: Color overlay on icons.

 
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map)
Author Message
llow
Cacti User


Joined: 05 Oct 2007
Posts: 88

PostPosted: Sat Dec 15, 2007 4:34 pm    Post subject: [PATCH] Feature: Color overlay on icons. Reply with quote

Icon color overlaying to work with scales, etc.

Adding something like
imagefilter($icon_im, IMG_FILTER_COLORIZE, $col->r, $col->g, $col->b);
during icon generation.

I'll write up a better patch, just playing with it right now.
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2167
Location: United Kingdom

PostPosted: Sat Dec 15, 2007 5:12 pm    Post subject: Reply with quote

Hadn't noticed that function before. Neat.

Unfortunately, it won't work for ubuntu/debian users (debian doesn't use the bundled gd), or for php 4, or earlier php 5

Since the function would just not be present it's easy enough to add a warning during the ReadConfig if the colorisation option was used on a system that can't do it though.
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Sat Dec 15, 2007 6:54 pm    Post subject: Reply with quote

That would definitely be a feature I'd use.

Let me know if you need it tested.
Back to top
llow
Cacti User


Joined: 05 Oct 2007
Posts: 88

PostPosted: Sat Dec 15, 2007 7:08 pm    Post subject: Reply with quote

New option USEICONSCALE?
Back to top
llow
Cacti User


Joined: 05 Oct 2007
Posts: 88

PostPosted: Sun Dec 16, 2007 1:41 am    Post subject: Reply with quote

Here is a patch, adds USEICONSCALE option to NODES. Defaults to none and works the same as USESCALE.

Code could probably be worked around to allow scales against any of the node features (text color, shadow color, etc). Didn't think this was important enough to code for now though.

I didn't place any checks in to make sure the function exists but by default if USEICONSCALE is not used it is not called anyways.

Patch will apply against 0.941 with some offsets due to other patches.



weathermap-useiconscale.patch
 Description:

Download
 Filename:  weathermap-useiconscale.patch
 Filesize:  2.17 KB
 Downloaded:  85 Time(s)

Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Sun Dec 16, 2007 10:13 am    Post subject: Reply with quote

For those of us that don't work with Linux every day, can you post the command to apply the patch?
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2167
Location: United Kingdom

PostPosted: Sun Dec 16, 2007 10:52 am    Post subject: Reply with quote

Thanks llow! A modified version of this patch is now in svn. I've added WriteConfig (so that the editor won't trash it), some function_exists() (so that it won't die on unsupported systems), and re-arranged the ReadConfig() so that it's easier to add more of these USE*SCALE keywords.
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Sun Dec 16, 2007 11:12 am    Post subject: Reply with quote

Ok, I just updated to the latest SVN and now all the colors on my scales are much darker than they were before. Any ideas why?

The new scale works well, except this is what it's doing to me. I've removed my USESCALE off of my text labels but for some reason they're appearing with purple backgrounds. Plus my Links color scale is appearing darker than it should.



WM_Overlay.gif
 Description:
 Filesize:  25.91 KB
 Viewed:  1401 Time(s)

WM_Overlay.gif


Back to top
llow
Cacti User


Joined: 05 Oct 2007
Posts: 88

PostPosted: Sun Dec 16, 2007 3:48 pm    Post subject: Reply with quote

You need to set your USESCALE to none otherwise it will use DEFAULT.

The overlay will probably require using darker colors to get the proper effect you want as well.
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2167
Location: United Kingdom

PostPosted: Sun Dec 16, 2007 4:24 pm    Post subject: Reply with quote

The purple labels is just because you let the nodes back to the default scale (which is DEFAULT), where purple is the lowest band.

I'm getting some odd murky colours in one of my maps, on one of my test machines (but not the other) which I can't currently explain though. Then again, I'm getting this with the new iconscale code commented out too, so it's possible that there is something else broken in the svn version

The other change in svn since 0.941 is also to do with scale handling, so that's entirely possible. It's something else that helps with some of the same problems - it allows you to assign a piece of text to each scale item too, for use as (e.g.) an icon filename. I'll carry on fiddling.
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2167
Location: United Kingdom

PostPosted: Sun Dec 16, 2007 5:22 pm    Post subject: Reply with quote

OK. That was a bug introduced by the other scale-tag feature, so that it would always treat a SCALE line as the two colour version, and if the second colour wasn't specified it was 0 0 0, so you got a gradient from your real colour to black, hence the darkening. Fixed now.
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Sun Dec 16, 2007 6:02 pm    Post subject: Reply with quote

Ok, got the latest SVN and it seems to be working correct now. I added a USESCALE none in the NODE DEFAULT section of the config file so my text is just black and the icons are colored.
Back to top
streaker69
Cacti Pro User


Joined: 27 Mar 2006
Posts: 647
Location: Psychic Amish Network Administrator

PostPosted: Mon Dec 17, 2007 7:55 am    Post subject: Reply with quote

I'd like to offer a suggestion if I may.

This is a really cool patch, colorizing the entire image in some cases looks bad. I think things could be improved some if maybe the Contrast and Brightness could be added in? If not as a adjustable option directly in the editor but maybe as an option in the config file itself?

Code:

 <?php
  $image = imagecreatefrompng("space.png");
  imagefilter($image, IMG_FILTER_CONTRAST, 20);
  header("content-type: image/png");
  imagepng($image);
  imagedestroy($image);
?>


Code:

 <?php
  $image = imagecreatefrompng("space.png");
  imagefilter($image, IMG_FILTER_BRIGHTNESS, 50);
  header("content-type: image/png");
  imagepng($image);
  imagedestroy($image);
?>


I'd write it myself, but unfortunately, I don't know how to implement it into the existing code. But it's just a thought.
Back to top
Howie
Cacti Guru User


Joined: 16 Sep 2004
Posts: 2167
Location: United Kingdom

PostPosted: Mon Dec 17, 2007 8:03 am    Post subject: Reply with quote

It would need to be per-node (or rather per-icon), I guess. Maybe even per-colour/SCALE but that would be really awkward. How about a couple of per-NODE SET variables?
Code:

   SET iconcol_contrast 20
   SET iconcol_brightness 50


The problem is that the "correct" values would depend very much on what colours you use in your scale, and what colour the icon was to start with. I tested using the monochrome cisco icons, and they worked fine as long as I used darkish colours instead of 'pure' 255 colours.
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Cacti Forum Index -> Plugin: (Network Weather Map) All times are GMT - 5 Hours
Page 1 of 1

 



Powered by phpBB © 2001, 2005 phpBB Group