drawPolygon: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - "<code>([^<]*)\[\[([^|]+\|)(!?=?=?\+?-?)\]\]([^<]*) *<\/code>" to "<code>$1$3$4</code>") |
Lou Montana (talk | contribs) m (Some wiki formatting) |
||
Line 18: | Line 18: | ||
|r1= [[Nothing]] | |r1= [[Nothing]] | ||
|x1= < | |x1= <sqf> | ||
test_polygon = []; | |||
for "_i" from 1 to 12 do | 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]); | ||
}; | }; | ||
Line 28: | Line 29: | ||
params ["_control"]; | params ["_control"]; | ||
_control drawPolygon [test_polygon, [0,0,1,1]]; | _control drawPolygon [test_polygon, [0,0,1,1]]; | ||
}];</ | }]; | ||
</sqf> | |||
|x2= Draw a polygon by adjusting the {{ic|_radius}} and {{ic|_numVertices}}< | |x2= Draw a polygon by adjusting the {{ic|_radius}} and {{ic|_numVertices}} | ||
<sqf> | |||
vertices = []; | |||
private _numVertices = 2; | private _numVertices = 2; | ||
private _numVertices = _numVertices max 3; | private _numVertices = _numVertices max 3; | ||
Line 37: | Line 41: | ||
for "_i" from 1 to _numVertices do | for "_i" from 1 to _numVertices do | ||
{ | { | ||
vertices pushBack (player getRelPos [_radius, 360 / _numVertices * _i]); | |||
}; | }; | ||
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", | findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", | ||
{ | { | ||
params ["_control"]; | |||
_control drawPolygon [vertices, [0,0,1,1]]; | |||
}];</ | }]; | ||
</sqf> | |||
|seealso= [[drawEllipse]] [[drawIcon]] [[drawLine]] [[drawRectangle]] [[drawArrow]] [[drawTriangle]] [[inPolygon]] | |seealso= [[drawEllipse]] [[drawIcon]] [[drawLine]] [[drawRectangle]] [[drawArrow]] [[drawTriangle]] [[inPolygon]] | ||
}} | }} |
Revision as of 09:48, 13 May 2022
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
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