new command to retrieve the water colour

getwatercolour

  Returns a string with the four components of the water colour, red,
  green, blue and alpha.

  Example: echo (getwatercolor)  --> 20 25 20 178

setwatercolour what value

  Allows setting the components of the water colour independently. "what"
  is either a keyword "red|green|blue|alpha" or the index number 0..3 and
  determines, which component is set to "value".

  Example:

    watercolour 0 0 0
      sets all colour components to zero

    setwatercolour red 200
      sets the red component to 200

DOCREF getwatercolour setwatercolour
This commit is contained in:
ac-stef
2016-09-03 16:56:10 +02:00
parent 3e7a0cfb10
commit 05e0bf5b30
+20
View File
@@ -36,6 +36,26 @@ void setwatercolor(const char *r, const char *g, const char *b, const char *a)
COMMANDN(watercolour, setwatercolor, "ssss");
FVAR(waveheight, 0, 0.3f, 1.0f);
void getwatercolour()
{
defformatstring(res)("%d %d %d %d", hdr.watercolor[0], hdr.watercolor[1], hdr.watercolor[2], hdr.watercolor[3]);
result(res);
}
COMMAND(getwatercolour, "");
const char *componentnames[] = { "red", "green", "blue", "alpha", "" };
void setwatercolour(char *what, int *v)
{
int t = getlistindex(what, componentnames, true, -1);
if(t >= 0 && t < 4)
{
hdr.watercolor[t] = *v;
if(editmode) unsavededits++;
}
}
COMMAND(setwatercolour, "si");
// renders water for bounding rect area that contains water... simple but very inefficient
#define VERTW(vertw, defbody, body) \