|
[Visual Basic]
Dim ca As New Canvas
Dim myparams As String
Dim mycol As New XColor
ca.Width = 200
ca.Height = 200
myparams = " Size=100,100 Operation=both"
ca.DrawShape("rect", "Pos=0,0 PaintColor=red PenColor=red"
+ myparams)
ca.DrawShape("rect", "Pos=100,0 PaintColor=green
PenColor=green" + myparams)
ca.DrawShape("rect", "Pos=0,100 PaintColor=blue PenColor=blue"
+ myparams)
ca.DrawShape("rect", "Pos=100,100 PaintColor=yellow
PenColor=yellow" + myparams)
ca.SaveAs(Server.MapPath("getcolor.gif"), "")
mycol.Color = ca.GetColor(New System.Drawing.Point(50,50))
Response.Write("Top Left Color is " + mycol.String
+ "<br>" + vbCrLf)
mycol.Color = ca.GetColor(New System.Drawing.Point(150,50))
Response.Write("Top Right Color is " + mycol.String
+ "<br>" + vbCrLf)
mycol.Color = ca.GetColor(New System.Drawing.Point(50,150))
Response.Write("Bottom Left Color is " + mycol.String
+ "<br>" + vbCrLf)
mycol.Color = ca.GetColor(New System.Drawing.Point(150,150))
Response.Write("Bottom Left Color is " + mycol.String
+ "<br>" + vbCrLf)
[C#]
Canvas ca = new Canvas();
XColor mycol = new XColor();
ca.Width = 200;
ca.Height = 200;
string myparams = " Size=100,100 Operation=both";
ca.DrawShape("rect", "Pos=0,0 PaintColor=red PenColor=red"
+ myparams);
ca.DrawShape("rect", "Pos=100,0 PaintColor=green
PenColor=green" + myparams);
ca.DrawShape("rect", "Pos=0,100 PaintColor=blue PenColor=blue"
+ myparams);
ca.DrawShape("rect", "Pos=100,100 PaintColor=yellow
PenColor=yellow" + myparams);
ca.SaveAs(Server.MapPath("getcolor.gif"), "");
mycol.Color = ca.GetColor(new System.Drawing.Point(50,50));
Response.Write("Top Left Color is " + mycol.String + "<br>\r\n");
mycol.Color = ca.GetColor(new System.Drawing.Point(150,50));
Response.Write("Top Right Color is " + mycol.String +
"<br>\r\n");
mycol.Color = ca.GetColor(new System.Drawing.Point(50,150));
Response.Write("Bottom Left Color is " + mycol.String
+ "<br>\r\n");
mycol.Color = ca.GetColor(new System.Drawing.Point(150,150));
Response.Write("Bottom Left Color is " + mycol.String
+ "<br>\r\n");
The graphics file and text output that this produces is shown below.
Note that the names of colors map onto what might be described as
a typical value rather than a 100% saturated value. For instance
green is not a 100% saturated green with no other components (this
looks rather garish) but a rather more typical green color.
getcolor.gif
Top Left Color is 86.7,3.1,2.4,0.0
Top Right Color is 0.0,39.2,6.7,0.0
Bottom Left Color is 0.0,0.0,83.1,0.0
Bottom Left Color is 98.8,95.3,2.0,0.0
|
|
|