0

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

Pete
  • 57,112
  • 28
  • 117
  • 166
  • Did you check this one -> http://stackoverflow.com/questions/23515024/how-i-change-fill-color-of-graphics-in-create-js maybe you shouldnt have an image, you should have a shape and than you should fill the color. – Mihriban Minaz Apr 19 '16 at 10:43
  • Hi, thanks for reply, but I have to load an image, not a geometrical form. – enrico scottini Apr 19 '16 at 12:27

1 Answers1

0

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.

Lanny
  • 11,244
  • 1
  • 22
  • 30
  • Ok thanks, third method works perfectly. But now I have another problem. I have two images that I can move. I color this images, and when these are superimposed I must change the color only in this part. like this http://imgur.com/SoPqxoy – enrico scottini Apr 20 '16 at 12:21
  • Composite operations can do that to a certain extent. Depending on your required effect, this could be quite difficult. I recommend opening another SO question. – Lanny Apr 20 '16 at 15:28