Le 28 nov. 06 à 21:09, Yen-Ju Chen a écrit :

On 11/28/06, Quentin Mathé <[EMAIL PROTECTED]> wrote:
Le 28 nov. 06 à 08:57, Yen-Ju Chen a écrit :

> I am looking for a way to draw number of unread articles from
> RSSReader in the application icon.
> Does IconKit support something like that ?

Yes, IconKit includes a compositor. Take a look at IKCompositor and
IKCompositorOperation classes, they are in a usable state.
I plan to commit later today an IconKit example that demonstrates
icon compositing and  other features.
But I'm going to fix first headers support (broken right now if you
want to use the library).

It allows you to draw an image on top of another.
Is it possible to draw text on top of icon ?
Otherwise, I have to prepare images from 1-100 in order to display the
proper number. :)

You can write a method that takes a number as a parameter, then creates an attributed string and draws it in an image to be returned. With the returned image, you can pass its size to another method that creates a properly sized background with NSBezierPath and draws it in an image to be returned. The background of these images has to be transparent (it is the case by default). Finally you pass each resulting image to IKCompositor, by using some code similar to the following one:

compositor = [[IKCompositor alloc] initWithImage: targetIconImage]

[compositor compositeImage: backgroundImage withPosition: IKCompositedImagePositionBottomRight] // first layer [compositor compositeImage: textImage withPosition: IKCompositedImagePositionBottomRight] // second layer
finalIconImage = [compositor render]

That's it :)

Quentin.

--
Quentin Mathé
[EMAIL PROTECTED]


_______________________________________________
Etoile-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/etoile-discuss

Répondre à