Converting color

About Monkey 2 Forums Monkey 2 Programming Help Converting color

This topic contains 9 replies, has 5 voices, and was last updated by  dominique95 10 months, 1 week ago.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
  • #13955


    So I’m totally stuck after few days think about this problem. It’s a really tough problem.
    How would you convert the color from RGBA Uint into a “color” datatype?




    But how to set the colour to full or no alpha rrggbbaa so you can ERASE “color” an OVAL?
    I just don’t understand how alpha is put in color, how to erase? is there a MODE for that?



    Is it kosher to use canvas.BlendMode = BlendMode.Opaque to set the absolute value of R G B *and Alpha* of a pixel?



    Yeah, the alpha is just a color channel, like red, green or blue.
    You can set is as part of the color, or separately using “canvas.Alpha = myAlpha”.

    Also remember that in openGL colors can have values higher than 1.0 – that’s HDR! Setting colors like that is essential to things like Glow shaders. It’s probably a good practice to not use UINT values of 0 to 255 unless you need to, and embrace colors as floating point values.


    Will output three overlapping squares with transparency, like this:



    And if by “Erase” color you mean to make a color in an image transparent… that’s really not necessary anymore, simply export images as PNG files with transparency.

    If you already have old images you’d like to use and you don’t want to change them using a graphics app… I guess you can make a monkey module that loads an image as a pixmap, specifies a color to be made transparent, finds all pixels in the pixmap that match that color and sets the color in those pixels to transparent and creates a new image from that pixmap…

    …or you can just save the images as PNG with transparency! 😉



    Wow, big thanks, good to know !
    But what happens if you wants to change only the alpha but you want to keep the rest intact? Do you have to make it pixel by pixel or is a way to change alpha channel alone?



    Just give the canavas some drawing color and the whole image will be drawn with that modified color.Note that you are supposed to use premultiplied alphas in mx2 (I think, not really sure of when to deal with premultiplied alphas).

    or directly on the Image



    When you draw to canvas, you blend pixels with existing ones.

    The question is how to erase pixels in canvas.

    It’s actual to make transparent HUD for AR-glasses stuff, when you need to make drawing area actually transparent to see through it.

    I remember there was a similar topic but don’t remember the answer – is it possible or is it in TODO.



    For creating Hud , I start with erased image, canvas.Clear(Color.None) and draw with BlendMode.Alpha
    and adjust the Alpha component of the drawing color.
    In the main loop , I draw this image on the screen. But it’s always the same.

    Try this , using A, D, M, O,  and Up/Down Keys.
    See the Color’s info under the mouse, blendmode will make sense.
    Transparency is where you see the red balls.
    Coded with Monkey2 1.1.06

Viewing 10 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic.