Adds osDrawPolygon to OSSL. Works a little different then other OS Drawing functions, this one has no start and end point, but a number of points that will form the desired polygon. Only FilledPolygon implemented so far.

* Also added some LSL transparent type conversion, as it's done in LSL scripting (string to integer, float to string, etc)
This commit is contained in:
Arthur Valadares
2009-08-21 21:12:22 -03:00
parent 604ef5ba79
commit 7923fd29a0
5 changed files with 98 additions and 18 deletions

View File

@@ -469,13 +469,19 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
}
else if (nextLine.StartsWith("FillPolygon"))
{
PointF[] points = null;
GetParams(partsDelimiter, ref nextLine, 11, ref points);
graph.FillPolygon(myBrush, points);
}
else if (nextLine.StartsWith("Ellipse"))
{
float x = 0;
float y = 0;
GetParams(partsDelimiter, ref nextLine, 7, ref x, ref y);
endPoint.X = (int) x;
endPoint.Y = (int) y;
endPoint.X = (int)x;
endPoint.Y = (int)y;
graph.DrawEllipse(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
startPoint.X += endPoint.X;
startPoint.Y += endPoint.Y;
@@ -492,30 +498,31 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
nextLine = nextLine.Remove(0, 8);
nextLine = nextLine.Trim();
string [] fprops = nextLine.Split(partsDelimiter);
foreach (string prop in fprops) {
string[] fprops = nextLine.Split(partsDelimiter);
foreach (string prop in fprops)
{
switch (prop)
{
case "B":
if (!(myFont.Bold))
myFont = new Font(myFont, myFont.Style | FontStyle.Bold);
break;
break;
case "I":
if (!(myFont.Italic))
myFont = new Font(myFont, myFont.Style | FontStyle.Italic);
break;
break;
case "U":
if (!(myFont.Underline))
myFont = new Font(myFont, myFont.Style | FontStyle.Underline);
break;
break;
case "S":
if (!(myFont.Strikeout))
myFont = new Font(myFont, myFont.Style | FontStyle.Strikeout);
break;
break;
case "R":
myFont = new Font(myFont, FontStyle.Regular);
break;
break;
}
}
}
@@ -542,7 +549,7 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
if (Int32.TryParse(nextLine, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out hex))
{
newColour = Color.FromArgb(hex);
}
}
else
{
// this doesn't fail, it just returns black if nothing is found
@@ -582,6 +589,25 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
}
}
private static void GetParams(char[] partsDelimiter, ref string line, int startLength, ref PointF[] points)
{
line = line.Remove(0, startLength);
string[] parts = line.Split(partsDelimiter);
if (parts.Length > 1 && parts.Length % 2 == 0)
{
points = new PointF[parts.Length / 2];
for (int i = 0; i < parts.Length; i = i + 2)
{
string xVal = parts[i].Trim();
string yVal = parts[i+1].Trim();
float x = Convert.ToSingle(xVal, CultureInfo.InvariantCulture);
float y = Convert.ToSingle(yVal, CultureInfo.InvariantCulture);
PointF point = new PointF(x, y);
points[i / 2] = point;
}
}
}
private Bitmap ImageHttpRequest(string url)
{
WebRequest request = HttpWebRequest.Create(url);