drawTriangle: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
Line 61: Line 61:
<dd class="notedate">Posted on July 16, 2017 - 15:36 (UTC)</dd>
<dd class="notedate">Posted on July 16, 2017 - 15:36 (UTC)</dd>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dt class="note">[[User:Killzone Kid|Killzone Kid]]</dt>
<dd class="note"> wip
<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,
{
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;</code>
</dd>
</dd>
</dl>
</dl>
<!-- DISCONTINUE Notes -->
<!-- DISCONTINUE Notes -->

Revision as of 16:37, 16 July 2017

-wrong parameter ("arma3dev") defined!-[[:Category:Introduced with arma3dev version 1.73|1.73]]
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.

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

[[Category:Introduced with arma3dev version 1.73]][[ Category: arma3dev: New Scripting Commands | DRAWTRIANGLE]][[ Category: arma3dev: Scripting Commands | DRAWTRIANGLE]]

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;