drawTriangle: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Move to 1.76 category)
m (Text replacement - "|= |p4=" to "|PARAMETER3= |p4=")
(8 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{Command|Comments=
____________________________________________________________________________________________
____________________________________________________________________________________________


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


| 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>
| 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>
'''NOTE''': 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
{{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
| map '''drawTriangle''' [vertices, color, fill] |SYNTAX=


|p1= map: [[Control]] - map control |= Parameter 1
|p1= map: [[Control]] - map control |PARAMETER1=


|p2= [vertices, color, fill]: [[Array]]
|p2= [vertices, color, fill]: [[Array]]
|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 |=
|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]|=  
|p4= color: [[Array]] - color in format: [r,g,b,a]|=  
|p5= fill (Optional): [[String]] - fill texture file or [[Procedural_Textures]]. See note in description for more info. |=  
|p5= fill (Optional): [[String]] - fill texture file or [[Procedural_Textures]]. See note in description for more info. |=  
Line 21: Line 22:
| [[Nothing]]
| [[Nothing]]


<br><br>[[Image:drawTriangle.jpg|250px]]|= Return value
<br><br>[[Image:drawTriangle.jpg|250px]]|RETURNVALUE=  
____________________________________________________________________________________________
____________________________________________________________________________________________


Line 36: Line 37:
"#(rgb,1,1,1)color(1,1,1,1)"
"#(rgb,1,1,1)color(1,1,1,1)"
];
];
}];</code>|= Example 1
}];</code>|EXAMPLE1=






| [[drawArrow]], [[drawEllipse]], [[drawIcon]], [[drawLine]], [[drawPolygon]], [[drawRectangle]] |= See also
| [[drawArrow]], [[drawEllipse]], [[drawIcon]], [[drawLine]], [[drawPolygon]], [[drawRectangle]] |SEEALSO=


}}
}}
Line 54: Line 55:
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[[Category:Command_Group:_Editor_Control|{{uc:{{PAGENAME}}}}]]


<!-- CONTINUE Notes -->
<!-- CONTINUE Notes -->
Line 96: Line 96:


openMap true;</code>
openMap true;</code>
</dd>
</dl>
<!-- DISCONTINUE Notes -->
<!-- CONTINUE Notes -->
<dl class="command_description">
<dd class="notedate">Posted on November 13, 2018 - 21:05 (UTC)</dd>
<dt class="note">[[User:killzone_kid|killzone_kid]]</dt>
<dd class="note">
Drawing holes (video [https://www.youtube.com/watch?v=XZRtXsBFLAg]): <code>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;</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 00:23, 21 December 2019

Hover & click on the images for description

Description

Description:
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.

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:
Uncategorised

Syntax

Syntax:
map drawTriangle [vertices, color, fill]
Parameters:
map: Control - map control
[vertices, color, fill]: Array
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
color: Array - color in format: [r,g,b,a]
fill (Optional): String - fill texture file or Procedural_Textures. See note in description for more info.
Return Value:
Nothing

drawTriangle.jpg

Examples

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

Additional Information

See also:
drawArrowdrawEllipsedrawIcondrawLinedrawPolygondrawRectangle

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

Notes

Bottom Section

Posted on July 16, 2017 - 15:36 (UTC)
Killzone Kid
Example youtube video: [1] _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;
Posted on November 13, 2018 - 21:05 (UTC)
killzone_kid
Drawing holes (video [2]): 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;