OsDrawPolygon

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
 
(10 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Template:Quicklinks}}
+
{{osslfunc
{| width="100%" style="border: thin solid black"
+
|threat_level=None
| colspan="2" align="center" style=background:orange | '''{{SUBPAGENAME}}'''
+
|function_syntax=string osDrawPolygon(string drawList, list xpoints, list ypoints)
|- valign="top"
+
|ossl_example=<source lang="lsl">
|'''Threat Level''' || <Threat Level goes here>
+
 
+
|- valign="top"
+
|'''Function Syntax''' || <source lang="lsl">
+
LSL: string osDrawPolygon( string drawList, list xpoints, list ypoints )
+
C#: string osDrawPolygon( string drawList, LSL_List xpoints, LSL_List ypoints )
+
</source>
+
|- valign="top"
+
|'''Example(s)||<source lang="lsl">
+
 
// Example of osDrawPolygon
 
// Example of osDrawPolygon
 
default
 
default
Line 17: Line 8:
 
     state_entry()
 
     state_entry()
 
     {
 
     {
    // Storage for our drawing commands
+
        // Storage for our drawing commands
 
         string CommandList = "";  
 
         string CommandList = "";  
 
+
       
    // Set the pen width to 3 pixels
+
        // "PenSize 3;"
 
         CommandList = osSetPenSize( CommandList, 3 );
 
         CommandList = osSetPenSize( CommandList, 3 );
 
+
        // "PenColor Blue;"
    // Set the pen color to blue
+
         CommandList = osSetPenColor( CommandList, "Blue" );  
         CommandList = osSetPenColour( CommandList, "Blue" );  
+
        // "Polygon 128,20,20,186,236,186;"
 
+
        CommandList = osDrawPolygon( CommandList, [128,20,236], [20,186,186] );
    // You can use either integer, float or string
+
       
         CommandList = osDrawPolygon( CommandList, [50,100,150], ["50",100,150.0] );  
+
        // "PenColor Green;"
 
+
        CommandList = osSetPenColor( CommandList, "Green" );
    // Now draw the polygon
+
        // "Polygon 128,236,20,70,236,70;"
 +
         CommandList = osDrawPolygon( CommandList, [128,20,236], [236,70,70] );
 +
       
 +
        // "PenSize 5;"
 +
        CommandList = osSetPenSize( CommandList, 5 );
 +
        // "PenColor Red;"
 +
        CommandList = osSetPenColor( CommandList, "Red" );
 +
        // "Polygon 20,20,236,20,236,236,20,236;"
 +
        CommandList = osDrawPolygon( CommandList, [20,236,236,20], [20,20,236,236] );
 +
       
 +
        // Now draw the polygon
 
         osSetDynamicTextureData( "", "vector", CommandList, "", 0 );
 
         osSetDynamicTextureData( "", "vector", CommandList, "", 0 );
 
     }
 
     }
}
+
}</source>
</source>
+
The result will be like that:
 
+
[[Image:OsDrawPolygonSample.png|200px]]
|}
+
|description=*Appends a [[Drawing commands#Polygon|Polygon]] drawing command to the string provided in '''drawList''' and returns the result.
Appends a [[Drawing_commands#Polygon|Polygon]] drawing command to the string provided in '''drawList''' and returns the result.
+
*The polygon is drawn with the current pen size and color on the x,y point pairs that comes from LSL list.
 
+
*It will be converted into the drawing command "Polygon x[0],y[0],x[1],y[1],x[2],y[2],...". See [[Drawing commands#Polygon]] to know what the command will actually do.
The polygon is drawn with the current pen size and color on the x,y point pairs that comes from LSL list. So (x[0],y[0]),(x[1],y[1]),(x[2],y[2]) would be an example of a polygon.
+
|
 
+
}}
[[Category:OSSL Functions]]
+
[[Category:OSSL]]
+
[[Category:OSSL functions without threat level]]
+

Latest revision as of 13:35, 14 November 2018

string osDrawPolygon(string drawList, list xpoints, list ypoints)
  • Appends a Polygon drawing command to the string provided in drawList and returns the result.
  • The polygon is drawn with the current pen size and color on the x,y point pairs that comes from LSL list.
  • It will be converted into the drawing command "Polygon x[0],y[0],x[1],y[1],x[2],y[2],...". See Drawing commands#Polygon to know what the command will actually do.
Threat Level None
Permissions No permissions specified
Extra Delay No function delay specified
Example(s)
// Example of osDrawPolygon
default
{
    state_entry()
    {
        // Storage for our drawing commands
        string CommandList = ""; 
 
        // "PenSize 3;"
        CommandList = osSetPenSize( CommandList, 3 );
        // "PenColor Blue;"
        CommandList = osSetPenColor( CommandList, "Blue" ); 
        // "Polygon 128,20,20,186,236,186;"
        CommandList = osDrawPolygon( CommandList, [128,20,236], [20,186,186] );
 
        // "PenColor Green;"
        CommandList = osSetPenColor( CommandList, "Green" ); 
        // "Polygon 128,236,20,70,236,70;"
        CommandList = osDrawPolygon( CommandList, [128,20,236], [236,70,70] );
 
        // "PenSize 5;"
        CommandList = osSetPenSize( CommandList, 5 );
        // "PenColor Red;"
        CommandList = osSetPenColor( CommandList, "Red" ); 
        // "Polygon 20,20,236,20,236,236,20,236;"
        CommandList = osDrawPolygon( CommandList, [20,236,236,20], [20,20,236,236] );
 
        // Now draw the polygon
        osSetDynamicTextureData( "", "vector", CommandList, "", 0 );
    }
}

The result will be like that: OsDrawPolygonSample.png

Personal tools
General
About This Wiki