Web

Updated in v0.48.

This category of extensions is useful for preparing SVG drawings for use on the Web. There are two submenus. The first is for adding JavaScript controls that enable events on one object to change other objects. The second is for cutting an image into multiple parts for use on web pages with the help of CSS.

JavaScript

This submenu has two entries. The first allows events linked to one object (mouse over, clicking on, etc.) to control the attributes of another object. The second allows events linked to one object to transmit that object's attributes to another. These extensions embed JavaScript into the SVG file. The JavaScript comes from the InkWeb package. To function, the code requires a JavaScript-enabled browser (native support in Firefox, Opera, Safari, Chrome, and Internet Explorer 9, support via plug-in for older versions of Internet Explorer).

Set Attributes

This extension creates the JavaScript so that an action (clicking on, mouse passing over, etc.) with one object changes the attributes of another object. The list of attributes to change is entered, separated by spaces, in the Attribute to set entry box (e.g., fill stroke stroke-width). The action that will cause the change is set in the When the set must be done? drop-down menu. The list of new values is entered, separated by spaces, in the Value to set entry box. The list of values must match the Attributes to set line (e.g., green black 2px). The next option specifies if this action should come before, after, or replace any previously defined actions. The final option determines, in the case where more than two objects are selected, if the first selected object controls all the other selected objects or if the last selected object is controlled by actions on all the other selected objects.

Set Attributes dialog.
The Set Attributes dialog.
JavaScript Set Attributes example.
An example of using the Set Attributes extension to generate JavaScript code. The two objects on the left, the red square and blue circle, were selected in that order. Then the Set Attributes extension was called with the following values: Attribute to set: fill stroke stroke-width, When the set must be done?: on click, Value to set: green black 5px. In a JavaScript enabled browser, clicking on the red square will turn the color of the circle green and set the width of the stroke to 5px as shown on the right.

Transmit Attributes

This extension creates the JavaScript so that an action (clicking on, mouse passing over, etc.) with one object changes specified attributes of another object to have the same value as the first. The list of attributes to change is entered, separated by spaces, in the Attribute to transmit entry box (e.g., fill stroke stroke-width). The action that will cause the change is declared in the When to transmit drop-down menu. The next option specifies if this action should come before, after, or replace any previously defined actions. The final option determines, in the case where more than two objects are selected, if the first selected object controls all the other selected objects or if the last selected object is controlled by actions on all the other selected objects.

Transmit Attributes dialog.
The Transmit Attributes dialog.
JavaScript Transmit Attributes example.
An example of using the Transmit Attributes extension to generate JavaScript code. The two objects on the left, the red square and blue circle, were selected in that order. Then the Transmit Attributes extension was called with the following values: Attribute to transmit: fill, When the transmit must be done?: on click, In a JavaScript enabled browser, clicking on the red square will turn the color of the circle red as shown on the right.

Web Slicer

New in v0.48.

This extension facilitates slicing a drawing into rectangular bitmaps for use in Web pages. It will optionally export CSS and HTML code for use with the bitmaps.

There are two steps in using this extension. First, the Create a slicer rectangle dialog is used to define a set of named rectangles for the areas that are to be exported. Each rectangle can specify a different target format (PNG, JPEG, or GIF) and optionally, a background color. The rectangles are stored in a separate Layer named Web Slicer. After defining the rectangles, the rectangle regions are exported using the Export layout pieces and HTML+CSS code dialog. A third dialog can be used to add attributes in the HTML.

Create a rectangle dialog

The dialog consists of a number of entry boxes for specifying export rectangles. Note that the placement of the rectangle is not defined in this dialog. After clicking the Apply button, a partially opaque rectangle will be created. You move and resize this rectangle to cover the area that should be exported.

  • Name:  Give a name to the export rectangle. The dialog can be used repeatedly with different names to define multiple export regions.

  • Format:  Specify the bitmap format. Different regions can have different formats.

  • DPI:  Resolution of bitmap.

  • Force dimension:  Specify the exact size of the bitmap (in pixels). If specified, the DPI setting is overridden.

  • Background color:  Background color for region. This will not be displayed by Inkscape.

Three tabs allow additional parameters to be specified. Note that the HTML tab specifies attributes that apply to the export rectangle.

Export layout pieces and HTML+CSS code dialog

This dialog allows you to specify where the output files should be stored and if HTML and CSS code should be produced. Note that the HTML and CSS code is not intended to be the final product but instead allows you to quickly check the output and to generate code that can be pasted into other files. Clicking the Apply button does the actual export.

Set a layout group dialog

This dialog allows you to set attributes that apply to the HTML and CSS that apply to the group of bitmaps exported. At least one of the Slicer rectangles must be selected in order to set these attributes.

[Note]Note

All of the attributes applied to the rectangles and HTML export are stored in <svg:desc> tags. These tags are not easy to edit via the XML Editor dialog. It may be easier to edit the SVG file in a text editor.