enrico scottini
enrico scottini

Reputation: 21

CreateJS: how to change color of bitmap image

I'm using createJS to build some easy game.

I have an image (white fill and black stroke) and I would change the black color to another.

Is it possible?

Thanks

Upvotes: 0

Views: 3153

Answers (1)

Lanny
Lanny

Reputation: 11294

The three ways to do color adjustments in EaselJS are:

  1. Composite Operations: You can draw an image using a composite operation (such as "destination-in") to determine how pixels are laid down. This is probably not going to give you the result you want. Here is an example of a black PNG being changed to different colors using compositeOperation.

  2. Color Filters. EaselJS has both a ColorFilter and a ColorMatrixFilter, which assist with modifying colors. The first uses parameters to multiply and add to the color and alpha channels, but is a little harder to use. The second uses a ColorMatrix to adjust hue, saturation, contrast, and brightness. This may not work for you, since changing the black pixels is kind of the opposite of color filters do.

  3. A Custom Filter. EaselJS supports custom filters (such as the Threshold Filter in the extras folder. This is probably your best option, and might take massaging to get what you need.

Hope that sheds some light.

Upvotes: 0

Related Questions