{"name":"drawTriangle","operator":null,"title":"drawTriangle","type":"command","url":"https://community.bistudio.com/wiki/drawTriangle","revid":377356,"updated":"2026-01-02T06:40:21Z","groups":["GUI Control - Map"],"status":"ok","replaced_by":[],"games":[{"game":"arma3","name":"Arma 3","version":"1.76"}],"since":{"game":"arma3","name":"Arma 3","version":"1.76"},"arma3_since":"1.76","branch":null,"locality":{"argument":null,"effect":null,"server_exec":false},"exec":null,"description":"Draws one to multiple triangles on the map.\n\n> [!NOTE]\n> When `fill` param is absent or is an empty string \"\", the triangle is drawn with lines of the color set in `color` param.\n> 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)\"`.","syntaxes":[{"syntax":"map drawTriangle [vertices, color, fill]","since":null,"effect":null,"exec":null,"params":[{"name":"map","type":"Control","optional":false,"default":null,"description":"map control","types":["Control"],"since":null,"text":"map: Control - map control"},{"name":"vertices","type":"Array of Positions","optional":false,"default":null,"description":"triangle(s) vertices in multiple of 3, see #Example 1 - if Position3D is provided for a vertex, its z value is ignored","types":["Array","Position"],"since":null,"text":"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"},{"name":"color","type":null,"optional":false,"default":null,"description":"Color (RGBA)","types":["Color"],"since":null,"text":"color: Color (RGBA)"},{"name":"fill","type":"String","optional":true,"default":"`\"\"`","description":"fill texture file or Procedural Textures. See note in description for more info.","types":["String"],"since":null,"text":"fill: String - (Optional, default `\"\"`) fill texture file or Procedural Textures. See note in description for more info."}],"returns":{"type":"Nothing","types":["Nothing"],"description":null,"text":"Nothing"},"form":"binary","operator":null,"left":{"text":"map","types":["Control"]},"right":{"text":"[vertices, color, fill]","types":["Array"]}}],"examples":[{"text":"```sqf\nfindDisplay 12 displayCtrl 51 ctrlAddEventHandler [\"Draw\", \n{\n    _this select 0 drawTriangle \n    [\n        [\n            // triangle 1 start\n            player getRelPos [100, 0],\n            player getRelPos [100, -135],\n            player getRelPos [100, 135]\n            // triangle 1 end\n        ],\n        [1,0,0,0.5],\n        \"#(rgb,1,1,1)color(1,1,1,1)\"        \n    ];\n}];\n```","code":["findDisplay 12 displayCtrl 51 ctrlAddEventHandler [\"Draw\", \n{\n\t_this select 0 drawTriangle \n\t[\n\t\t[\n\t\t\t// triangle 1 start\n\t\t\tplayer getRelPos [100, 0],\n\t\t\tplayer getRelPos [100, -135],\n\t\t\tplayer getRelPos [100, 135]\n\t\t\t// triangle 1 end\n\t\t],\n\t\t[1,0,0,0.5],\n\t\t\"#(rgb,1,1,1)color(1,1,1,1)\"\t\t\n\t];\n}];"]}],"multiplayer":null,"problems":null,"aliases":[],"see_also":["drawArrow","drawEllipse","drawIcon","drawLine","drawPolygon","drawRectangle","drawXPolygon"],"notes":[{"user":"Killzone_Kid","date":"2017-07-16T15:36:00Z","text":"Example [YouTube video](https://www.youtube.com/watch?v=gSiuLdUeq0M)\n\n```sqf\nctrl = findDisplay 12 displayCtrl 51;\n_ctrl setVariable [\"data\", [1, \"#(rgb,1,1,1)color(1,1,1,1)\", 1000, position player, \n{\n    params [\"_p\", \"_r\", \"_a\", \"_sr\", \"_ba\"];\n    _sr = _r * 0.382;\n    _pb = _p getPos [_sr, _a + 180];\n    [\n        _p getPos [_r, _a], _p getPos [_sr, _a + 36], _p getPos [_sr, _a - 36],\n        _pb, _p getPos [_r, _a - 72], _p getPos [_r, _a + 72],\n        _p getPos [_r, _a - 144], _p getPos [_sr, _a - 108], _pb,\n        _p getPos [_r, _a + 144], _p getPos [_sr, _a + 108], _pb\n    ]\n}]];\n\n_ctrl ctrlRemoveAllEventHandlers \"Draw\";\n_ctrl ctrlAddEventHandler [\"Draw\", \n{\n    _map = _this select 0;\n    _data = _map getVariable \"data\";\n    _data params [\"_i\", \"_fill\", \"_dist\", \"_pos\", \"_fn\"];\n    _data set [0, _i + 1];\n    _size = _i % _dist;\n    if (_size == 0) then \n    {\n        _data set [0, 1];\n        _data set [1, [\"#(rgb,1,1,1)color(1,1,1,1)\", \"\"] select (random 1 < 0.3)];\n        _data set [2, 250 + round random 750];\n    };\n    _alpha = linearConversion [_dist, 0, _dist - _size, 1, 0];\n    _map drawEllipse [_pos, _size * 2, _size * 2, 0, [0,0,1,_alpha], _fill];\n    _map drawTriangle [[_pos getPos [_size, -_size], _size, _size] call _fn, [1,0,0,_alpha], _fill];\n    _map drawTriangle [[_pos getPos [_size, -_size + 120], _size, _size] call _fn, [0,1,0,_alpha], _fill];\n    _map drawTriangle [[_pos getPos [_size, -_size - 120], _size, _size] call _fn, [1,1,0,_alpha], _fill];\n}];\n\nopenMap true;\n```"},{"user":"Killzone_Kid","date":"2018-11-13T21:05:00Z","text":"Drawing holes ([video](https://www.youtube.com/watch?v=XZRtXsBFLAg)):\n\n```sqf\nt = time;\ni = 0;\ntex = \"#(rgb,1,1,1)color(1,1,1,0.5)\";\ncol = [1,1,1,1];\n\nfindDisplay 12 displayCtrl 51 ctrlAddEventHandler [\"Draw\", \n{\n    if (time > t) then\n    {\n        col = [random 1, random 1, random 1, 1];\n        tex = [    \n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\vertical_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\bdiagonal_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\cross_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\diaggrid_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\fdiagonal_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\grid_ca.paa\",\n            \"\\A3\\ui_f\\data\\map\\markerbrushes\\horizontal_ca.paa\",\n            \"#(rgb,1,1,1)color(1,1,1,0.5)\"\n        ] \n        select (i % 8);\n        \n        t = time + 0.5;\n        i = i + 1;\n    };\n    \n    _this select 0 drawTriangle \n    [\n        [\n            [0,0],[100,500],[400,400],\n            [0,0],[400,400],[500,100],\n            [0,0],[500,100],[1000,0],\n            [1000,0],[500,100],[600,400],\n            [1000,0],[600,400],[900,500],\n            [1000,0],[900,500],[1000,1000],\n            [1000,1000],[900,500],[600,600],\n            [1000,1000],[600,600],[500,900],\n            [1000,1000],[500,900],[0,1000],\n            [0,1000],[500,900],[400,600],\n            [0,1000],[400,600],[100,500],\n            [0,1000],[100,500],[0,0]\n        ],\n        col, \n        tex\n    ];\n    \n    _this select 0 drawPolygon [[[0,0,0],[0,1000,0],[1000,1000,0],[1000,0,0]], col];\n    _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];\n}];\n\nopenMap true;\nmapAnimAdd [0, 0.15, [500,500,0]];\nmapAnimCommit;\n```"}],"categories":["Arma 3: New Scripting Commands","Arma 3: Scripting Commands","Command Group: GUI Control - Map","Introduced with Arma 3 version 1.76","Scripting Commands"]}