Merge branch 'vector' into OpenSimulator.org
parent
4e5e70491b
commit
b9db1b1345
OpenSim/Region/Environment/Modules/Scripting/VectorRender
|
@ -128,34 +128,134 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
|
||||||
|
|
||||||
private void Draw(string data, UUID id, string extraParams)
|
private void Draw(string data, UUID id, string extraParams)
|
||||||
{
|
{
|
||||||
// TODO: this is a brutal hack. extraParams should actually be parsed reasonably.
|
// We need to cater for old scripts that didnt use extraParams neatly, they use either an integer size which represents both width and height, or setalpha
|
||||||
int size = 256;
|
// we will now support multiple comma seperated params in the form width:256,height:512,alpha:255
|
||||||
try
|
int width = 256;
|
||||||
|
int height = 256;
|
||||||
|
int alpha = 255; // 0 is transparent
|
||||||
|
|
||||||
|
char[] paramDelimiter = { ',' };
|
||||||
|
char[] nvpDelimiter = { ':' };
|
||||||
|
|
||||||
|
extraParams = extraParams.Trim();
|
||||||
|
extraParams = extraParams.ToLower();
|
||||||
|
|
||||||
|
string[] nvps = extraParams.Split(paramDelimiter);
|
||||||
|
|
||||||
|
int temp = -1;
|
||||||
|
foreach (string pair in nvps)
|
||||||
{
|
{
|
||||||
size = Convert.ToInt32(extraParams);
|
string[] nvp = pair.Split(nvpDelimiter);
|
||||||
}
|
string name = "";
|
||||||
catch (Exception e)
|
string value = "";
|
||||||
{
|
|
||||||
//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
|
if (nvp[0] != null)
|
||||||
Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
|
{
|
||||||
|
name = nvp[0].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nvp.Length==2)
|
||||||
|
{
|
||||||
|
value = nvp[1].Trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (name)
|
||||||
|
{
|
||||||
|
case "width":
|
||||||
|
temp = parseIntParam(value);
|
||||||
|
if (temp != -1)
|
||||||
|
{
|
||||||
|
if (temp < 1)
|
||||||
|
{
|
||||||
|
width = 1;
|
||||||
|
}
|
||||||
|
else if (temp > 2048)
|
||||||
|
{
|
||||||
|
width = 2048;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
width = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "height":
|
||||||
|
temp = parseIntParam(value);
|
||||||
|
if (temp != -1)
|
||||||
|
{
|
||||||
|
if (temp < 1)
|
||||||
|
{
|
||||||
|
height = 1;
|
||||||
|
}
|
||||||
|
else if (temp > 2048)
|
||||||
|
{
|
||||||
|
height = 2048;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
height = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "alpha":
|
||||||
|
temp = parseIntParam(value);
|
||||||
|
if (temp != -1)
|
||||||
|
{
|
||||||
|
if (temp < 0)
|
||||||
|
{
|
||||||
|
alpha = 0;
|
||||||
|
}
|
||||||
|
else if (temp > 255)
|
||||||
|
{
|
||||||
|
alpha = 255;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
alpha = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "":
|
||||||
|
// blank string has been passed do nothing just use defaults
|
||||||
|
break;
|
||||||
|
default: // this is all for backwards compat, all a bit ugly hopfully can be removed in future
|
||||||
|
// could be either set alpha or just an int
|
||||||
|
if (name == "setalpha")
|
||||||
|
{
|
||||||
|
alpha = 0; // set the texture to have transparent background (maintains backwards compat)
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// this function used to accept an int on its own that represented both
|
||||||
|
// width and height, this is to maintain backwards compat, could be removed
|
||||||
|
// but would break existing scripts
|
||||||
|
temp = parseIntParam(name);
|
||||||
|
if (temp != -1)
|
||||||
|
{
|
||||||
|
if (temp > 1028)
|
||||||
|
temp = 1028;
|
||||||
|
|
||||||
|
if (temp < 128)
|
||||||
|
temp = 128;
|
||||||
|
|
||||||
|
width = temp;
|
||||||
|
height = temp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((size < 128) || (size > 1024))
|
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format32bppArgb);
|
||||||
size = 256;
|
|
||||||
|
|
||||||
Bitmap bitmap = new Bitmap(size, size, PixelFormat.Format32bppArgb);
|
|
||||||
|
|
||||||
Graphics graph = Graphics.FromImage(bitmap);
|
Graphics graph = Graphics.FromImage(bitmap);
|
||||||
|
|
||||||
extraParams = extraParams.ToLower();
|
// this is really just to save people filling the
|
||||||
int alpha = 255;
|
// background white in their scripts, only do when fully opaque
|
||||||
if (extraParams == "setalpha")
|
if (alpha == 255)
|
||||||
{
|
{
|
||||||
alpha = 0;
|
graph.FillRectangle(new SolidBrush(Color.White), 0, 0, width, height);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
graph.FillRectangle(new SolidBrush(Color.White), 0, 0, size, size);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int w = 0; w < bitmap.Width; w++)
|
for (int w = 0; w < bitmap.Width; w++)
|
||||||
|
@ -183,6 +283,25 @@ namespace OpenSim.Region.Environment.Modules.Scripting.VectorRender
|
||||||
m_textureManager.ReturnData(id, imageJ2000);
|
m_textureManager.ReturnData(id, imageJ2000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int parseIntParam(string strInt)
|
||||||
|
{
|
||||||
|
int parsed;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
parsed = Convert.ToInt32(strInt);
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//Ckrinke: Add a WriteLine to remove the warning about 'e' defined but not used
|
||||||
|
// Console.WriteLine("Problem with Draw. Please verify parameters." + e.ToString());
|
||||||
|
parsed = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return parsed;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
private void CairoDraw(string data, System.Drawing.Graphics graph)
|
private void CairoDraw(string data, System.Drawing.Graphics graph)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue