Implemented osPenCap, that sets EndCap and StartCap to Pen. This allows using arrow, diamond, round and flat caps.
* Made image request safer, if it can't find an image for any reason, draws a square where the image should be and a message alerting the user.remotes/origin/0.6.7-post-fixes
parent
9c9fa51b0f
commit
efb287f28f
|
@ -443,7 +443,16 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
|||
endPoint.X = (int) x;
|
||||
endPoint.Y = (int) y;
|
||||
Image image = ImageHttpRequest(nextLine);
|
||||
graph.DrawImage(image, (float) startPoint.X, (float) startPoint.Y, x, y);
|
||||
if (image != null)
|
||||
{
|
||||
graph.DrawImage(image, (float)startPoint.X, (float)startPoint.Y, x, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.DrawString("URL couldn't be resolved or is", new Font("Arial",6), myBrush, startPoint);
|
||||
graph.DrawString("not an image. Please check URL.", new Font("Arial", 6), myBrush, new Point(startPoint.X, 12 + startPoint.Y));
|
||||
graph.DrawRectangle(drawPen, startPoint.X, startPoint.Y, endPoint.X, endPoint.Y);
|
||||
}
|
||||
startPoint.X += endPoint.X;
|
||||
startPoint.Y += endPoint.Y;
|
||||
}
|
||||
|
@ -539,6 +548,57 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
|||
float size = Convert.ToSingle(nextLine, CultureInfo.InvariantCulture);
|
||||
drawPen.Width = size;
|
||||
}
|
||||
else if (nextLine.StartsWith("PenCap"))
|
||||
{
|
||||
bool start = true, end = true;
|
||||
nextLine = nextLine.Remove(0, 6);
|
||||
nextLine = nextLine.Trim();
|
||||
string[] cap = nextLine.Split(partsDelimiter);
|
||||
if (cap[0].ToLower() == "start")
|
||||
end = false;
|
||||
else if (cap[0].ToLower() == "end")
|
||||
start = false;
|
||||
else if (cap[0].ToLower() != "both")
|
||||
return;
|
||||
string type = cap[1].ToLower();
|
||||
|
||||
if (end)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.EndCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (start)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "arrow":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.ArrowAnchor;
|
||||
break;
|
||||
case "round":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.RoundAnchor;
|
||||
break;
|
||||
case "diamond":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.DiamondAnchor;
|
||||
break;
|
||||
case "flat":
|
||||
drawPen.StartCap = System.Drawing.Drawing2D.LineCap.Flat;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (nextLine.StartsWith("PenColour"))
|
||||
{
|
||||
nextLine = nextLine.Remove(0, 9);
|
||||
|
@ -609,17 +669,20 @@ namespace OpenSim.Region.CoreModules.Scripting.VectorRender
|
|||
}
|
||||
|
||||
private Bitmap ImageHttpRequest(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
WebRequest request = HttpWebRequest.Create(url);
|
||||
//Ckrinke: Comment out for now as 'str' is unused. Bring it back into play later when it is used.
|
||||
//Ckrinke Stream str = null;
|
||||
HttpWebResponse response = (HttpWebResponse) (request).GetResponse();
|
||||
HttpWebResponse response = (HttpWebResponse)(request).GetResponse();
|
||||
if (response.StatusCode == HttpStatusCode.OK)
|
||||
{
|
||||
Bitmap image = new Bitmap(response.GetResponseStream());
|
||||
return image;
|
||||
}
|
||||
|
||||
}
|
||||
catch { }
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -879,6 +879,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
return drawList;
|
||||
}
|
||||
|
||||
public string osSetPenCap(string drawList, string direction, string type)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osSetPenColour");
|
||||
|
||||
m_host.AddScriptLPS(1);
|
||||
drawList += "PenCap " + direction + "," + type + "; ";
|
||||
return drawList;
|
||||
}
|
||||
|
||||
public string osDrawImage(string drawList, int width, int height, string imageUrl)
|
||||
{
|
||||
CheckThreatLevel(ThreatLevel.None, "osDrawImage");
|
||||
|
|
|
@ -101,6 +101,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
|
|||
string osSetFontSize(string drawList, int fontSize);
|
||||
string osSetPenSize(string drawList, int penSize);
|
||||
string osSetPenColour(string drawList, string colour);
|
||||
string osSetPenCap(string drawList, string direction, string type);
|
||||
string osDrawImage(string drawList, int width, int height, string imageUrl);
|
||||
vector osGetDrawStringSize(string contentType, string text, string fontName, int fontSize);
|
||||
void osSetStateEvents(int events);
|
||||
|
|
|
@ -282,6 +282,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
|
|||
return m_OSSL_Functions.osSetPenSize(drawList, penSize);
|
||||
}
|
||||
|
||||
public string osSetPenCap(string drawList, string direction, string type)
|
||||
{
|
||||
return m_OSSL_Functions.osSetPenCap(drawList, direction, type);
|
||||
}
|
||||
|
||||
public string osSetPenColour(string drawList, string colour)
|
||||
{
|
||||
return m_OSSL_Functions.osSetPenColour(drawList, colour);
|
||||
|
|
Loading…
Reference in New Issue