Main Content

Icon Editor

R2026b

Design and create icons for masked blocks

Since R2022b

Description

Use the Icon Editor to create and edit masked block icons in a graphical environment. You can create block icons that change when you modify the underlying block, such as by changing parameter values or resizing the block.

Using Icon Editor, you can:

  • Create icons visually using drawing tools, preset shapes, text, images, and alignment aids, such as grids, smart guides, and rulers.

  • Use Parts to render multiple variations of the same block.

  • Show or hide specific elements in the icon based on conditions derived from block parameters or mask parameters.

  • Dynamically position each element in the icon relative to the position of other elements on the canvas, or based on parameter values.

  • Preview the icon on the Simulink® canvas in various scenarios, such as when horizontally stretching, flipping, or scaling.

You can also create icons by using a script. In the Icon tab of the Mask Editor toolstrip, in the Authoring Mode section, click Drawing Commands. For more information, see Mask Icon Drawing Commands.

Icon Editor Panes

The Icon Editor is organized into these panes to help you design and customize icons in a graphical environment:

  • Toolstrip — Use the Icon tab of the toolstrip of Mask Editor to manage icon settings, file operations, and canvas behavior. These options let you configure how your icon is stored, displayed, and aligned within the editor.

  • Tools Pane — The Tools pane appears on the left side of the Icon Editor. Use the Tools pane to create custom icons by using basic shapes, paths, equations, and other tools.

  • Element Browser Pane — The Element Browser pane appears on the left side of the Icon Editor. Use the Element Browser pane to assign unique names to elements, hide or show them while you make modifications, lock or unlock their positions, arrange elements within groups, delete unwanted elements, and control the stack order to determine how elements overlay one another.

  • Canvas — Use the canvas to visually arrange and edit the graphical elements of your block icon.

  • Icon Properties Pane — The Icon Properties pane appears on the right side of the Icon Editor. Use the Icon Properties pane to view and edit specific attributes of an icon, such as size and visibility conditions.

  • Element Properties Pane — When you select an element in the canvas, the Element Properties pane appears on the right side of the Icon Editor. Use the Element Properties pane to modify the visual characteristics of the selected element, such as its format and behavior in the Simulink Editor.

Key Terminology

Here are some commonly used terms in the Icon Editor:

  • Element — Any single graphical object, such as a line, text, shape, or image that can be placed on the icon editor canvas.

  • Port — A visual reference for block input or output connections, used to align graphical elements or position text labels. Adding or removing ports in the Icon Editor does not add or remove them in a Simulink block.

  • Group — A collection of elements combined into a single unit you can select for easier moving, resizing, or applying shared properties.

Icon Editor view

Open the Icon Editor

To create and edit icons for masked blocks in a graphical environment:

  1. On the Simulink canvas, right-click the block for which you want to create or edit the icon. If the block does not have a mask, select Create Mask. If a mask already exists, select Edit Mask. The Mask Editor opens.

  2. Go to the Icon tab of the Mask Editor.

Examples

expand all

You can use the Icon Editor to define conditions to control the visibility of certain icon parts. The icon can adapt to dynamic behavior based on the block parameters.

Refer to the block Conditional_visibility in the model slexMaskIconEditor. The arrow in the icon is displayed when the mask parameter Show Variable Capacitor is selected. Additionally, the block indicates its charging status as Charged or Discharged, depending on the option selected for the mask parameter Charging Status.

Control Visibility of Icon Elements Using Block Parameters

To create a visibility condition for the capacitor icon:

1. Create a mask on the Subsystem block.

2. In the Parameters & Dialog tab of the Mask Editor, create a check box parameter named VariableCapacitor and a popup parameter named ChargingStatus. Use these mask parameters to create the visibility condition.

3. In the Icon tab, draw the capacitor icon using the available drawing tools.

4. To specify the visibility condition, select the arrow element of the icon. In the Element Properties pane, click Visibility, and then click Condition Builder. From the Condition Type list, select Block Parameters. Select the mask parameter VariableCapacitor, set the condition as Equal to, and then select on. Click Apply to create a JavaScript expression using the specified condition.

5. To display the status of the capacitor, select the text element. In the Element Properties pane, click Visibility, and then click Condition Builder. In Set Visibility Condition, specify the JavaScript expression value@ChargingStatus === 0.

6. To save the icon with the model, in the toolstrip, click Save With Model.

7. Preview the icon in Simulink canvas. Double-click the block Conditional_visibility to open the mask dialog box. Select Show Variable Capacitor and then click OK. Observe that the arrow element is visible in the icon.

Designing block icons with multiple elements can be complex. When you design block icons using parts, you can:

  • Break the icon into smaller sections, making it easier to manage and edit.

  • Reuse common elements across multiple parts to render multiple variations.

  • Show or hide specific sections of the icon based on block parameters.

  • Organize and layer elements to control which elements appear above or below others. This capability makes the stacking order clearer and reduces complexity when working with multiple elements.

Consider a masked Subsystem block with the popup parameter set to portSelection with the prompt No.of Ports. The block icon changes based on the value you select for No. of Ports in the Block Parameters dialog box. If you specify the No. of Ports as 3, an image of a three-switch port appears on the block icon. If you specify No. of Ports as 4, an image of a four-switch port appears on the block icon.

To create block icon variations using parts:

1. Create a mask on the Subsystem block.

2. In the Mask Editor, in the Controls pane, click Popup to create a popup parameter. In the Property Editor pane, double-click the cell to the right of Type options and select Options with custom values. Add two rows, specify both the Description and Value for the first row as 3, and specify both the Description and Value for the second row as 4. Click Save.

3. Click the Icon tab. Draw the icon image shown.

4. Pin this part to make it the base part of the block mask icon. In the Element Browser, click the Pin icon to make this part the base part of the block mask icon. Elements in the base part appear in all other parts, so you do not need to replicate icon elements.

Note: You cannot modify the elements of the base part and their positions in other parts.

5. To create a new icon part, click the plus sign in the Element Browser. Use the graphical drawing tools to draw an icon with four-switch port elements. Double-click the part name to rename the part as Four_switch_port.

6. Click the duplicate icon part to duplicate the Four_switch_port part. Modify the duplicated part to show a three-switch port. Rename the part as Three_switch_port.

7. To control when a particular part appears as the block icon, enter conditions based on the corresponding block parameters by clicking Set visibility condition in the Element Browser. In the Element Properties pane, click Visibility, and then click Condition Builder. From the Condition Type list, select Block Parameters. Set the parameter to portSelection, the condition to Equal to, and the value to 3 for a three-switch port. Similarly, set the condition for a four-switch port, where the portSelection is equal to 4. Click Apply.

8. Save the mask. In the mask dialog box, change the value of the No. of Ports parameter. Observe how the block icon changes based on the value you select for the parameter.

Use Parts to Design Complex Block Icon and Preview Variations

You can design complex block icons using icon parts and combine the parts based on parameter conditions. For example, refer to the Integrator_block block in the model slexMaskIconEditor. Each element in the icon of the Integrator_block block is designed as an individual part, and these parts are combined based on the visibility condition specified for each part. These conditions help to avoid a cluttered canvas.

This image shows some of the Integrator_block icon variations based on visibility conditions. For example, the parts Vertical_1ByS and Either_symbol are combined to form an icon variation with the conditions blockHeight>=25, WrapState="ON", and ExternalReset="either".

Preview the variations of the icon on Simulink® canvas. The preview options Parameter Variations and Width Height Variations are available at the bottom of the Simulink canvas.

To view all the permutations of the integer block based on parameters and conditional visibility, click Parameter Variations and then Width Height Variations.

You can anchor block icon elements at a specific position or relative to other icon elements on the canvas using relative positioning. Relative positioning reduces manual adjustments when you resize or modify icons and help maintain consistent alignment and spacing.

Refer to the block Relative_position in the model slexMaskIconEditor.

To position the elements on the block Relative_position:

1. Create a mask on the Subsystem block.

2. On the Parameters & Dialog tab, create a check box parameter named showLabel.

3. Click the Icon tab and design the icon.

You can group elements to manage multiple elements as a single unit, so you can move, resize, or modify them together. For example, you can group elements related to the Gaussian curve.

4. In the Element Browser pane, select the Gaussian element group. In the Element Properties pane, in the Relative Position section, click Edit Custom, and then set the appropriate condition for Vertical Center.

5. Save the icon and save the mask. Double-click the block Relative_position. In the mask dialog box, select Show Label, and observe that the text Gaussian Curve appears as a label on the block. The curve automatically adjusts its position to prevent any overlap with the label.

In a Simulink® block diagram, each block represents a component in the system. Instead of manually labeling the value on each block, you can use the Icon Editor to display the value of the parameter on the block itself to improve readability and reduce errors during model validation and debugging. When you bind a text element to a parameter, any change in the value of the parameter is reflected immediately on the block. You can also modify the value of a parameter on the block directly instead of modifying the parameter in the mask dialog box.

Refer to the block Force in the example model slexMaskIconEditor.

Parameterize Text

To parameterize text on the Force block icon:

1. Create a mask on the Subsystem block.

2. On the Parameters & Dialog tab, create three mask parameters: mass, acceleration, and force.

3. Write mask initialization and parameter callback code to calculate the force using the values of mass and acceleration.

4. Click the Icon tab. Design the icon using the text elements for labels mass, acceleration, and force. Place an Expression Text element next to each label for values.

Note: If you want to edit the value of the block parameter in the block icon itself, select Allow editing on block.

5. Follow the preceding steps to parameterize acceleration and force.

6. Save the mask.

Double-click the block Force, modify the values of mass and acceleration in the mask dialog box, and observe the results.

You can create a block icon that dynamically changes size when you resize the block. When you resize the block, the element that fits within the new size is displayed as the block icon. The image is neither shrunk nor cropped, instead a clear and readable version of the icon always appears, ensuring visibility and readability regardless of the size of the block.

Refer to the block First_fit in the model slexMaskIconEditor. Resize the block and observe the text displayed on the block icon. The biggest size contains the matrix values and the smallest size contains the index K of the matrix.

To design icon similar to the block Layout_Constraints follow these steps:

1. Create a mask on the Subsystem block.

2. Click the Icon tab, in the icon canvas, insert the equation tool and specify the LaTeX equation \pmatrix{0 & 1 & 2 & 3 \cr 4 & 5 & 6 & 7 \cr 8 & 9 & 0 & 1} and \pmatrix{3 \times 4} to display the values and dimension of the matrix respectively. Create a text element K to display the index of the matrix.

3. Select all the three elements, right-click and select Convert to First Fit.

This groups the selected elements and only the elements that fit the icon size are displayed.

4. Save the icon and save the mask.

Resize the block and observe the text displayed on the block icon.

You can automatically repeat elements across multiple ports in a masked block icon without having to manually repeat the element at each port, which avoids clutter on the canvas. In the example model slexMaskGraphicalIconEditor.slx, refer to the block Auto_repeat, where the circle element repeats on each port on the left side of the block, and the rectangle element repeats on each port of the right side of the block.

To repeat the icon element across multiple ports:

1. Create a mask on the block.

2. Click the Icon tab.

3. Create a rectangle element to the right of the canvas.

4. Select the rectangle element. To repeat the element on the right pane, in the Element Properties pane, under Dynamic Port Elements, select Right Ports.

Repeat the circle element on the left ports. In the Element Properties pane, under Dynamic Port Elements, select Left Ports.

Look inside the Auto_Repeat Subsystem block. Add one or more In or Out ports and observe the changes.

You can automatically increment a text element that is bound to a port. For example, if you bind a text element labeled a to a left port and want the text to increment automatically across other left ports, set Generation Algorithm to Increment. The labels for the other left ports will appear as a1, a2, and so on.

You can use the Icon Editor to create block icons for Simscape® blocks.

1. Open the model slexMaskGraphicalIconEditor_simscape.

     open_system("slexMaskGraphicalIconEditor_simscape");

2. To launch the Icon Editor double-click Launch Icon Editor block or use this command in the MATLAB Command Window:

     Simulink.IconEditor.open(gcb);

3. For more information on using the Icon Editor to view and edit block icons for Simscape blocks, see Using the Icon Editor in Customizing the Block Name and Appearance (Simscape).

Parameters

expand all

Icon File

Displays the name of the icon file.

If enabled, the icon file is saved with the model. Otherwise, the icon file is saved as an external file on disk.

Rename and save the masked block icon.

Import an icon or icon parts into the masked block.

  • Import Icon Part — Import single or multiple parts into the icon.

  • Import Icon — Import a new icon.

Remove the icon from the block. If the icon is saved with the model, the icon file is also removed.

Drawing Aids

Select this option to turn on canvas grid which can be used to organize, align, and size visual elements on your canvas.

Select this option to snap an element to the nearest grid line for accurate alignment.

Select this option to display port grids to align elements with respect to the ports.

Adjust spacing between the grid lines.

Set a color for the grid lines.

Use smart guides to align or position an element relative to other elements in the icon or the canvas.

Use rulers for precise positioning of an element.

Parts

Use Add to add a part to the icon.

Use Duplicate to copy the selected part of the icon.

Use Delete to remove the selected part of the icon.

Use View All to view various parts of the icon.

Configuration

Define the number of ports on the left, right, top, and bottom of the icon. These elements are only visual guides and do not add real ports to the actual block.

Conditions

Display all the visibility conditions available on a block icon. You can also edit these conditions.

Preview

Check icon behavior across different block sizes and orientations.

Preview In Model provides you these functionalities:

  • Visualize the icon with original size, without any transformations, and after transformations such as scaling, horizontal and vertical stretching, and different rotations and orientations.

  • Visualize the icon with parameter- and width- or height- based variations.

Element Toolstrip

Define the visual appearance of icon elements, including outline color, stroke width, text formatting, and fill color.

Manage element grouping and orientation. You can combine multiple elements into one unit, separate grouped elements, flip elements horizontally or vertically, or control the layering of elements on the canvas.

  • Group — Combine multiple elements into one unit.

  • Ungroup — Separate grouped elements.

  • Flip Horizontal — Mirror the element left to right.

  • Flip Vertical — Mirror the element top to bottom.

  • Send Backward — Move the element one layer back.

  • Send to Back — Move the element to the back layer.

  • Bring Forward — Move the element one layer forward.

  • Bring to Front — Move the element to the front layer.

Position multiple elements relative to each other by aligning their edges or centers.

Evenly distribute elements vertically or horizontally.

Associate icon elements with block ports.

  • Dynamic Port Elements — Expands the Auto Generate Port Labels section within the Element Properties pane.

  • Bind Port — Bind port labels and icon elements to a port.

Right-Side Pane

Adjust the shape and position of elements in the canvas. These options are available in the Icon Properties pane:

  • H — Set the height of the canvas.

  • W — Set the width of the canvas.

  • Frame — Select a frame shape for the block, such as rectangle, circle, capsule, triangle, trapezium, hexagon, or None. You can further customize the selected frame by clicking the pencil icon to modify its appearance. Selecting None retains the default shape, and no frame is displayed for the block.

  • Show port labels from block — Set the check-box to display port labels from the blocks inside the mask.

Link to block parameters or JavaScript expressions. These settings enable you to control how values are evaluated, allow direct editing on the block icon, and manage text behavior. This option is available when you select the Expression Text element.

OptionsFunctionality
Evaluate parametersEvaluate the parameter displayed on the block.
Allow editing on blockOption to edit the value of the parameter on the block icon.
Auto Center TextThe text element remains centered on the canvas at all times, regardless of the block size or the content of the text.

Automate the creation and placement of elements such as icons or text labels across multiple block ports. Use these settings to define how elements are repeated, sequenced, or mapped to specific parameters on the left or right side of the block.

OptionSettingFunctionality
Ports Repeat elements on right, left, top, or bottom ports.
Generation AlgorithmIncrement Increment the text element. For example, if the text element is w and you select Increment as the Generation Algorithm, the text element increments to w1, w2, and so on.
Duplicate Duplicate an icon element.
Use Parameter Value Display the parameter value at the ports.
Parameter Name Select the parameter whose value will be displayed at the ports. This option is applicable only to text elements.

Define the position of an element based on a reference element. The positioned element adjusts automatically to maintain its defined position.

  • Position — Select the alignment and element that you want to move or position.

  • Relative to — Choose the alignment and reference element or block boundary that will determine the position of the selected element.

  • With offset — Specify the precise horizontal and vertical distance to maintain between the positioned element and its reference point.

Set how the icon responds to block and canvas changes in the model environment. These settings control rotation behavior, resizing behavior, and background transparency, and to define how stroke widths respond to canvas zooming and block resizing.

Icon Properties Pane

OptionSettingFunctionality
Rotate Rotate the icon along with the block.
ResizeOffIcon retains its original size when the block resizes.
OnIcon resizes to fit the block.
Shrink OnlyIcon resizes to fit to the block while shrinking but not otherwise.
Resize Limit Set the maximum size to which the icon can be resized.
ForegroundAllowChange foreground color of the icon. To change the foreground color, right-click the Simulink canvas and use the context menu option.
DisallowRetain the original color of the canvas on the icon even when the canvas color changes.
Inherit from Ports Use the color of the port associated with this element as the foreground color.
BackgroundAllowChange background color of the icon. You can change the background color by right-clicking the Simulink canvas and using the context menu.
DisallowRetain the original color of the canvas on the icon even when the canvas color changes.
Transparent Use a transparent background for the block. This option is selected by default for Simscape™ blocks.
Normalize Width Set the stroke width of all the elements to one pixel.
Scale with Ports Scale the stroke width of the element by the style of the line that is connected to the port that is associated with the element.
Scale on Zoom Increase the stroke width when the canvas is zoomed in and decrease the stroke width when the canvas is zoomed out.
Scale on ResizeOnScale the stroke linearly on resizing the block.
OffMaintain constant stroke width on resizing the block.
Shrink OnlyScale the stroke linearly when the block shrinks and do not scale when icon is enlarged.

Element Properties Pane

OptionsSettingFunctionality
RotateWith ParentRotate the element with its parent.
Readable Maintain a readable text element. The text appears from left to right or bottom to top without mirroring.
Fixed Maintain the orientation of the element even if the block is rotated.
With PortsRotate the element along with the port.
ResizeOnScale linearly along with parent when the icon is resized.
OffMaintain the size of the element when the icon is resized.
Shrink OnlyShrink the element linearly when its parent shrinks but maintain the size when its parent is enlarged.
Adaptive Scale port labels appropriately along with the block.
Resize Limit Set the maximum size to which the icon can be resized.
Horizontal ScalingOnScale the element horizontally along with the block.
OffMaintain the width of the element.
Shrink Only Shrink the element horizontally when its parent shrinks but maintain the size when its parent is enlarged.
Vertical ScalingOnScale the element vertically along with the block.
OffMaintain the height of the element.
Shrink OnlyShrink the element vertically when its parent shrinks but maintain the size when its parent is enlarged.
Scale on ZoomOnScale the element linearly when the canvas is zoomed.
OffMaintain the size of the element when the canvas is zoomed.
Shrink OnlyShrink the element when the canvas is zoomed out and maintain its size when the canvas is zoomed in.
Normalize WidthInheritInherit the style from the icon. If the element is part of a group, then it inherits the style from its parent element.
OnSet the stroke width of all the elements to one pixel.
Scale with PortsInherit Inherit the style from the icon. If the element is part of a group, then it inherits the style from its parent element.
OnScale the stroke width of the element by the style of the line that is connected to the port that is associated with the element.
Scale On ZoomInherit Inherit the style from the icon. If the element is part of a group, then it inherits the style from its parent element.
OnScale the stroke width of the elements when the canvas is zoomed out. Maintain a constant stroke width when the canvas is zoomed in.
Scale On ResizeInheritInherit the style from the icon. If the element is part of a group, then it inherits the style from its parent element.
OnScale the stroke of the element linearly on resizing the icon.
OffMaintain constant stroke width of the elements on resizing the icon.
Shrink OnlyScale stroke of the elements linearly when the icon shrinks and do not scale when the icon is enlarged.

Left-Side Pane

Draw shapes, lines, and text on the icon editor canvas. Some options in Tools are:

  • Equation — Write equations using LaTeX markup. This tool is similar to the equation tool in MATLAB® and Simulink.

  • Shape Finder — Click the canvas and type the name of a shape that you want to insert. You can use basic shapes, such as Cylinder, Triangle, Axis, or Wave, or predefined shapes from the Electrical, Translational, and Rotational libraries.

  • Edit Shape — Edit all supported shapes, such as rectangles, ellipses, lines, and paths. To edit a shape, select the Edit Shape tool in the fixed palette above the canvas and click an element. All edit points that form the shape appear.

Version History

Introduced in R2022b