drawTriangle: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "|= |p4=" to "|PARAMETER3= |p4=")
No edit summary
 
(49 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Command|Comments=
{{RV|type=command
____________________________________________________________________________________________


| arma3 |Game name=
|game1= arma3
|1.76|Game version=
|version1= 1.76
____________________________________________________________________________________________


| Draws a single triangle or multiple triangles on the map. Triangle is defined by 3 positions of its verticies: p0, p1, p2 in a single array ['''p0''', '''p1''', '''p2''']. Next 3 positions in the same array [p0, p1, p2, '''p0''', '''p1''', '''p2'''] will be used to draw second triangle, another 3 positions [p0, p1, p2, p0, p1, p2, '''p0''', '''p1''', '''p2'''] to draw 3rd and so on. <br><br>
|gr1= GUI Control - Map
{{Informative | When <tt>fill</tt> param is absent or is an empty string "", the triangle is drawn with lines of the color set in <tt>color</tt> param. In order to draw color filled triangle of the same color as <tt>color</tt> param, set <tt>fill</tt> param to opaque white procedural texture<tt>"#(rgb,1,1,1)color(1,1,1,1)"</tt>.}}|DESCRIPTION=
____________________________________________________________________________________________


| map '''drawTriangle''' [vertices, color, fill] |SYNTAX=
|descr= [[File:drawTriangle.jpg|right|250px]]
Draws one to multiple triangles on the map.
{{Feature | informative | When {{hl|fill}} param is absent or is an empty string "", the triangle is drawn with lines of the color set in {{hl|color}} param.
In order to draw color-filled triangle of the same color as {{hl|color}} param, set {{hl|fill}} param to opaque white procedural texture{{hl|"#(rgb,1,1,1)color(1,1,1,1)"}}.}}


|p1= map: [[Control]] - map control |PARAMETER1=
|s1= map [[drawTriangle]] [vertices, color, fill]


|p2= [vertices, color, fill]: [[Array]]
|p1= map: [[Control]] - map control
|p3= vertices: [[Array]] of triangle(s) vertices in multiple of 3s [p0, p1, p2(, p0, p1, p2,....)], where vertex position (p) is in format [x,y] or [x,y,z], in which case z is ignored |PARAMETER3=


|p4= color: [[Array]] - color in format: [r,g,b,a]|=
|p2= vertices: [[Array]] of [[Position]]s - triangle(s) vertices in multiple of 3, see {{Link|#Example 1}} - if [[Position#Introduction|Position3D]] is provided for a vertex, its z value is ignored
|p5= fill (Optional): [[String]] - fill texture file or [[Procedural_Textures]]. See note in description for more info. |=


| [[Nothing]]
|p3= color: [[Array]] in format [[Color|Color (RGBA)]]


<br><br>[[Image:drawTriangle.jpg|250px]]|RETURNVALUE=
|p4= fill: [[String]] - (Optional, default {{hl|""}}) fill texture file or [[Procedural Textures]]. See note in description for more info.
____________________________________________________________________________________________


|x1= <code>[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlAddEventHandler]] ["Draw",  
|r1= [[Nothing]]
 
|x1= <sqf>
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",  
{
{
_this [[select]] 0 [[drawTriangle]]
_this select 0 drawTriangle  
[
[
[
[
[[player]] [[getRelPos]] [100, 0],
// triangle 1 start
[[player]] [[getRelPos]] [100, -135],
player getRelPos [100, 0],
[[player]] [[getRelPos]] [100, 135]
player getRelPos [100, -135],
player getRelPos [100, 135]
// triangle 1 end
],
],
[1,0,0,0.5],
[1,0,0,0.5],
"#(rgb,1,1,1)color(1,1,1,1)"
"#(rgb,1,1,1)color(1,1,1,1)"
];
];
}];</code>|EXAMPLE1=
}];
 
</sqf>
 
 
| [[drawArrow]], [[drawEllipse]], [[drawIcon]], [[drawLine]], [[drawPolygon]], [[drawRectangle]] |SEEALSO=


|seealso= [[drawArrow]] [[drawEllipse]] [[drawIcon]] [[drawLine]] [[drawPolygon]] [[drawRectangle]] [[drawXPolygon]]
}}
}}


<h3 style="display:none">Notes</h3>
{{Note
<dl class="command_description">
|user= Killzone_Kid
 
|timestamp= 20170716153600
</dl>
|text= Example [https://www.youtube.com/watch?v{{=}}gSiuLdUeq0M YouTube video]
 
<spoiler>
<h3 style="display:none">Bottom Section</h3>
<sqf>
 
ctrl = findDisplay 12 displayCtrl 51;
[[Category:Scripting Commands|DRAWTRIANGE]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
 
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on July 16, 2017 - 15:36 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note">Example youtube video: [https://www.youtube.com/watch?v=gSiuLdUeq0M] <code>_ctrl = findDisplay 12 displayCtrl 51;
_ctrl setVariable ["data", [1, "#(rgb,1,1,1)color(1,1,1,1)", 1000, position player,  
_ctrl setVariable ["data", [1, "#(rgb,1,1,1)color(1,1,1,1)", 1000, position player,  
{
{
Line 95: Line 85:
}];
}];


openMap true;</code>
openMap true;
</dd>
</sqf>
</dl>
</spoiler>
<!-- DISCONTINUE Notes -->
}}


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Killzone_Kid
<dd class="notedate">Posted on November 13, 2018 - 21:05 (UTC)</dd>
|timestamp= 20181113210500
<dt class="note">[[User:killzone_kid|killzone_kid]]</dt>
|text= Drawing holes ({{Link|https://www.youtube.com/watch?v{{=}}XZRtXsBFLAg|video}}):
<dd class="note">
<spoiler>
Drawing holes (video [https://www.youtube.com/watch?v=XZRtXsBFLAg]): <code>t = time;
<sqf>
t = time;
i = 0;
i = 0;
tex = "#(rgb,1,1,1)color(1,1,1,0.5)";
tex = "#(rgb,1,1,1)color(1,1,1,0.5)";
Line 156: Line 147:


openMap true;
openMap true;
mapAnimAdd [0, 0.15, [500,500,0]];  
mapAnimAdd [0, 0.15, [500,500,0]];
mapAnimCommit;</code>
mapAnimCommit;
</dd>
</sqf>
</dl>
</spoiler>
<!-- DISCONTINUE Notes -->
}}

Latest revision as of 22:36, 1 November 2024

Hover & click on the images for description

Description

Description:
drawTriangle.jpg

Draws one to multiple triangles on the map.

When fill param is absent or is an empty string "", the triangle is drawn with lines of the color set in color param. In order to draw color-filled triangle of the same color as color param, set fill param to opaque white procedural texture"#(rgb,1,1,1)color(1,1,1,1)".
Groups:
GUI Control - Map

Syntax

Syntax:
map drawTriangle [vertices, color, fill]
Parameters:
map: Control - map control
vertices: Array of Positions - triangle(s) vertices in multiple of 3, see Example 1 - if Position3D is provided for a vertex, its z value is ignored
color: Array in format Color (RGBA)
fill: String - (Optional, default "") fill texture file or Procedural Textures. See note in description for more info.
Return Value:
Nothing

Examples

Example 1:
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { _this select 0 drawTriangle [ [ // triangle 1 start player getRelPos [100, 0], player getRelPos [100, -135], player getRelPos [100, 135] // triangle 1 end ], [1,0,0,0.5], "#(rgb,1,1,1)color(1,1,1,1)" ]; }];

Additional Information

See also:
drawArrow drawEllipse drawIcon drawLine drawPolygon drawRectangle 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
Killzone_Kid - c
Posted on Jul 16, 2017 - 15:36 (UTC)
Example YouTube video

ctrl = findDisplay 12 displayCtrl 51; _ctrl setVariable ["data", [1, "#(rgb,1,1,1)color(1,1,1,1)", 1000, position player, { params ["_p", "_r", "_a", "_sr", "_ba"]; _sr = _r * 0.382; _pb = _p getPos [_sr, _a + 180]; [ _p getPos [_r, _a], _p getPos [_sr, _a + 36], _p getPos [_sr, _a - 36], _pb, _p getPos [_r, _a - 72], _p getPos [_r, _a + 72], _p getPos [_r, _a - 144], _p getPos [_sr, _a - 108], _pb, _p getPos [_r, _a + 144], _p getPos [_sr, _a + 108], _pb ] }]]; _ctrl ctrlRemoveAllEventHandlers "Draw"; _ctrl ctrlAddEventHandler ["Draw", { _map = _this select 0; _data = _map getVariable "data"; _data params ["_i", "_fill", "_dist", "_pos", "_fn"]; _data set [0, _i + 1]; _size = _i % _dist; if (_size == 0) then { _data set [0, 1]; _data set [1, ["#(rgb,1,1,1)color(1,1,1,1)", ""] select (random 1 < 0.3)]; _data set [2, 250 + round random 750]; }; _alpha = linearConversion [_dist, 0, _dist - _size, 1, 0]; _map drawEllipse [_pos, _size * 2, _size * 2, 0, [0,0,1,_alpha], _fill]; _map drawTriangle [[_pos getPos [_size, -_size], _size, _size] call _fn, [1,0,0,_alpha], _fill]; _map drawTriangle [[_pos getPos [_size, -_size + 120], _size, _size] call _fn, [0,1,0,_alpha], _fill]; _map drawTriangle [[_pos getPos [_size, -_size - 120], _size, _size] call _fn, [1,1,0,_alpha], _fill]; }]; openMap true;

↑ Back to spoiler's top
Killzone_Kid - c
Posted on Nov 13, 2018 - 21:05 (UTC)
Drawing holes (video):

t = time; i = 0; tex = "#(rgb,1,1,1)color(1,1,1,0.5)"; col = [1,1,1,1]; findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { if (time > t) then { col = [random 1, random 1, random 1, 1]; tex = [ "\A3\ui_f\data\map\markerbrushes\vertical_ca.paa", "\A3\ui_f\data\map\markerbrushes\bdiagonal_ca.paa", "\A3\ui_f\data\map\markerbrushes\cross_ca.paa", "\A3\ui_f\data\map\markerbrushes\diaggrid_ca.paa", "\A3\ui_f\data\map\markerbrushes\fdiagonal_ca.paa", "\A3\ui_f\data\map\markerbrushes\grid_ca.paa", "\A3\ui_f\data\map\markerbrushes\horizontal_ca.paa", "#(rgb,1,1,1)color(1,1,1,0.5)" ] select (i % 8); t = time + 0.5; i = i + 1; }; _this select 0 drawTriangle [ [ [0,0],[100,500],[400,400], [0,0],[400,400],[500,100], [0,0],[500,100],[1000,0], [1000,0],[500,100],[600,400], [1000,0],[600,400],[900,500], [1000,0],[900,500],[1000,1000], [1000,1000],[900,500],[600,600], [1000,1000],[600,600],[500,900], [1000,1000],[500,900],[0,1000], [0,1000],[500,900],[400,600], [0,1000],[400,600],[100,500], [0,1000],[100,500],[0,0] ], col, tex ]; _this select 0 drawPolygon [[[0,0,0],[0,1000,0],[1000,1000,0],[1000,0,0]], col]; _this select 0 drawPolygon [[[100,500,0],[400,600,0],[500,900,0],[600,600,0],[900,500,0],[600,400,0],[500,100,0],[400,400,0]], col]; }]; openMap true; mapAnimAdd [0, 0.15, [500,500,0]]; mapAnimCommit;

↑ Back to spoiler's top