Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Obtain icon as 8-bits / grayscale image? #7

Open
tinchodias opened this issue May 23, 2023 · 4 comments
Open

Obtain icon as 8-bits / grayscale image? #7

tinchodias opened this issue May 23, 2023 · 4 comments

Comments

@tinchodias
Copy link

Hi @labordep is there some way in the icons database or in this project, to get the icons directly in grayscale format?

@labordep
Copy link
Member

Hi @tinchodias you can get Ant Design icons, icons are in black color format by default (loaded from SVG files).

You need to download locally the ant design icon project (this is explains in the documentation but maybe not very clear, we need feedbacks ;-) ) and after you can use it with :

self antIconNamed: #search

@labordep
Copy link
Member

We are working on a capacity to dynamically download icon from an internet repository but this is not yet priority (we are working offline).

@tinchodias
Copy link
Author

Yes I did read the README and downloaded the ant icon set to the local directory where the default setting expects it.
So, no complaints on the doc! We can close the issue.

When I asked I was a bit confused creating this demo, and finally it worked without that:
Screenshot 2023-05-23 at 18 36 34

Code:

inputForm := self antIconNamed: #checkCircle.
inputSurface := AeCairoImageSurface fromForm: inputForm.

outputColors := Color wheel: 7.

"Create a surface and associated context"
outputSurface := AeCairoImageSurface
    extent: (inputSurface width * outputColors size) @ inputSurface height
    format: AeCairoSurfaceFormat argb32.
outputContext := outputSurface newContext.

"Paint the inputSurface with each color"
outputColors
    do: [ :eachColor |
        outputContext
            sourceColorRGBA: eachColor;
            maskSurface: inputSurface x: 0 y: 0 ]
    separatedBy: [
        outputContext
            translateByX: inputSurface width
            y: 0 ].

outputSurface asForm inspect

@tinchodias
Copy link
Author

(Snippet uses Alexandrie: https://github.com/pharo-graphics/Alexandrie)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants