When the solution matters

Tips...

4D v11 SQL (Current Version)4D 2004 Solution Accelerators Academic Downloads

4D v11 SQL

Overview 4D Products 4D Maintenance 4D SVG 4D SVG Ressources More information

TESTIMONIAL

"I recently discovered 4D SVG, and in less than a week my hotel management software has found its reservation planning (among other graphic screens) faster, better looking, and ultimately easier to develop than with 4D Draw, which I had been using up until now. Furthermore, my customers can now display everything in full-screen, if they wish, thanks to SVG."


Maurice Michau
Independent Developer

4D SVG

SVG Viewer

4D SVG is a component that takes advantage of 4D v11 SQL's native SVG engine, allowing you to create and manipulate SVG graphics within your 4D applications. With it, you can create, transform, and even animate SVG images, bringing even more versatility to your 4D v11 SQL solutions.

The component provides commands to meet your most frequent graphical needs, giving you access to parameters that will let you create your own SVG graphics, or modify existing SVG files from other sources.

It includes an SVG Viewer that will let you view your SVG files both as an image and as the XML source code. A separate Syntax Palette lists all of the component's commands - logically grouped by theme - which can be dragged and dropped into your 4D methods, along with all of their parameters.

Additionally, 4D SVG includes its own 4D Pop component that gives you access to the functions via the 4D Pop toolbar.

4D SVG in 4D Pop

An exhaustive list of the parameters and commands is available in the 4D SVG documentation, included with the component.

 

What is SVG?

Pie ChartSVG stands for Scalable Vector Graphics. It is an XML-based standard for vector images, maintained under the stewardship of the W3C (World Wide Web Consortium) standards body. It can be used for anything from user interface and Web graphics to large-scale printing applications. Because of its scalability, the same images can be used across all applications.

When dealing with two-dimensional images, there are two types: Raster (or bitmap) graphics that are comprised of hundreds to millions of individual pixels, and vector graphics that are based upon mathematical descriptions using points, lines, curves, and polygons. Because they employ the latter, SVG images can be resized – to be almost limitlessly smaller or larger – with no degradation of quality, like blurring or pixellation.

 

Why use 4D SVG?

Besides being a widely-supported standard, vector graphics can bring tangible benefits to 4D developers.

Lighter

Vector graphics are lightweight and versatile, providing relatively lightweight file sizes. Using smaller graphics files lightens the load on your object library when developing in 4D, resulting in lighter applications when you deploy.

red boxFor example, a very basic image of a simple button could be drawn in SVG as a rectangle comprised of four points, as well as a color defined for the lines and the filling. As a typical JPEG file that's 128 pixels wide, it weighs in at about 1.4 kb. As an SVG file, it's a paltry 400 bytes. This may not seem like a big deal at first. But in projects involving numerous images, the bits and bytes start to add up!

More Scalable

Beyond the file size benefit of vector graphics, the S in SVG stands for "scalable." This means that an image can be resized without any degradation. For comparative purposes, let's look at a slightly more complex graphic in SVG, JPEG, and GIF formats.

smileys - small

At 72 pixels across, these smileys are not significantly discernible. In fact, the GIF version weighs in even lighter than the SVG version at 1 kilobyte. But what happens if we were to simply take these exact same files and enlarge them to 256 pixels wide?

smileys - large

All of a sudden, the extra bytes of SVG are worthwhile! In fact, to have a sharp, clear GIF at this width, the file would have to be 4 KB. And a JPEG file would have to be over 12 KB. The SVG version remains at 1.9 KB, and would continue to work even if you wanted to make it the size of a roadside billboard.

This scalability has two benefits. First, you can use a much smaller graphics file for an image you intend to fill the screen. Secondly, it means you can repeatedly use the same image for multiple purposes - small for icons, medium-sized for general content, and even high resolution for printing. This replaces the need for storing many versions and sizes of the same image in your library for each distinct use.

Programmatic Control

With 4D SVG, size isn't the only factor over which you have complete power.

Because images are based on XML, you can modify each parameter easily from 4D to transform one single image repeatedly.

pentagon

The above illustration, for example, is a single SVG image of a pentagon transformed twice into two very different figures, simply by modifying the points.

Of course, shapeshifting isn't 4D SVG's only talent. Because any text placed in an SVG image is still treated as text, you can repeatedly modify it without the need for multiple files.

4D buttons

Above you have a single file for a graphical button, used several times over with the text modified via 4D SVG.

The component can also be used to create useful animations. For example, a method using 4D SVG's transform, rotate and scale commands can turn an SVG image of an analog clock into a fully functional timepiece.

Analog clock

In this example, there is only one image used - the clock - and 4D SVG commands are used to modify the position of the arms within that image. The second hand ticks forward each second, and the minute and hour hands smoothly advance as time marches on. And because the clock is a vector image, the window can be resized as much as the user likes without any loss of quality.

International | Company | Contact 4D | Site Map | Privacy Policy | © 4D, Inc. 1995-2009 | Change font size: [A] [A] [A] | Print this page | 4D RSS Feeds