change background with gray colors, it's possible?

Started by katie08cd, Fri 31/01/2020 23:19:33

Previous topic - Next topic

katie08cd

hello everyone, sorry and can I change the background with gray colors? I'm trying to create a vignette effect, only if I create the full screen gui after the character does not move, then I created 2 gui on the sides with a vignette effect, but I would like to create a background effect on the gray, and then put the hidden objects yellow, which will then become visible in that mode, I hope it is a tint type command or similar, thanks

Cassiebsg

Hi

If you're talking about the default gray GUI's background it's not possible to change themm. Make your own GUIs is the solution.

If you're talking about adding tint to BGs, characters and or objects then yes, you can.
Open the manual and type tint in the search box to find all the possible ways to tint.
There are those who believe that life here began out there...

Snarky

I think katie08cd is talking about turning down the saturation of the colors, so that everything becomes grayscale, except for the items that are to be highlighted.

There's no built-in function that lets you do this.

(Edit: Unless Tint() actually does? I've never been able to really understand how that function works. It never seems to do what I expect it to.)

If not, you would have to code it more or less from scratch. It can be done, but it will be very slow: AGS will have to draw the grayscale picture pixel by pixel, and particularly in high resolutions that could be prohibitive. And because AGS only gives you 16-bit control of color you would also lose quality.

But basically, what you would have to do would be:

-Use DynamicSprite.CreateFromScreenShot() to capture the screen (in color), and get its DrawingSurface
-Loop through every pixel of the image, doing:
  -Read the value of the pixel using DrawingSurface.GetPixel()
  -Convert the result of GetPixel() into r,g,b values
  -Calculate the desaturated version/grayscale equivalent of the r,g,b values (either just a simple average or, better, a weighted average)
  -Convert the grayscale r,g,b value back into an AGS color value
  -Draw that value onto the pixel

That gives you a grayscale version of the screen. Now to get the hidden objects highlighted in yellow, you take each one, create a copy of the sprite, tint it yellow, and draw it onto the grayscale image. Then you display the result on top of the screen, e.g. as the background of a fullscreen GUI.

Again, it could be that this will run so slowly that it's not usable (let's say if it takes twenty seconds to render the grayscale version of the screen).

Another alternative is to provide grayscale versions of all the sprites and backgrounds, and just switch them out. Of course, that will nearly double the size of your game, and unless you do something very clever with sprite numbers or views it will be a pain to manage.

eri0o

Code: ags
DynamicSprite* originalBgSprite;

setBGColor(int r,  int g,  int b,  int s,  int l){   
DrawingSurface* bgSurface = Room.GetDrawingSurfaceForBackground();   
bgSurface.DrawImage(0, 0, originalBgSprite.Graphic);   
bgSurface.Release();   
DynamicSprite* bgSprite = DynamicSprite.CreateFromBackground();   
bgSprite.Tint(r,g,b,s,l); // You'll have to supply these values;   
bgSurface = Room.GetDrawingSurfaceForBackground();   // Now copy it back to the background   
bgSurface.DrawImage(0, 0, bgSprite.Graphic);   // Clean up   
bgSurface.Release();   
bgSprite.Delete();  
}

function on_event (EventType event, int data) {
  if (event == eEventEnterRoomBeforeFadein) {
    originalBgSprite = DynamicSprite.CreateFromBackground();  
  }
  if (event == eEventLeaveRoom) {
    originalBgSprite.Delete();
  }
}



Above is a code to tint the background. It can be gray by using no saturation (0), like this:

Code: ags
setBGColor(100, 100, 100, 0, 100)


Edit: ah, there's a chance that saturation is actually amount of tint, in this case, if the colors are equal intensity, try setting saturation to 100 and see if this makes the colors gray (when setting r,g,b to equal values)

This is untested. :P

Ah, essentially, tinting sprites is "forever" (until the player has either quit or load a save that was before the tint), which is why it's important to save the sprite somewhere before tinting on the above.

For characters and objects I think their tint should do what you expect provide the region lighting is disabled.

https://adventuregamestudio.github.io/ags-manual/Object.html#objecttint

QuoteObject.Tint
(Formerly known as SetObjectTint, which is now obsolete)

Object.Tint(int red, int green, int blue,
            int saturation, int luminance)
Tints the object on the screen to (RED, GREEN, BLUE) with SATURATION percent saturation.

This function applies a tint to a specific object. For the meaning of all the parameters, see SetAmbientTint.

The tint set by this function overrides any ambient tint set for the room. For this reason, passing the SATURATION as 0 to this function does not turn it off - rather, it ensures that no tint is applied to the object (even if an ambient tint is set).

To remove the tint set by this function and return to using the ambient tint for this object, call RemoveTint

Snarky

I don't think this actually works, eri0o. From the manual:

Quote from: SetAmbientTintThe SATURATION parameter defines how much the tint is applied, and is from 0-100. A saturation of 100 will completely re-colourize the sprites to the supplied colour, and a saturation of 1 will give them a very minor tint towards the specified colour.

So according to that explanation, the parameter cannot desaturate the sprite, it only controls the intensity of the tint. (However, as I said, my experience is that the behavior of the Tint() functions are not according to what I would expect from the documentation, so this could be wrong.)

eri0o

Ambient tint is different for historical reasons/backwards compatibility or something. Try passing a 1 instead of zero.

I do have grayscale scenes using tint in my game but my code is fairly involved and is part of screen effects that depends on stuff, including Tween, so I could not transplant it to here.

I am not at the computer now, so I trust the person interested or someone will experiment and figure it out.

Edit: ah, there's a chance that saturation is actually amount of tint, in this case, if the color is white, try setting saturation to 100 and see if this makes the colors gray (when setting r,g,b to equal values)

I added the note above. Maybe this is it.

SMF spam blocked by CleanTalk