SlideShare a Scribd company logo
1 of 20
SVG(ScalableSVG(Scalable
Vector Graphics)Vector Graphics)
infobizzs.com
What is SVG?What is SVG?
• SVG stands for Scalable Vector Graphics.
• SVG defines vector-based graphics in XML format.
• SVG stands for Scalable Vector Graphics.
• SVG is used to define vector-based graphics for the Web.
• SVG defines the graphics in XML format.
• SVG graphics do NOT lose any quality if they are zoomed or
resized .
• Every element and every attribute in SVG files can be animated.
• SVG is a W3C recommendation.
• SVG integrates with other W3C standards such as the DOM and
XSL.
infobizzs.com
SVG AdvantagesSVG Advantages
Advantages of using SVG over other image formats (like JPEG and
GIF) are:
• SVG images can be created and edited with any text editor
• SVG images can be searched, indexed, scripted, and
compressed
• SVG images are scalable
• SVG images can be printed with high quality at any
resolution
• SVG images are zoomable (and the image can be zoomed
without degradation)
• SVG is an open standard
• SVG files are pure XML
infobizzs.com
SVG in HTMLSVG in HTML
• In HTML5, you can embed SVG elements directly into your
HTML pages.
• Here is an example of a simple SVG graphic:
• and here is the HTML code:
infobizzs.com
ExampleExample
<!DOCTYPE html>
<html>
<body>
<h1>My first SVG</h1>
<svg width="100" height="100">
  <circle cx="50" cy="50" r="40" stroke="green" stroke-
width="4" fill="yellow" />
</svg>
</body>
</html>
infobizzs.com
OutputOutput
infobizzs.com
SVG Code explanation:SVG Code explanation:
infobizzs.com
• An SVG image begins with an <svg> element
• The width and height attributes of the <svg> element define the
width and height of the SVG image
• The <circle> element is used to draw a circle
• The cx and cy attributes define the x and y coordinates of the
center of the circle. If cx and cy are omitted, the circle's center is set
to (0, 0)
• The r attribute defines the radius of the circle
• The stroke and stroke-width attributes control how the outline of a
shape appears. We set the outline of the circle to a 4px green
"border“
•
• The fill attribute refers to the color inside the circle. We set the fill
color to yellow
• The closing </svg> tag closes the SVG image
SVG ShapesSVG Shapes
SVG has some predefined shape elements that can be used by
developers:
• Rectangle <rect>
• Circle <circle>
• Ellipse <ellipse>
• Line <line>
• Polyline <polyline>
• Polygon <polygon>
• Path <path>
infobizzs.com
SVG Rectangle - <rect>SVG Rectangle - <rect>
• The <rect> element is used to create a rectangle and variations
of a rectangle shape:
• Here is the SVG code:
infobizzs.com
ExampleExample
<svg width="400" height="110">
  <rect width="300" height="100“
style="fill:rgb(0,0,255);
stroke-width:3;stroke:rgb(0,0,0)" />
</svg>
OutputOutput
infobizzs.com
Code explanation:Code explanation:
• The width and height attributes of the <rect> element define the
height and the width of the rectangle
• The style attribute is used to define CSS properties for the
rectangle
• The CSS fill property defines the fill color of the rectangle
• The CSS stroke-width property defines the width of the border of
the rectangle
• The CSS stroke property defines the color of the border of the
rectangle
infobizzs.com
SVG Circle - <circle>SVG Circle - <circle>
• The <circle> element is used to create a circle:
• Here is the SVG code:
infobizzs.com
ExampleExample
<svg height="100" width="100">
  <circle cx="50" cy="50" r="40" stroke="black" stroke-
width="3" fill="red" />
</svg>
OutputOutput
infobizzs.com
Code explanation:Code explanation:
• The cx and cy attributes define the x and y coordinates of the
center of the circle. If cx and cy are omitted, the circle's center is
set to (0,0)
• The r attribute defines the radius of the circle
infobizzs.com
SVG Ellipse - <ellipse>SVG Ellipse - <ellipse>
• The <ellipse> element is used to create an ellipse.
• An ellipse is closely related to a circle. The difference is that an
ellipse has an x and a y radius that differs from each other, while
a circle has equal x and y radius:
• The following example creates an ellipse:
• Here is the SVG code:
infobizzs.com
ExampleExample
• <svg height="140" width="500">
  <ellipse cx="200" cy="80" rx="100" ry="50"
  style="fill:yellow;stroke:purple;stroke-width:2" />
</svg>
Output
infobizzs.com
Code explanation:Code explanation:
• The cx attribute defines the x coordinate of the center
of the ellipse
• The cy attribute defines the y coordinate of the center
of the ellipse
• The rx attribute defines the horizontal radius
• The ry attribute defines the vertical radius
infobizzs.com
SVG Line - <line>SVG Line - <line>
• The <line> element is used to create a line:
• Here is the SVG code:
infobizzs.com
ExampleExample
<svg height="210" width="500">
<line x1="0" y1="0" x2="200" y2="200"
style="stroke:rgb(255,0,0);stroke-width:2" />
</svg>
OutputOutput
infobizzs.com
Code explanation:Code explanation:
• The x1 attribute defines the start of the line on the x-
axis
• The y1 attribute defines the start of the line on the y-
axis
• The x2 attribute defines the end of the line on the x-
axis
• The y2 attribute defines the end of the line on the y-
axis
infobizzs.com

More Related Content

What's hot (20)

css.ppt
css.pptcss.ppt
css.ppt
 
Introduction to Html5
Introduction to Html5Introduction to Html5
Introduction to Html5
 
How Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) WorksHow Cascading Style Sheets (CSS) Works
How Cascading Style Sheets (CSS) Works
 
Intro to HTML and CSS basics
Intro to HTML and CSS basicsIntro to HTML and CSS basics
Intro to HTML and CSS basics
 
Css box-model
Css box-modelCss box-model
Css box-model
 
CSS ppt
CSS pptCSS ppt
CSS ppt
 
Css3
Css3Css3
Css3
 
Html & Css presentation
Html  & Css presentation Html  & Css presentation
Html & Css presentation
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
Css backgrounds
Css   backgroundsCss   backgrounds
Css backgrounds
 
CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Introduction to HTML and CSS
Introduction to HTML and CSSIntroduction to HTML and CSS
Introduction to HTML and CSS
 
HTML and CSS crash course!
HTML and CSS crash course!HTML and CSS crash course!
HTML and CSS crash course!
 
Introduction to CSS3
Introduction to CSS3Introduction to CSS3
Introduction to CSS3
 
Html 5
Html 5Html 5
Html 5
 
Html5 tutorial for beginners
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
 
Introduction to css & its attributes with syntax
Introduction to css & its attributes with syntaxIntroduction to css & its attributes with syntax
Introduction to css & its attributes with syntax
 
Flexbox and Grid Layout
Flexbox and Grid LayoutFlexbox and Grid Layout
Flexbox and Grid Layout
 
Css ppt
Css pptCss ppt
Css ppt
 
Java script
Java scriptJava script
Java script
 

Viewers also liked

HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVGyarcub
 
제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP
 제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP 제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP
제 5회 DGMIT R&D 컨퍼런스: HTML Graphics APdgmit2009
 
SVG For Web Designers (and Developers)
SVG For Web Designers (and Developers) SVG For Web Designers (and Developers)
SVG For Web Designers (and Developers) Sara Soueidan
 
HTML5: features with examples
HTML5: features with examplesHTML5: features with examples
HTML5: features with examplesAlfredo Torre
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to BootstrapRon Reiter
 

Viewers also liked (7)

HTML5 and SVG
HTML5 and SVGHTML5 and SVG
HTML5 and SVG
 
제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP
 제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP 제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP
제 5회 DGMIT R&D 컨퍼런스: HTML Graphics AP
 
SVG For Web Designers (and Developers)
SVG For Web Designers (and Developers) SVG For Web Designers (and Developers)
SVG For Web Designers (and Developers)
 
Bootstrap ppt
Bootstrap pptBootstrap ppt
Bootstrap ppt
 
Bootstrap ppt
Bootstrap pptBootstrap ppt
Bootstrap ppt
 
HTML5: features with examples
HTML5: features with examplesHTML5: features with examples
HTML5: features with examples
 
Introduction to Bootstrap
Introduction to BootstrapIntroduction to Bootstrap
Introduction to Bootstrap
 

Similar to Svg

SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)Filip Van Laenen
 
SVG - Scalable Vector Graphics
SVG - Scalable Vector GraphicsSVG - Scalable Vector Graphics
SVG - Scalable Vector GraphicsShweta Sadawarte
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)Filip Van Laenen
 
Drawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebDrawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebCloudinary
 
Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Pascal Rettig
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSGil Fink
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using cssDhairya Joshi
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?Mike Wilcox
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvasGary Yeh
 
Graphics 2D SVG
Graphics 2D SVGGraphics 2D SVG
Graphics 2D SVGMinh Huong
 
Html5 Canvas Detail
Html5 Canvas DetailHtml5 Canvas Detail
Html5 Canvas DetailNisa Soomro
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive GraphicsBlazing Cloud
 

Similar to Svg (20)

5. SVG.pptx
5. SVG.pptx5. SVG.pptx
5. SVG.pptx
 
SVG Animations
SVG AnimationsSVG Animations
SVG Animations
 
SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)SVG (Devoxx 2011, 2011-NOV-14)
SVG (Devoxx 2011, 2011-NOV-14)
 
SVG - Scalable Vector Graphics
SVG - Scalable Vector GraphicsSVG - Scalable Vector Graphics
SVG - Scalable Vector Graphics
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)
 
Drawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the WebDrawing a Circle Three Ways: Generating Graphics for the Web
Drawing a Circle Three Ways: Generating Graphics for the Web
 
Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3Vector Graphics on the Web: SVG, Canvas, CSS3
Vector Graphics on the Web: SVG, Canvas, CSS3
 
Biological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJSBiological Modeling, Powered by AngularJS
Biological Modeling, Powered by AngularJS
 
MTA managing the graphical interface by using css
MTA managing the graphical interface by using cssMTA managing the graphical interface by using css
MTA managing the graphical interface by using css
 
Thats Not Flash?
Thats Not Flash?Thats Not Flash?
Thats Not Flash?
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
SVG and the web
SVG and the webSVG and the web
SVG and the web
 
Graphics 2D SVG
Graphics 2D SVGGraphics 2D SVG
Graphics 2D SVG
 
Html 5 svg
Html 5 svgHtml 5 svg
Html 5 svg
 
CSS and CSS3
CSS and CSS3CSS and CSS3
CSS and CSS3
 
Learn svg
Learn svgLearn svg
Learn svg
 
SVG overview
SVG overviewSVG overview
SVG overview
 
Html5 Canvas Detail
Html5 Canvas DetailHtml5 Canvas Detail
Html5 Canvas Detail
 
Interactive Graphics
Interactive GraphicsInteractive Graphics
Interactive Graphics
 
Iagc2
Iagc2Iagc2
Iagc2
 

Recently uploaded

Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationNeilDeclaro1
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...Amil baba
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxPooja Bhuva
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsSandeep D Chaudhary
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactisticshameyhk98
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsMebane Rash
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxPooja Bhuva
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Pooja Bhuva
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxannathomasp01
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17Celine George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxUmeshTimilsina1
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 

Recently uploaded (20)

Basic Intentional Injuries Health Education
Basic Intentional Injuries Health EducationBasic Intentional Injuries Health Education
Basic Intentional Injuries Health Education
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
OSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & SystemsOSCM Unit 2_Operations Processes & Systems
OSCM Unit 2_Operations Processes & Systems
 
Philosophy of china and it's charactistics
Philosophy of china and it's charactisticsPhilosophy of china and it's charactistics
Philosophy of china and it's charactistics
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Interdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptxInterdisciplinary_Insights_Data_Collection_Methods.pptx
Interdisciplinary_Insights_Data_Collection_Methods.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptxCOMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
COMMUNICATING NEGATIVE NEWS - APPROACHES .pptx
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Plant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptxPlant propagation: Sexual and Asexual propapagation.pptx
Plant propagation: Sexual and Asexual propapagation.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

Svg

  • 2. What is SVG?What is SVG? • SVG stands for Scalable Vector Graphics. • SVG defines vector-based graphics in XML format. • SVG stands for Scalable Vector Graphics. • SVG is used to define vector-based graphics for the Web. • SVG defines the graphics in XML format. • SVG graphics do NOT lose any quality if they are zoomed or resized . • Every element and every attribute in SVG files can be animated. • SVG is a W3C recommendation. • SVG integrates with other W3C standards such as the DOM and XSL. infobizzs.com
  • 3. SVG AdvantagesSVG Advantages Advantages of using SVG over other image formats (like JPEG and GIF) are: • SVG images can be created and edited with any text editor • SVG images can be searched, indexed, scripted, and compressed • SVG images are scalable • SVG images can be printed with high quality at any resolution • SVG images are zoomable (and the image can be zoomed without degradation) • SVG is an open standard • SVG files are pure XML infobizzs.com
  • 4. SVG in HTMLSVG in HTML • In HTML5, you can embed SVG elements directly into your HTML pages. • Here is an example of a simple SVG graphic: • and here is the HTML code: infobizzs.com
  • 5. ExampleExample <!DOCTYPE html> <html> <body> <h1>My first SVG</h1> <svg width="100" height="100">   <circle cx="50" cy="50" r="40" stroke="green" stroke- width="4" fill="yellow" /> </svg> </body> </html> infobizzs.com
  • 7. SVG Code explanation:SVG Code explanation: infobizzs.com • An SVG image begins with an <svg> element • The width and height attributes of the <svg> element define the width and height of the SVG image • The <circle> element is used to draw a circle • The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0, 0) • The r attribute defines the radius of the circle • The stroke and stroke-width attributes control how the outline of a shape appears. We set the outline of the circle to a 4px green "border“ • • The fill attribute refers to the color inside the circle. We set the fill color to yellow • The closing </svg> tag closes the SVG image
  • 8. SVG ShapesSVG Shapes SVG has some predefined shape elements that can be used by developers: • Rectangle <rect> • Circle <circle> • Ellipse <ellipse> • Line <line> • Polyline <polyline> • Polygon <polygon> • Path <path> infobizzs.com
  • 9. SVG Rectangle - <rect>SVG Rectangle - <rect> • The <rect> element is used to create a rectangle and variations of a rectangle shape: • Here is the SVG code: infobizzs.com
  • 10. ExampleExample <svg width="400" height="110">   <rect width="300" height="100“ style="fill:rgb(0,0,255); stroke-width:3;stroke:rgb(0,0,0)" /> </svg> OutputOutput infobizzs.com
  • 11. Code explanation:Code explanation: • The width and height attributes of the <rect> element define the height and the width of the rectangle • The style attribute is used to define CSS properties for the rectangle • The CSS fill property defines the fill color of the rectangle • The CSS stroke-width property defines the width of the border of the rectangle • The CSS stroke property defines the color of the border of the rectangle infobizzs.com
  • 12. SVG Circle - <circle>SVG Circle - <circle> • The <circle> element is used to create a circle: • Here is the SVG code: infobizzs.com
  • 13. ExampleExample <svg height="100" width="100">   <circle cx="50" cy="50" r="40" stroke="black" stroke- width="3" fill="red" /> </svg> OutputOutput infobizzs.com
  • 14. Code explanation:Code explanation: • The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0,0) • The r attribute defines the radius of the circle infobizzs.com
  • 15. SVG Ellipse - <ellipse>SVG Ellipse - <ellipse> • The <ellipse> element is used to create an ellipse. • An ellipse is closely related to a circle. The difference is that an ellipse has an x and a y radius that differs from each other, while a circle has equal x and y radius: • The following example creates an ellipse: • Here is the SVG code: infobizzs.com
  • 16. ExampleExample • <svg height="140" width="500">   <ellipse cx="200" cy="80" rx="100" ry="50"   style="fill:yellow;stroke:purple;stroke-width:2" /> </svg> Output infobizzs.com
  • 17. Code explanation:Code explanation: • The cx attribute defines the x coordinate of the center of the ellipse • The cy attribute defines the y coordinate of the center of the ellipse • The rx attribute defines the horizontal radius • The ry attribute defines the vertical radius infobizzs.com
  • 18. SVG Line - <line>SVG Line - <line> • The <line> element is used to create a line: • Here is the SVG code: infobizzs.com
  • 19. ExampleExample <svg height="210" width="500"> <line x1="0" y1="0" x2="200" y2="200" style="stroke:rgb(255,0,0);stroke-width:2" /> </svg> OutputOutput infobizzs.com
  • 20. Code explanation:Code explanation: • The x1 attribute defines the start of the line on the x- axis • The y1 attribute defines the start of the line on the y- axis • The x2 attribute defines the end of the line on the x- axis • The y2 attribute defines the end of the line on the y- axis infobizzs.com