drawIcon: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(see also)
m (Eff Local)
 
(88 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma |= Game name
|game1= arma1
|version1= 1.00


|1.00|= Game version
|game2= arma2
____________________________________________________________________________________________
|version2= 1.00


| Draw an icon on the map. The command needs to be called every frame, preferably with "Draw" control event handler [[ctrlAddEventHandler]].
|game3= arma2oa
|version3= 1.50


|= Description
|game4= tkoh
____________________________________________________________________________________________
|version4= 1.00


| map '''drawIcon''' [texture, color, position, width, height, angle, text, shadow, textSize, font, align] |= Syntax
|game5= arma3
|version5= 0.50


|p1= map: [[Control]] |= Parameter 1
|gr1= GUI Control - Map


|p2= texture: [[String]] |=
|eff= local
|p3= color: [[Array]] - [r,g,b,a] |=
|p4= position: [[Position2D]] or [[Position3D]] or [[Object]] |=
|p5= width: [[Number]]|=
|p6= height: [[Number]]|=
|p7= angle: [[Number]]|=
|p8= text: [[String]] |=
|p9= shadow: [[Number]] or [[Boolean]] - 0/false: no shadow, 1: shadow (for text), 2/true: outline (works for text and for icon only if icon angle is 0)|=
|p10= textSize: [[Number]] - (since Arma 3 v0.72)|=
|p11= font: [[String]] - (since Arma 3 v0.72) |=
|p12= align: [[String]] - (since Arma 3 v0.72) "left", "right", "center". Default is "right" |=


| [[Nothing]] |= Return value
|descr= Draws an icon on the map.
As this command needs to be called every frame, it is preferable using the [[User Interface Event Handlers#onDraw|onDraw]] UI Event Handler.
{{Feature|informative|Some useful icons can be found in <sqf inline>configFile >> "CfgVehicleIcons"</sqf>.}}


|x1= <code>[[findDisplay]] 12 [[displayCtrl]] 51 [[ctrlAddEventHandler]] ["Draw", "
|s1= map [[drawIcon]] [texture, color, position, width, height, angle, text, shadow, textSize, font, align<!--, drawSideArrows, offsetX, offsetY-->]
_this [[select]] 0 [[drawIcon]] [
 
'iconStaticMG',
|p1= map: [[Control]]
[1,0,0,1],
 
[[getPos]] [[player]],
|p2= texture: [[String]] - icon texture
24,
 
24,
|p3= color: [[Array]] - text and icon color in format [[Color|Color(RGBA)]]
[[getDir]] [[player]],
 
'Player Vehicle',
|p4= position: [[Object]], [[Array]] format [[Position#Introduction|Position2D]] or [[Position#Introduction|Position3D]]
1,
 
0.03,
|p5= width: [[Number]] - width of the icon (but not the text)
'TahomaB',
 
'right'
|p6= height: [[Number]] - height of the icon (but not the text)
]
 
"];</code>|= EXAMPLE1
|p7= angle: [[Number]] - rotation angle of the icon (but not the text)
____________________________________________________________________________________________
 
|p8= text: [[String]] - (Optional, default "")
 
|p9= shadow: [[Number]] or [[Boolean]] - (Optional, default [[false]]) can be one of:
* 0 ([[false]]): no shadow
* 1: shadow (for text)
* 2 ([[true]]): outline (works for text and for icon only if icon angle is 0)
 
|p10= textSize: [[Number]] - (Optional, default -1) size of the text in UI units
|p10since= arma3 0.72
 
|p11= font: [[String]] - (Optional, default "") text's font
|p11since= arma3 0.72


| [[drawArrow]], [[drawEllipse]], [[drawLine]], [[drawRectangle]], [[drawPolygon]] |= See also
|p12= align: [[String]] - (Optional, default "right") text alignment. Can be:
* "left"
* "right"
* "center"
|p12since= arma3 0.72


}}
<!--


<h3 style="display:none">Notes</h3>
|p13= drawSideArrows: [[Boolean]] - (Optional, default [[false]]) unused
<dl class="command_description">
|p13since= arma3 2.04
<!-- Note Section BEGIN -->


<dd class="notedate">Posted on July 03, 2013 - 15:35
|p14= offsetX: [[Number]] - (Optional, default 0) unused
<dt class="note">'''[[User:Druid|Druid]]'''<dd class="note">Support of paremeters <i>textSize</i>, <i>font</i> and <i>align</i> is in the game since Arma 3 version 0.72.<br/>
|p14since= arma3 2.04


<dd class="notedate">Posted on March 22, 2014
|p15= offsetY: [[Number]] - (Optional, default 0) unused
<dt class="note">'''[[User:Waffle SS.|Waffle SS.]]'''
|p15since= arma3 2.04
<dd class="note">icon will always remain the same width and height, if you want an icon scaled to the map, use:<code>('''sizeInMeters''' * 0.15) * 10^(abs log (ctrlMapScale _ctrl))</code> for width and height (guessimated).
<BR><BR>


<!-- Note Section END -->
-->
</dl>


<h3 style="display:none">Bottom Section</h3>
|r1= [[Nothing]]


[[Category:Scripting Commands|DRAWICON]]
|x1= Red icon with text:
[[Category:Scripting Commands ArmA|DRAWICON]]
<sqf>
[[Category:Scripting Commands ArmA2|{{uc:{{PAGENAME}}}}]]
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {
[[Category:Scripting Commands Arma 3|{{uc:{{PAGENAME}}}}]]
_this select 0 drawIcon [
[[Category:Scripting_Commands_Take_On_Helicopters|{{uc:{{PAGENAME}}}}]]
"iconStaticMG", // custom images can also be used: getMissionPath "\myFolder\myIcon.paa"
[[Category:Command_Group:_GUI_Control|{{uc:{{PAGENAME}}}}]]
[1,0,0,1],
[[Category:Command_Group:_Editor_Control|{{uc:{{PAGENAME}}}}]]
getPosASLVisual player,
24,
24,
getDirVisual player,
"Player Vehicle",
1,
0.03,
"TahomaB",
"right"
]
}];
</sqf>


<!-- CONTINUE Notes -->
|x2= Green text only:
<dl class="command_description">
<sqf>
<dd class="notedate">Posted on July 20, 2014 - 16:59 (UTC)</dd>
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", {
<dt class="note">[[User:AgentRevolution|AgentRevolution]]</dt>
_this select 0 drawIcon [
<dd class="note">
"#(rgb,1,1,1)color(1,1,1,1)",
If you want only text with no icon, you can use "#(argb,8,8,3)color(0,0,0,0)" as texture.
[0,1,0,1],
</dd>
player,
</dl>
0,
<!-- DISCONTINUE Notes -->
0,
0,
name player
]
}];
</sqf>


<!-- CONTINUE Notes -->
|seealso= [[drawArrow]] [[drawEllipse]] [[drawLine]] [[drawRectangle]] [[drawPolygon]] [[drawTriangle]]
<dl class="command_description">
}}
<dd class="notedate">Posted on July 7, 2015 - 21:27 (UTC)</dd>
<dt class="note">[[User:Waffle SS.|Waffle SS.]]</dt>
<dd class="note">
Be careful when using this command. Unlike map markers, the draw commands can decrease your framerate.
</dd>
</dl>
<!-- DISCONTINUE Notes -->


<!-- CONTINUE Notes -->
{{Note
<dl class="command_description">
|user= Benargee
<dd class="notedate">Posted on January 4, 2016 - 05:41 (UTC)</dd>
|timestamp= 20160104054100
<dt class="note">[[User:Benargee|Benargee]]</dt>
|text= {{arma3}} 1.54<br>
<dd class="note">
This command does not seem to play nice with [[onEachFrame]]. It seems to draw on the main screen while maintaing position relative to the map position<br>
Arma 3 1.54<br/>
This command doesn't seem to play nice with [[onEachFrame]]. It seems to draw on the main screen while maintaing position relative to the map position<br/>
Example:
Example:
<code>[[onEachFrame]] {
<sqf>
[[findDisplay]] 12 [[displayCtrl]] 51 [[drawIcon]] ['iconStaticMG',[1,0,0,1],[[getPos]] [[player]],24,24,[[getDir]] [[player]],'Player Vehicle',1,0.03,'TahomaB','right'];
onEachFrame {
};</code>
findDisplay 12 displayCtrl 51 drawIcon ['iconStaticMG', [1,0,0,1], getPosASL player, 24, 24, getDir player, 'Player Vehicle', 1, 0.03, 'TahomaB', 'right'];
</dd>
};
</dl>
</sqf>
<!-- DISCONTINUE Notes -->
}}
 
{{Note
|user= Leopard20
|timestamp= 20220509193407
|text= The icon size always stays the same, even after zooming in/out. To make the icon get bigger with map zoom, use this for width and height size:
<sqf>
private _scale = 6.4 * worldSize / 8192 * ctrlMapScale _map;
private _size = _sizeInMeters / _scale;
</sqf>
For example, the following icon has an exact size of 50 meters on the map, even after zooming in/out:
<sqf>
private _scale = 6.4 * worldSize / 8192 * ctrlMapScale _map;
private _size = 50 / _scale;
_map drawIcon ["iconStaticMG", [1,0,0,1], getPosASLVisual player, _size, _size, 0]
</sqf>
}}

Latest revision as of 10:48, 16 September 2023

Hover & click on the images for description

Description

Description:
Draws an icon on the map. As this command needs to be called every frame, it is preferable using the onDraw UI Event Handler.
Some useful icons can be found in configFile >> "CfgVehicleIcons".
Groups:
GUI Control - Map

Syntax

Syntax:
map drawIcon [texture, color, position, width, height, angle, text, shadow, textSize, font, align]
Parameters:
map: Control
texture: String - icon texture
color: Array - text and icon color in format Color(RGBA)
position: Object, Array format Position2D or Position3D
width: Number - width of the icon (but not the text)
height: Number - height of the icon (but not the text)
angle: Number - rotation angle of the icon (but not the text)
text: String - (Optional, default "")
shadow: Number or Boolean - (Optional, default false) can be one of:
  • 0 (false): no shadow
  • 1: shadow (for text)
  • 2 (true): outline (works for text and for icon only if icon angle is 0)
since Arma 3 logo black.png0.72
textSize: Number - (Optional, default -1) size of the text in UI units
since Arma 3 logo black.png0.72
font: String - (Optional, default "") text's font
since Arma 3 logo black.png0.72
align: String - (Optional, default "right") text alignment. Can be:
  • "left"
  • "right"
  • "center"
Return Value:
Nothing

Examples

Example 1:
Red icon with text:
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { _this select 0 drawIcon [ "iconStaticMG", // custom images can also be used: getMissionPath "\myFolder\myIcon.paa" [1,0,0,1], getPosASLVisual player, 24, 24, getDirVisual player, "Player Vehicle", 1, 0.03, "TahomaB", "right" ] }];
Example 2:
Green text only:
findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { _this select 0 drawIcon [ "#(rgb,1,1,1)color(1,1,1,1)", [0,1,0,1], player, 0, 0, 0, name player ] }];

Additional Information

See also:
drawArrow drawEllipse drawLine drawRectangle drawPolygon drawTriangle

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
Benargee - c
Posted on Jan 04, 2016 - 05:41 (UTC)
Arma 3 1.54
This command does not seem to play nice with onEachFrame. It seems to draw on the main screen while maintaing position relative to the map position
Example:
onEachFrame { findDisplay 12 displayCtrl 51 drawIcon ['iconStaticMG', [1,0,0,1], getPosASL player, 24, 24, getDir player, 'Player Vehicle', 1, 0.03, 'TahomaB', 'right']; };
Leopard20 - c
Posted on May 09, 2022 - 19:34 (UTC)
The icon size always stays the same, even after zooming in/out. To make the icon get bigger with map zoom, use this for width and height size:
private _scale = 6.4 * worldSize / 8192 * ctrlMapScale _map; private _size = _sizeInMeters / _scale;
For example, the following icon has an exact size of 50 meters on the map, even after zooming in/out:
private _scale = 6.4 * worldSize / 8192 * ctrlMapScale _map; private _size = 50 / _scale; _map drawIcon ["iconStaticMG", [1,0,0,1], getPosASLVisual player, _size, _size, 0]