On 04 Nov 2014, at 19:41, Alex Kac <a...@webis.net> wrote:
> I have an NSImage that looks like  in a mini-toolbar - kind of like Xcode. 
> 
> Now of course I can just create a hand-drawn selected version, but I like 
> doing things like that in code. So I’d like to have code that takes the 
> NSImage and makes it glow like Xcode here:
> https://www.dropbox.com/s/by642iw7xosnki7/Screenshot%202014-11-04%2011.40.18.png?dl=0

 OK, so that’s not actually a glow, you’re just trying to tint an image in a 
different color, it seems? I presume your image is a flat 2D glyph like Xcode’s 
as well?

 You will want to look into the compositing modes that Quartz supports (or 
rather, NSImage in its drawing calls). I’ve done this a couple of times. There 
is one of these modes, but I forget which … maybe SourceIn? DestinationIn? One 
of those, that essentially uses the alpha from your NSImage to obliterate the 
alpha of the destination image you’re drawing on top. So what you do is create 
an NSImage, lockFocus, fill it with the desired color, then SourceIn or 
whatever the actual image.

 Alternatively, if you have an NSButton, you can use a PDF image and use 
NSImage’s template image mechanism (I think you just name it 
xxxTemplateImage.pdf) and then one of NSButton's highlighting styles will 
recognize it’s a template image and fill and bezel it. This depends on what 
style of button you’re using, too, though, so may be rather limiting.

Cheers,
-- Uli Kusterer
“The Witnesses of TeachText are everywhere...”
http://zathras.de


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to