Go Back   Wiki NewForum | Latest Entertainment News > Career Forum & Tips > Tech Forum & Tutorial > IT Forum


SVG Tutorial


Reply
Views: 6528  
Thread Tools Rate Thread
  #11  
Old 05-03-2009, 04:00 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default SVG Gaussian Blur

An SVG Filter must be defined within a tag.
Gaussian Blur

The tag is used to define an SVG filter. The tag has a required id attribute which identifies which filter will be applied to the graphic.


The tag must be nested within a tag. The tag is short for definitions and it allows definition of special elements such as filter.


Copy the following code into Notepad and save the file as "filter1.svg". Place the file in your Web directory:



"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">



style="fill:#ff0000;stroke:#000000;
stroke-width:2;filter:url(#Gaussian_Blur)"/>

Code explanation:
  • The id attribute of the tag defines a unique name for the filter (the same filter can be used by many elements in the document)
  • The filter:url(#Gaussian_Blur) property is used to link an element to a filter. The # character must be used when linking to the filters id
  • The filter effect is defined with the tag. The fe prefix is used for all filters
  • The stdDeviation attribute of the tag defines the amount of the blur
  • The in="SourceGraphic" part defines that the effect is created from the whole image


Another example with a different stdDeviation:

"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">



style="fill:#ff0000;stroke:#000000;
stroke-width:2;filter:url(#Gaussian_Blur)"/>
Reply With Quote
  #12  
Old 05-03-2009, 04:01 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default SVG Gradients - Linear

An SVG Gradient must be defined within a tag.
SVG Gradients

A gradient is a smooth transition from one color to another. In addition, several color transitions can be applied to the same element.
There are two main types of gradients in SVG:
  • Linear Gradients
  • Radial Gradients
Linear Gradients

The tag is used to define an SVG linear gradient.
The tag must be nested within a tag. The tag is short for definitions and it allows definition of special elements such as gradients.


Linear gradients can be defined as horizontal, vertical or angular gradients:
  • Horizontal gradients are created when y1 and y2 are equal and x1 and x2 differ
  • Vertical gradients are created when x1 and x2 are equal and y1 and y2 differ
  • Angular gradients are created when x1 and x2 differ and y1 and y2 differ
Copy the following code into Notepad and save the file as "linear1.svg". Place the file in your Web directory:






"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">




style="fill:url(#orange_red)"/>

Code explanation:
  • The id attribute of the tag defines a unique name for the gradient
  • The fill:url(#orange_red) property links the ellipse element to the gradient
  • The x1, x2, y1,y2 attributes of the tag define the starting and ending position of the gradient
  • The color range for a gradient can be composed of two or more colors. Each color is specified with a tag. The offset attribute is used to define where the gradient color begin and end


Another example:




"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">




style="fill:url(#orange_red)"/>
Reply With Quote
  #13  
Old 05-03-2009, 04:02 PM
welcomewiki welcomewiki is offline
Member
 
Join Date: Dec 2008
Location: India
Posts: 80,566
Default SVG Gradients - Radia

An SVG Gradient must be defined within a tag.
Radial Gradients

The tag is used to define an SVG radial gradient.
The tag must be nested within a tag. The tag is short for definitions and it allows definition of special elements such as gradients.


Copy the following code into Notepad and save the file as "radial1.svg". Place the file in your Web directory:





"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">
fx="50%" fy="50%">



style="fill:url(#grey_blue)"/>

Code explanation:
  • The id attribute of the tag defines a unique name for the gradient
  • The fill:url(#grey_blue) property links the ellipse element to the gradient
  • The cx, cy and r attributes define the outermost circle and the fx and fy define the innermost circle
  • The color range for a gradient can be composed of two or more colors. Each color is specified with a tag. The offset attribute is used to define where the gradient color begin and end
Another example:


"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> xmlns="http://www.w3.org/2000/svg">
fx="50%" fy="50%">



style="fill:url(#grey_blue)"/>
Reply With Quote
Reply

New topics in IT Forum





Powered by vBulletin® Version 3.8.10
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
WikiNewForum)