How to Breathe Life into the SVG Drawings

Sergiy Hrytsay, CAD Engineer

DWG-SVG-drawing conversion

Nowadays, it is difficult to imagine any eye-catching web-site without animation.
However, animated technical drawings are difficult to find. But why can’t we breathe life into general arrangement drawings (GA), piping and instrument diagrams (P&ID) and so on? It would be interesting and more effective to present these drawings dynamically as opposed to statically.

The SVG (Scalable Vector Graphic) format can assist you in solving this issue  of “livening up” your drawing. SVG is a special format, based on XML and designed for representation of 2D images in your browser supported by interactivity and animation. Having only to convert your image previously into the CDR (CorelDraw) or AI (Adobe Illustrator) formats, one can consequently use as many as three popular tools (SMIL, JavaScript and Raphael library) to  make any “dead” image full of life.

Let me start from the simplest way of animating an SVG drawing. It is called Synchronized Multimedia Integration Language or SMIL. It should be noted that SMIL is a part of SVG. It is embedded in the SVG specification. SMIL provides one with a possibility to do the following:

  • animate color attributes;
  • transport or rotate elements;
  • animate the numeric attributes of elements (eg. the value of x-y coordinates);
  • follow a motion path.

Take for example the SVG code where the following animation is used:

Example 1:
<circle cx=”100″ cy=”100″ r=”20″ fill=”red” stroke=”blue” stroke-width=”1″>
<animate attributeName=”r” from=”20″ to=”100″ begin=”0s” dur=”5s” repeatCount=”1″/>

The circle animation starts with a radius of 20px and is increased to 100px during 5 seconds.
On the other hand, if you need to create a more complicated animation, SMIL may run short of the necessary functions. That is why one should look for other ways of animating drawings. JavaScript can be helpful.

JavaScript (JS) is widely used in web programming. You can create your own function for displaying or calculating something. Since SVG is an XML-based standard, we can use JavaScript to produce truly remarkable animation.

Let us illustrate this with this part of the SVG code using JavaScript:

Example 2:
<script type=”text/javascript”> //include javascript
function changeColorIn(evt) //name of the function
{,”fill”,”grey”); //change fill color from white to grey,”fill-opacity”,”0.4″); //change fill-opacity of color from 1 to 0.4
<rect x=”50″ y=”20″ width=”150″ height=”150″ fill=”white” fill-opacity=”1″ stroke =”black” onmouseover=”changeColorIn(evt)”/>
//draw a white rectangle with a black stroke with width=150 and height=150 at x = 50, y = 20

Utilizing JavaScript has, of course, both advantages and disadvantages. The biggest plus of using JS is that the sky is the limit for programmers to create the animation they want. However, a minus of using JS is that programmers have to write manually the specific steps for animating in JS code. As a result, several libraries have been created for optimizing the work related to programming. The most famous library is Raphael.

Raphael is a JavaScript library that displays vector graphics for websites. Raphael supports all of the main internet browsers. One can download the library from the official Raphael site and include it into one’s own web site:

<script src=”…/raphael.js”></script>.

This part of the Raphael code shows initializing of a new document and draws a circle with a radius of 5px with its center placed at x=100, y=100:

Example 3:

var paper = Raphael(10, 50, 320, 200);

// Creates circle at x = 100, y = 100, with radius 5

var circle =, 100, 5);

Since Raphael is based on JS, it has the same functions of interactivity as a mouse click or pushing a button.

Generally speaking, one has a lot of ways of animating an image or a drawing. It can be using SMIL, JavaScript or Raphael. The choice of an animation technique depends only on the complexity of tasks and the professionalism of the programmer.

To learn more about these techniques, don’t hesitate to contact me.


Oil and Gas Asset Data Management

Harness the technology advancements and incorporate the Industry 4.0 into your Oil&Gas business

Windpower Competency Center

Opening the door of Industry 4.0 possibilities


We are ready to help!

Request consultation, ask a question or share your feedback. Just get in touch!

RDS-PP Wizard
RDS-PP Wizard: Efficient RDS-PP Implementation
Windpower Big Data usage enabled through SAP solutions.  It has already been 5 years since...
KICKer Upgrade: Enhancing Classification Even Further
KICKer is being actively used in our projects, therefore, we’ve been constantly working on expanding...
RDS-PP implementation statistics 1-40
RDS-PP Implementation Milestones
Keel has reached a milestone of implementing the RDS-PP T32 standard for more than 10...
Regulatory Compliance in the Oil & Gas Industry
By Vitalii Yeliashevskyi, Senior Engineer Many companies operating on a global scale or those wanting...