drawPolygon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
No edit summary
 
(50 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3dev |= Game name
|game1= arma3
|version1= 1.58


|1.57|= Game version
|gr1= GUI Control - Map
____________________________________________________________________________________________


| Draws given polygon on the given map control with given color. The polygon must consist of at least 3 points. |= Description
|descr= Draws given polygon on the given map control with given color. The polygon must consist of at least 3 points. Unlike with other {{hl|draw*}} commands and due to complexity, this command does not support filling of the polygon with color. Use [[drawTriangle]] command to construct and fill polygon shape as a workaround.
____________________________________________________________________________________________


| map '''drawPolygon''' [polygon, color] |= Syntax
|s1= map [[drawPolygon]] [polygon, color]


|p1= map: [[Control]] |= Parameter 1
|p1= map: [[Control]]
|p2= [polygon, color]: [[Array]] |= Parameter 2
|p3= polygon: [[Array]] - array of positions in format [pos1, pos2, pos3,....posN], where pos is [[Position3D]] |= Parameter 3
|p4= color: [[Array]] - line color in format [r,g,b,a]|= Parameter 4
| [[Nothing]] |= Return value


|x1=<code>test_polygon = [];
|p2= polygon: [[Array]] of [[Position#Introduction|Position3D]]
[[for]] "_i" [[from]] 1 [[to]] 12 [[do]]
 
|p3= color: [[Color|Color (RGBA)]]
 
|r1= [[Nothing]]
 
|x1= <sqf>
test_polygon = [];
for "_i" from 1 to 12 do  
{
{
test_polygon [[pushBack]] ([[player]] [[getPos]] [10 + [[random]] 100, 360/_i]);
test_polygon pushBack (player getPos [10 + random 100, 360 / _i]);
};
};
[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlAddEventHandler]] ["Draw",  
 
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",  
{
{
_this [[select]] 0 [[drawPolygon]] [test_polygon, [0,0,1,1]];
params ["_control"];
}];</code>|=
_control drawPolygon [test_polygon, [0,0,1,1]];
____________________________________________________________________________________________
}];
</sqf>


|[[drawEllipse]], [[drawIcon]], [[drawLine]], [[drawRectangle]], [[drawArrow]], [[inPolygon]]|= See also
|x2= Draw a polygon by adjusting the {{hl|_radius}} and {{hl|_numVertices}}
<sqf>
vertices = [];
private _numVertices = 2;
private _numVertices = _numVertices max 3;
private _radius = 100;


}}
for "_i" from 1 to _numVertices do
{
vertices pushBack (player getRelPos [_radius, 360 / _numVertices * _i]);
};


<h3 style="display:none">Notes</h3>
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
<dl class="command_description">
{
<!-- Note Section BEGIN -->
params ["_control"];
_control drawPolygon [vertices, [0,0,1,1]];
}];
</sqf>


<!-- Note Section END -->
|seealso= [[drawEllipse]] [[drawIcon]] [[drawLine]] [[drawRectangle]] [[drawArrow]] [[drawTriangle]] [[inPolygon]] [[drawXPolygon]]
</dl>
}}
 
<h3 style="display:none">Bottom Section</h3>
 
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 22:36, 1 November 2024

Hover & click on the images for description

Description

Description:
Draws given polygon on the given map control with given color. The polygon must consist of at least 3 points. Unlike with other draw* commands and due to complexity, this command does not support filling of the polygon with color. Use drawTriangle command to construct and fill polygon shape as a workaround.
Groups:
GUI Control - Map

Syntax

Syntax:
map drawPolygon [polygon, color]
Parameters:
map: Control
polygon: Array of Position3D
color: Color (RGBA)
Return Value:
Nothing

Examples

Example 1:
test_polygon = []; for "_i" from 1 to 12 do { test_polygon pushBack (player getPos [10 + random 100, 360 / _i]); }; findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { params ["_control"]; _control drawPolygon [test_polygon, [0,0,1,1]]; }];
Example 2:
Draw a polygon by adjusting the _radius and _numVertices
vertices = []; private _numVertices = 2; private _numVertices = _numVertices max 3; private _radius = 100; for "_i" from 1 to _numVertices do { vertices pushBack (player getRelPos [_radius, 360 / _numVertices * _i]); }; findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { params ["_control"]; _control drawPolygon [vertices, [0,0,1,1]]; }];

Additional Information

See also:
drawEllipse drawIcon drawLine drawRectangle drawArrow drawTriangle inPolygon drawXPolygon

Notes

Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note