Main Content

Draw Mask Icon Using Mask Drawing Commands

Create icons for the masked blocks. You can either create static or dynamic icons. Static icons remain unchanged. Dynamic icons are created with the mask parameters, hence the icon changes with a change in the mask parameters. This example shows how to use drawing commands to create a mask icon.

Draw Static Icon

A static mask icon remains unchanged, independent of the value of the mask parameters.

  1. Select the masked block that requires the icon.

  2. On the Block tab, in the Mask group, click Edit Mask.

  3. In the Icons tab, enter this command in the Icon Drawing commands pane:

    % Use specified image as mask icon
    image('engine.jpg')

    The image file must be on the MATLAB® path.

    For more examples of drawing command syntax, see Icon drawing commands.

    Images in formats .cur, .hdf4, .ico, .pcx, .ras, .xwd, .svg cannot be used as block mask images. However, you can use images in these formats if you wrap the file name in the imread() function and use the RGB triplet. Using the imread() function is not efficient. However, it is still supported for backward compatibility.

Draw Dynamic Icon

A dynamic icon changes with the values of the mask parameters. Use it to represent the purpose of the masked block.

  1. Select the masked block that requires the icon.

  2. On the Block tab, in the Mask group, click Edit Mask.

    The Mask Editor opens.

  3. In the Icon tab, enter this command in the Icon Drawing commands pane. Alternatively, you can click on the commands available in the left pane and fill in the data.

    pos = get_param(gcb, 'Position');
    width = pos(3) - pos(1);
    x = [0, width];
    y = m*x + b;
    % Parameters 'm' and 'b' must be defined in 'Parameters & Dialog' pane.
    plot(x,y)

  4. Under Options, set Icon Units to Pixels.

    The drop-down lists under Options allow you to specify icon frame visibility, icon transparency, drawing context, icon rotation, and port rotation.

  5. Click Apply.

    Note

    If Simulink® cannot evaluate all commands in the Icon Drawing commands pane to generate an icon, three question marks (? ? ?) appear on the mask.

See Mask Display and Initialization Commands for more examples of icon drawing commands. This model shows how to draw:

  • Static mask

  • Dynamic shape mask

  • Dynamic text mask

  • Image mask

Related Topics