OsSetPenColour

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
m
(syntax correction, Need to get this moved to osPenColor)
Line 1: Line 1:
{{Template:Quicklinks}}
+
{{Template:Quicklinks}} [[Technical Reference|Technical Reference]] -> [[Technical Reference/terms|Terms]] -> [[Status|Status Page]] -> [[OSSL Implemented|OSSL Implemented Functions]] -> [[Dynamic textures]] -> [[OsSetPenColour|osSetPenColour]]  
[[Technical Reference | Technical Reference]] -> [[Technical Reference/terms | Terms]] -> [[Status | Status Page]] -> [[OSSL_Implemented| OSSL Implemented Functions]] -> [[Dynamic textures]] -> [[OsSetPenColour | osSetPenColour]]
+
  
 +
<br><strike>LSL: </strike>'''[[String|<strike>String</strike>]]<strike>osSetPenColour( </strike>[[String|<strike>String</strike>]]'''<strike>'''drawList, string colour )'''</strike>&nbsp; deprecated as of Dec.10.2010<br><strike>C#: </strike>'''[[String|<strike>String</strike>]]<strike>osSetPenColour( </strike>[[String|<strike>String</strike>]]'''<strike>'''drawList, string colour )''' </strike>deprecated as of Dec.10.2010
  
LSL: '''[[string]] osSetPenColour( [[string]] drawList, string colour )'''<br />
+
LSL: '''[[String]] osSetPenColor( [[String]] drawList, string color )'''&nbsp;<br>C#: '''[[String]] osSetPenColor( [[String]] drawList, string color )'''&nbsp;
C#: '''[[string]] osSetPenColour( [[string]] drawList, string colour )'''
+
  
 +
<br>Appends a [[Drawing commands#PenColour|PenColour]] drawing command to the string provided in '''drawList''' and returns the result.
  
Appends a [[Drawing_commands#PenColour|PenColour]] drawing command to the string provided in '''drawList''' and returns the result.
+
This sets the pen's drawing color to either the specified [http://msdn.microsoft.com/en-us/library/aa358802.aspx named .NET color] or to a 32-bit color value (formatted as eight hexadecimal digits in the format aarrggbb, representing the eight-bit alpha, red, green and blue channels).  
  
This sets the pen's drawing color to either the specified [http://msdn.microsoft.com/en-us/library/aa358802.aspx named .NET color] or to a 32-bit color value (formatted as eight hexadecimal digits in the format aarrggbb, representing the eight-bit alpha, red, green and blue channels).
+
For full opacity, use an alpha value of ff (e.g. <tt>ffff0000</tt> for red); for varying degrees of transparency, reduce the alpha value (e.g. <tt>800000ff</tt> for half-transparent blue).  
  
For full opacity, use an alpha value of ff (e.g. <tt>ffff0000</tt> for red); for varying degrees of transparency, reduce the alpha value (e.g. <tt>800000ff</tt> for half-transparent blue).
+
The color names and hexadecimal color representations are not case-sensitive.  
  
The color names and hexadecimal color representations are not case-sensitive.
+
Example: <source lang="lsl">
 
+
// Example of osSetPenColor
Example:
+
<source lang="lsl">
+
// Example of osSetPenColour
+
  
 
string hexDigits = "0123456789abcdef";
 
string hexDigits = "0123456789abcdef";
list colorNames = [ "AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque",
+
list colorNames = [ "AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque",
                    "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood",
+
"Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood",
                    "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk",
+
"CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk",
                    "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGrey",
+
"Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGrey",
                    "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange",
+
"DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange",
                    "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue",
+
"DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue",
                    "DarkSlateGrey", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue",
+
"DarkSlateGrey", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue",
                    "DimGrey", "DodgerBlue", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia",
+
"DimGrey", "DodgerBlue", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia",
                    "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Grey", "Green", "GreenYellow",
+
"Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Grey", "Green", "GreenYellow",
                    "Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender",
+
"Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender",
                    "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral",
+
"LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral",
                    "LightCyan", "LightGoldenrodYellow", "LightGreen", "LightGrey", "LightPink",
+
"LightCyan", "LightGoldenrodYellow", "LightGreen", "LightGrey", "LightPink",
                    "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGrey",
+
"LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGrey",
                    "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta",
+
"LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta",
                    "Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple",
+
"Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple",
                    "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise",
+
"MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise",
                    "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin",
+
"MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin",
                    "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed",
+
"NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed",
                    "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed",
+
"Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed",
                    "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple",
+
"PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple",
                    "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown",
+
"Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown",
                    "SeaGreen", "Seashell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGrey",
+
"SeaGreen", "Seashell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGrey",
                    "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato",
+
"Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato",
                    "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen" ];
+
"Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen" ];
  
 
default
 
default
 
{
 
{
    state_entry()
+
state_entry()
    {
+
{
        string CommandList = "";                             // Storage for our drawing commands
+
string CommandList = ""; // Storage for our drawing commands
        integer i;
+
integer i;
  
        CommandList = osSetPenSize( CommandList, 1 );         // Set the pen width to 1 pixel
+
CommandList = osSetPenSize( CommandList, 1 ); // Set the pen width to 1 pixel
  
        for (i = 0; i < 140; ++i) // draw each named color as a single horizontal line
+
for (i = 0; i < 140; ++i) // draw each named color as a single horizontal line
        {
+
{
            // Set the pen to the next color name in our list
+
// Set the pen to the next color name in our list
            CommandList = osSetPenColour( CommandList, llList2String( colorNames, i ));
+
CommandList = osSetPenColor( CommandList, llList2String( colorNames, i ));
            // Now draw a line in that color
+
// Now draw a line in that color
            CommandList = osDrawLine( CommandList, 0, i, 255, i );
+
CommandList = osDrawLine( CommandList, 0, i, 255, i );
        }
+
}
  
        // Now let's fill up the remainder with lines of random colors, leaving a gap of 20 lines.
+
// Now let's fill up the remainder with lines of random colors, leaving a gap of 20 lines.
        for (i = 161; i < 256; ++i)
+
for (i = 161; i < 256; ++i)
        {
+
{
            string thisColor = "ff"; // give it an opaque alpha
+
string thisColor = "ff"; // give it an opaque alpha
            integer j;
+
integer j;
            for (j = 0; j < 6; ++j) // then choose six random hex digits for the color
+
for (j = 0; j < 6; ++j) // then choose six random hex digits for the color
            {
+
{
                integer k = (integer) llFrand( 16.0 );
+
integer k = (integer) llFrand( 16.0 );
                thisColor += llGetSubString( hexDigits, k, k );
+
thisColor += llGetSubString( hexDigits, k, k );
            }
+
}
            CommandList = osSetPenColour( CommandList, thisColor );
+
CommandList = osSetPenColor( CommandList, thisColor );
            CommandList = osDrawLine( CommandList, 0, i, 255, i );
+
CommandList = osDrawLine( CommandList, 0, i, 255, i );
        }
+
}
        // Now generate the texture and apply it to the prim
+
// Now generate the texture and apply it to the prim
        osSetDynamicTextureData( "", "vector", CommandList, "width:256,height:256", 0 );
+
osSetDynamicTextureData( "", "vector", CommandList, "width:256,height:256", 0 );
    }
+
}
 
}
 
}
</source>
+
</source>  
 
+
 
+
  
 
[[Category:OSSL]]
 
[[Category:OSSL]]

Revision as of 15:48, 10 December 2010

Technical Reference -> Terms -> Status Page -> OSSL Implemented Functions -> Dynamic textures -> osSetPenColour


LSL: StringosSetPenColour( StringdrawList, string colour )  deprecated as of Dec.10.2010
C#: StringosSetPenColour( StringdrawList, string colour ) deprecated as of Dec.10.2010

LSL: String osSetPenColor( String drawList, string color ) 
C#: String osSetPenColor( String drawList, string color ) 


Appends a PenColour drawing command to the string provided in drawList and returns the result.

This sets the pen's drawing color to either the specified named .NET color or to a 32-bit color value (formatted as eight hexadecimal digits in the format aarrggbb, representing the eight-bit alpha, red, green and blue channels).

For full opacity, use an alpha value of ff (e.g. ffff0000 for red); for varying degrees of transparency, reduce the alpha value (e.g. 800000ff for half-transparent blue).

The color names and hexadecimal color representations are not case-sensitive.

Example:
// Example of osSetPenColor
 
string hexDigits = "0123456789abcdef";
list colorNames = [ "AliceBlue", "AntiqueWhite", "Aqua", "Aquamarine", "Azure", "Beige", "Bisque",
 "Black", "BlanchedAlmond", "Blue", "BlueViolet", "Brown", "BurlyWood",
 "CadetBlue", "Chartreuse", "Chocolate", "Coral", "CornflowerBlue", "Cornsilk",
 "Crimson", "Cyan", "DarkBlue", "DarkCyan", "DarkGoldenrod", "DarkGrey",
 "DarkGreen", "DarkKhaki", "DarkMagenta", "DarkOliveGreen", "DarkOrange",
 "DarkOrchid", "DarkRed", "DarkSalmon", "DarkSeaGreen", "DarkSlateBlue",
 "DarkSlateGrey", "DarkTurquoise", "DarkViolet", "DeepPink", "DeepSkyBlue",
 "DimGrey", "DodgerBlue", "FireBrick", "FloralWhite", "ForestGreen", "Fuchsia",
 "Gainsboro", "GhostWhite", "Gold", "Goldenrod", "Grey", "Green", "GreenYellow",
 "Honeydew", "HotPink", "IndianRed", "Indigo", "Ivory", "Khaki", "Lavender",
 "LavenderBlush", "LawnGreen", "LemonChiffon", "LightBlue", "LightCoral",
 "LightCyan", "LightGoldenrodYellow", "LightGreen", "LightGrey", "LightPink",
 "LightSalmon", "LightSeaGreen", "LightSkyBlue", "LightSlateGrey",
 "LightSteelBlue", "LightYellow", "Lime", "LimeGreen", "Linen", "Magenta",
 "Maroon", "MediumAquamarine", "MediumBlue", "MediumOrchid", "MediumPurple",
 "MediumSeaGreen", "MediumSlateBlue", "MediumSpringGreen", "MediumTurquoise",
 "MediumVioletRed", "MidnightBlue", "MintCream", "MistyRose", "Moccasin",
 "NavajoWhite", "Navy", "OldLace", "Olive", "OliveDrab", "Orange", "OrangeRed",
 "Orchid", "PaleGoldenrod", "PaleGreen", "PaleTurquoise", "PaleVioletRed",
 "PapayaWhip", "PeachPuff", "Peru", "Pink", "Plum", "PowderBlue", "Purple",
 "Red", "RosyBrown", "RoyalBlue", "SaddleBrown", "Salmon", "SandyBrown",
 "SeaGreen", "Seashell", "Sienna", "Silver", "SkyBlue", "SlateBlue", "SlateGrey",
 "Snow", "SpringGreen", "SteelBlue", "Tan", "Teal", "Thistle", "Tomato",
 "Turquoise", "Violet", "Wheat", "White", "WhiteSmoke", "Yellow", "YellowGreen" ];
 
default
{
 state_entry()
 {
 string CommandList = ""; // Storage for our drawing commands
 integer i;
 
 CommandList = osSetPenSize( CommandList, 1 ); // Set the pen width to 1 pixel
 
 for (i = 0; i < 140; ++i) // draw each named color as a single horizontal line
 {
 // Set the pen to the next color name in our list
 CommandList = osSetPenColor( CommandList, llList2String( colorNames, i ));
 // Now draw a line in that color
 CommandList = osDrawLine( CommandList, 0, i, 255, i );
 }
 
 // Now let's fill up the remainder with lines of random colors, leaving a gap of 20 lines.
 for (i = 161; i < 256; ++i)
 {
 string thisColor = "ff"; // give it an opaque alpha
 integer j;
 for (j = 0; j < 6; ++j) // then choose six random hex digits for the color
 {
 integer k = (integer) llFrand( 16.0 );
 thisColor += llGetSubString( hexDigits, k, k );
 }
 CommandList = osSetPenColor( CommandList, thisColor );
 CommandList = osDrawLine( CommandList, 0, i, 255, i );
 }
 // Now generate the texture and apply it to the prim
 osSetDynamicTextureData( "", "vector", CommandList, "width:256,height:256", 0 );
 }
}
Personal tools
General
About This Wiki