SlideShare a Scribd company logo
1 of 48
SVG
Friday, December 4, 2015 www.qsoftvietnam.com 1
Presenter:
Nguyễn Phi Linh
Lê Minh Hưởng
Nguyễn Công Đỗ
Friday, December 4, 2015 www.qsoftvietnam.com 2
Outline
 Introduction
 Getting Started
 Positions
 Basic Shapes
 Paths
 Fills and Strokes
 Gradients
 Patterns
 Animation
 Texts
 Transformations
 Clipping
 SVG Image Tag
 Tools For SVG
Friday, December 4, 2015 www.qsoftvietnam.com 3
Introduction
• 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
Friday, December 4, 2015 www.qsoftvietnam.com 4
Getting Started
• Start with the svg root element
• SVG files on the web can be displayed directly in the browser or embedded in
HTML files via several methods:
• <object data="image.svg" type="image/svg+xml" />
• <iframe src="image.svg"></iframe>
• Check support: <svg …>Message</svg>
Positions
Friday, December 4, 2015 www.qsoftvietnam.com 5
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 6
 Rectangles
• rx : The x radius of the corners of the rectangle
• ry : The y radius of the corners of the rectangle
<rect>
x
y
width
height
rx
ry
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 7
 Circle
• r : The radius of the circle.
• cx : The x position of the center of the circle.
• cy : The y position of the center of the circle.
<circle>
r
cxcy
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 8
 Ellipse
<ellipse>
rx
ry
cx
cy
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 9
 Line
 x1 : The x position of point 1.
• y1 : The y position of point 1.
• x2 : The x position of point 2.
• y2 : The y position of point 2.
<line>
x1
y1
x2
y2
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 10
 Polyine
<polyline>
Polylines are groups of connected
straight lines
points
• Each point must contain two
numbers, an x coordinate and a
y coordinate. So the list (0,0),
(1,1) and (2,2) could be
written: "0 0, 1 1, 2 2".
Basic Shapes
Friday, December 4, 2015 www.qsoftvietnam.com 11
 Polygon
<polygon>
The path automatically returns to
the first point for you at the end,
creating a closed shape
points
• Each point must contain two
numbers, an x coordinate and a
y coordinate. So the list (0,0),
(1,1) and (2,2) could be
written: "0 0, 1 1, 2 2".
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 12
• The <path> element is the most powerful element in the SVG library of basic
shapes. It can be used to create (at least to a fairly good approximation), all the
other basic shapes and more.
• The shape of a path element is defined by one attribute: d. The d attribute contains a
series of commands and parameters used by those commands.
• Paths can be used to create smooth flowing lines using a relatively few number of control
points
• Similar looking effects can be created using just the polyline element, but you have to
use a lot of points to create a smooth looking effect, and it still won't scale well at larger
sizes.
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 13
Line
commands
Moveto
Lineto
CurvetoArcto
ClosePath
• M = moveto
• L = lineto
• H = horizontal lineto
• V = vertical lineto
• C = curveto
• S = smooth curveto
• Q = quadratic Bézier curve
• T = smooth quadratic Bézier curveto
• A = elliptical Arc
• Z = closepath
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 14
 Moveto
• Moveto instructions can be thought of as picking up the drawing instrument
and setting it down somewhere else. There is no line drawn between the
previous point and the specified point. It is good practice to open all paths with
a Moveto command, because without an initial Moveto, commands will be
executed with the starting point at wherever it happened to be previously,
possibly resulting in undefined behaviour.
• Syntax:
• M x,y where x and y are absolute coordinates, horizontal and vertical respectively.
• m dx,dy where dx and dy are distances relative to the current position, to the right
and down respectively.
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 15
 Lineto
• Lineto instructions will draw a straight line. This line moves from the current
position to the specified location. The syntax for a generic Lineto command is
"L x,y" or "l dx, dy" where x and y are absolute coordinates and dx and dy are
distances to the right and down respectively.
• There are also the letters H and V, which specify Horizontal and Vertical
movements. Their syntax is exactly the same as L, including that the lower-
case version is relative rather than absolute.
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 16
 Curveto
Curveto commands specify a Bezier curve. There are two types of Bezier
curves:
• Cubic : (C c1x, c2x c1y, c2y x, y) or (c dc1x, dc1y dc2x, dx dc2y, dy )
• Quadratic : (Q cx, cy x, y) or (q dcx, dcy, dx, dy)
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 17
Quadratic : There is a shortcut for stringing together multiple quadratic Beziers, T.
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 18
 Arcto
The other type of curved line you can create using SVG is the arc, A. Arcs are
sections of circles or ellipses. For a given x-radius and y-radius, there are two
ellipses that can connect any two points (as long as they're within the radius of the
circle). Along either of those circles there are two possible paths that you can take
to connect the points, so in any situation there are four possible arcs available.
 A rx ry x-axis-rotation large-arc-flag sweep-flag x y
 a rx ry x-axis-rotation large-arc-flag sweep-flag dx dy
Paths
Friday, December 4, 2015 www.qsoftvietnam.com 19
 ClosePath
The ClosePath command will simply draw a straight line from the current position to
the first point in the path. It is the simplest command, and takes no parameters. It will take the
shortest linear path to the starting point, intersecting other paths if they fall in the way. The
syntax is "Z" or "z", and both will react exactly the same.
Fills & Strokes
Friday, December 4, 2015 www.qsoftvietnam.com 20
 Fill sets the color inside the object
 Stroke sets the color of the line drawn around the object
Color
Fill & Stroke Css
Fills & Strokes
Friday, December 4, 2015 www.qsoftvietnam.com 21
• width
• height
• path commands
• d
Can't be set through CSS
The SVG specification decides strictly between attributes, that
are properties and other attributes. The former can be
modified with CSS, the latter not.
Fills & Strokes attributes
Friday, December 4, 2015 www.qsoftvietnam.com 22
• stroke
• stroke-width
• stroke-linecap
– butt
– square
– round
• stroke-dasharray
– number,number,number
…
• stroke-opacity
• fill
• fill-opacity
Friday, December 4, 2015 www.qsoftvietnam.com 23
Fills & Strokes Use?
Gradients
Friday, December 4, 2015 www.qsoftvietnam.com 24
 Linear Gradient
 Radial Gradient
 Linear Gradient
• 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
Friday, December 4, 2015 www.qsoftvietnam.com 25
Gradients
Friday, December 4, 2015 www.qsoftvietnam.com 26
 Radial Gradient
• cx, cy, r, fx, fy
• Center and Focal point
• cx, cy, r, fx, fy : 0.25 = 25%
• spreadMethod
• pad
• repeat
• reflect
Friday, December 4, 2015 www.qsoftvietnam.com 27
Friday, December 4, 2015 www.qsoftvietnam.com 28
Patterns
Friday, December 4, 2015 www.qsoftvietnam.com 29
 Like gradients, the <pattern> element should be put in
the <defs> section of your SVG file.
Friday, December 4, 2015 www.qsoftvietnam.com 30
Patterns
Patterns
Friday, December 4, 2015 www.qsoftvietnam.com 31
 patternUnits="userSpaceOnUse“
 patternContentUnits="objectBoundingBox"
Animation
Friday, December 4, 2015 www.qsoftvietnam.com 32
 <set>
 <animate>
 <animateTransform>
 <animateMotion>
 <animateColor>
Animation
Friday, December 4, 2015 www.qsoftvietnam.com 33
 Set
The set element is the simplest of the SVG animation
elements. It simply sets an attribute to a certain value after a
specific time interval has passed. As such, the shape is not
continuously animating, but just changes attribute value once.
<set
attributeName="r" attributeType="XML" to="100" begin="0s“
/>
Animation
Friday, December 4, 2015 www.qsoftvietnam.com 34
 Animate
The animate element is used to animate an attribute of an
SVG shape.
<animate
attributeName="cx" attributeType="XML" from="30" to="470"
begin="0s" dur="5s" fill="remove" repeatCount="indefinite"
/>
Animation
Friday, December 4, 2015 www.qsoftvietnam.com 35
 Animate Tranform
The <animateTransform> element can animate the
transform attribute of a shape. The <animate> element cannot
do that.
<animateTransform
attributeName="transform" type="rotate" from="0 100 100" to="360
100 100" begin="0s" dur="10s" repeatCount="indefinite"
/>
Animation
Friday, December 4, 2015 www.qsoftvietnam.com 36
 Animate Motion
The <animateMotion> element can animate the
movement of a shape along a path.
It can also rotate the shape to match the slope of the path,
like a car driving up and down hill.
<animateMotion
path="M10,50 q60,50 100,0 q60,-50 100,0" begin="0s" dur="10s"
repeatCount="indefinite" rotate="auto"
/>
Friday, December 4, 2015 www.qsoftvietnam.com 37
Texts
<text> Bringing text into an SVG image
<text>
x dy
dxy
rotate
Friday, December 4, 2015 www.qsoftvietnam.com 38
Texts
<svg viewBox = "0 0 200 200" version = "1.1">
<text x = "10" y = "25" fill = "red" transform="rotate(30 20,40)" font-size = "15">
Example
</text>
<text x="0" y="0" dx = "10" dy = "40" fill = "blue" transform="rotate(30 20,40)" font-size = "15">
Example
</text>
</svg>
Friday, December 4, 2015 www.qsoftvietnam.com 39
Texts -TextPath
• In addition to text drawn in a straight line, SVG also includes the ability to place
text along the shape of a <path> element.
• To specify that a block of text is to be rendered along the shape of a <path>, include
the given text within a textPath element which includes an xlink:href attribute with a
reference to a <path> element.
Friday, December 4, 2015 www.qsoftvietnam.com 40
Friday, December 4, 2015 www.qsoftvietnam.com 41
Transformations
• Translation
• Rotation
• Embedding SVG in SVG
• Skewing
• Scaling
• Complex transformations with matrix()
• Effects on Coordinate Systems
Friday, December 4, 2015 www.qsoftvietnam.com 42
Transformations
 Translation
• It may be necessary to move an element around, even though you can position
it with the according attributes. For this purpose, the translate()transformation
stands ready.
• translate(x,y)
Friday, December 4, 2015 www.qsoftvietnam.com 43
Transformations
 Rotation
• rorate(degrees)
• This example shows a square that is rotated by 45 degrees.
Friday, December 4, 2015 www.qsoftvietnam.com 44
Clipping
• Clipping refers to removing parts of elements defined by other parts.
• In this case, any half-transparent effects are not possible, it's an all-or-nothing
approach.
• <clipPath >
• clip-path="url(#...)"
Friday, December 4, 2015 www.qsoftvietnam.com 45
SVG Image Tag
Friday, December 4, 2015 www.qsoftvietnam.com 46
Tools for SVG
• Inkscape
https://inkscape.org
• Adobe Illustrator
http://www.adobe.com/products/illustrator
• Apache Batik
http://xmlgraphics.apache.org/batik/
Friday, December 4, 2015 www.qsoftvietnam.com 47
Reference
• http://www.w3schools.com/svg/default.asp
• http://tutorials.jenkov.com/svg
• https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial
• https://developer.mozilla.org/en-
US/docs/Web/API/SVGAElement
• https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
THANK YOU FOR
YOUR ATTENTION!
Friday, December 4, 2015 www.qsoftvietnam.com 48

More Related Content

Similar to Graphics 2D SVG

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
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvasGary Yeh
 
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 Graphic
SVG - Scalable Vector GraphicSVG - Scalable Vector Graphic
SVG - Scalable Vector GraphicAkila Iroshan
 
Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksPhilip Tellis
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCADVickyTGAW
 
Fundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFatihahIrra
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)Filip Van Laenen
 
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationSVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationAnthony Starks
 
Making BIG DATA smaller
Making BIG DATA smallerMaking BIG DATA smaller
Making BIG DATA smallerTony Tran
 
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...BookNet Canada
 
SVG vs Canvas - Showdown of the Painters
SVG vs Canvas - Showdown of the PaintersSVG vs Canvas - Showdown of the Painters
SVG vs Canvas - Showdown of the PaintersPhil Reither
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics PipelineMark Kilgard
 
Sketching Tips From A CAPINC SOLIDWORKS Gure
Sketching Tips From A CAPINC SOLIDWORKS GureSketching Tips From A CAPINC SOLIDWORKS Gure
Sketching Tips From A CAPINC SOLIDWORKS GureCAPINC
 

Similar to Graphics 2D SVG (20)

DotNetNuke World CSS3
DotNetNuke World CSS3DotNetNuke World CSS3
DotNetNuke World CSS3
 
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
 
Html5 canvas
Html5 canvasHtml5 canvas
Html5 canvas
 
Auto cad for fashion design by v.s. bhati
Auto cad for fashion design by v.s. bhatiAuto cad for fashion design by v.s. bhati
Auto cad for fashion design by v.s. bhati
 
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 Graphic
SVG - Scalable Vector GraphicSVG - Scalable Vector Graphic
SVG - Scalable Vector Graphic
 
Improving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other HacksImproving D3 Performance with CANVAS and other Hacks
Improving D3 Performance with CANVAS and other Hacks
 
Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2Ar1 twf030 lecture1.2
Ar1 twf030 lecture1.2
 
3D Design with OpenSCAD
3D Design with OpenSCAD3D Design with OpenSCAD
3D Design with OpenSCAD
 
Fundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdfFundamentals of Multimedia - Vector Graphics.pdf
Fundamentals of Multimedia - Vector Graphics.pdf
 
SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)SVG (Framsia, 27-SEP-2011)
SVG (Framsia, 27-SEP-2011)
 
SVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generationSVGo: a Go Library for SVG generation
SVGo: a Go Library for SVG generation
 
Making BIG DATA smaller
Making BIG DATA smallerMaking BIG DATA smaller
Making BIG DATA smaller
 
D3.js and SVG
D3.js and SVGD3.js and SVG
D3.js and SVG
 
Css3
Css3Css3
Css3
 
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...
The Bunny Slopes of SVG Mountain - Naomi Kennedy (Penguin Random House) - ebo...
 
SVG vs Canvas - Showdown of the Painters
SVG vs Canvas - Showdown of the PaintersSVG vs Canvas - Showdown of the Painters
SVG vs Canvas - Showdown of the Painters
 
CS 354 More Graphics Pipeline
CS 354 More Graphics PipelineCS 354 More Graphics Pipeline
CS 354 More Graphics Pipeline
 
Sketching Tips From A CAPINC SOLIDWORKS Gure
Sketching Tips From A CAPINC SOLIDWORKS GureSketching Tips From A CAPINC SOLIDWORKS Gure
Sketching Tips From A CAPINC SOLIDWORKS Gure
 
canvas_1.pptx
canvas_1.pptxcanvas_1.pptx
canvas_1.pptx
 

Recently uploaded

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样umasea
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024StefanoLambiase
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesPhilip Schwarz
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEOrtus Solutions, Corp
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaHanief Utama
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio, Inc.
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsAhmed Mohamed
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...OnePlan Solutions
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptkotipi9215
 

Recently uploaded (20)

办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
办理学位证(UQ文凭证书)昆士兰大学毕业证成绩单原版一模一样
 
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort ServiceHot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
Hot Sexy call girls in Patel Nagar🔝 9953056974 🔝 escort Service
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
Dealing with Cultural Dispersion — Stefano Lambiase — ICSE-SEIS 2024
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Folding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a seriesFolding Cheat Sheet #4 - fourth in a series
Folding Cheat Sheet #4 - fourth in a series
 
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASEBATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
BATTLEFIELD ORM: TIPS, TACTICS AND STRATEGIES FOR CONQUERING YOUR DATABASE
 
React Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief UtamaReact Server Component in Next.js by Hanief Utama
React Server Component in Next.js by Hanief Utama
 
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed DataAlluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
Alluxio Monthly Webinar | Cloud-Native Model Training on Distributed Data
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 
Unveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML DiagramsUnveiling Design Patterns: A Visual Guide with UML Diagrams
Unveiling Design Patterns: A Visual Guide with UML Diagrams
 
Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...Advancing Engineering with AI through the Next Generation of Strategic Projec...
Advancing Engineering with AI through the Next Generation of Strategic Projec...
 
chapter--4-software-project-planning.ppt
chapter--4-software-project-planning.pptchapter--4-software-project-planning.ppt
chapter--4-software-project-planning.ppt
 

Graphics 2D SVG

  • 1. SVG Friday, December 4, 2015 www.qsoftvietnam.com 1 Presenter: Nguyễn Phi Linh Lê Minh Hưởng Nguyễn Công Đỗ
  • 2. Friday, December 4, 2015 www.qsoftvietnam.com 2 Outline  Introduction  Getting Started  Positions  Basic Shapes  Paths  Fills and Strokes  Gradients  Patterns  Animation  Texts  Transformations  Clipping  SVG Image Tag  Tools For SVG
  • 3. Friday, December 4, 2015 www.qsoftvietnam.com 3 Introduction • 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
  • 4. Friday, December 4, 2015 www.qsoftvietnam.com 4 Getting Started • Start with the svg root element • SVG files on the web can be displayed directly in the browser or embedded in HTML files via several methods: • <object data="image.svg" type="image/svg+xml" /> • <iframe src="image.svg"></iframe> • Check support: <svg …>Message</svg>
  • 5. Positions Friday, December 4, 2015 www.qsoftvietnam.com 5
  • 6. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 6  Rectangles • rx : The x radius of the corners of the rectangle • ry : The y radius of the corners of the rectangle <rect> x y width height rx ry
  • 7. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 7  Circle • r : The radius of the circle. • cx : The x position of the center of the circle. • cy : The y position of the center of the circle. <circle> r cxcy
  • 8. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 8  Ellipse <ellipse> rx ry cx cy
  • 9. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 9  Line  x1 : The x position of point 1. • y1 : The y position of point 1. • x2 : The x position of point 2. • y2 : The y position of point 2. <line> x1 y1 x2 y2
  • 10. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 10  Polyine <polyline> Polylines are groups of connected straight lines points • Each point must contain two numbers, an x coordinate and a y coordinate. So the list (0,0), (1,1) and (2,2) could be written: "0 0, 1 1, 2 2".
  • 11. Basic Shapes Friday, December 4, 2015 www.qsoftvietnam.com 11  Polygon <polygon> The path automatically returns to the first point for you at the end, creating a closed shape points • Each point must contain two numbers, an x coordinate and a y coordinate. So the list (0,0), (1,1) and (2,2) could be written: "0 0, 1 1, 2 2".
  • 12. Paths Friday, December 4, 2015 www.qsoftvietnam.com 12 • The <path> element is the most powerful element in the SVG library of basic shapes. It can be used to create (at least to a fairly good approximation), all the other basic shapes and more. • The shape of a path element is defined by one attribute: d. The d attribute contains a series of commands and parameters used by those commands. • Paths can be used to create smooth flowing lines using a relatively few number of control points • Similar looking effects can be created using just the polyline element, but you have to use a lot of points to create a smooth looking effect, and it still won't scale well at larger sizes.
  • 13. Paths Friday, December 4, 2015 www.qsoftvietnam.com 13 Line commands Moveto Lineto CurvetoArcto ClosePath • M = moveto • L = lineto • H = horizontal lineto • V = vertical lineto • C = curveto • S = smooth curveto • Q = quadratic Bézier curve • T = smooth quadratic Bézier curveto • A = elliptical Arc • Z = closepath
  • 14. Paths Friday, December 4, 2015 www.qsoftvietnam.com 14  Moveto • Moveto instructions can be thought of as picking up the drawing instrument and setting it down somewhere else. There is no line drawn between the previous point and the specified point. It is good practice to open all paths with a Moveto command, because without an initial Moveto, commands will be executed with the starting point at wherever it happened to be previously, possibly resulting in undefined behaviour. • Syntax: • M x,y where x and y are absolute coordinates, horizontal and vertical respectively. • m dx,dy where dx and dy are distances relative to the current position, to the right and down respectively.
  • 15. Paths Friday, December 4, 2015 www.qsoftvietnam.com 15  Lineto • Lineto instructions will draw a straight line. This line moves from the current position to the specified location. The syntax for a generic Lineto command is "L x,y" or "l dx, dy" where x and y are absolute coordinates and dx and dy are distances to the right and down respectively. • There are also the letters H and V, which specify Horizontal and Vertical movements. Their syntax is exactly the same as L, including that the lower- case version is relative rather than absolute.
  • 16. Paths Friday, December 4, 2015 www.qsoftvietnam.com 16  Curveto Curveto commands specify a Bezier curve. There are two types of Bezier curves: • Cubic : (C c1x, c2x c1y, c2y x, y) or (c dc1x, dc1y dc2x, dx dc2y, dy ) • Quadratic : (Q cx, cy x, y) or (q dcx, dcy, dx, dy)
  • 17. Paths Friday, December 4, 2015 www.qsoftvietnam.com 17 Quadratic : There is a shortcut for stringing together multiple quadratic Beziers, T.
  • 18. Paths Friday, December 4, 2015 www.qsoftvietnam.com 18  Arcto The other type of curved line you can create using SVG is the arc, A. Arcs are sections of circles or ellipses. For a given x-radius and y-radius, there are two ellipses that can connect any two points (as long as they're within the radius of the circle). Along either of those circles there are two possible paths that you can take to connect the points, so in any situation there are four possible arcs available.  A rx ry x-axis-rotation large-arc-flag sweep-flag x y  a rx ry x-axis-rotation large-arc-flag sweep-flag dx dy
  • 19. Paths Friday, December 4, 2015 www.qsoftvietnam.com 19  ClosePath The ClosePath command will simply draw a straight line from the current position to the first point in the path. It is the simplest command, and takes no parameters. It will take the shortest linear path to the starting point, intersecting other paths if they fall in the way. The syntax is "Z" or "z", and both will react exactly the same.
  • 20. Fills & Strokes Friday, December 4, 2015 www.qsoftvietnam.com 20  Fill sets the color inside the object  Stroke sets the color of the line drawn around the object Color Fill & Stroke Css
  • 21. Fills & Strokes Friday, December 4, 2015 www.qsoftvietnam.com 21 • width • height • path commands • d Can't be set through CSS The SVG specification decides strictly between attributes, that are properties and other attributes. The former can be modified with CSS, the latter not.
  • 22. Fills & Strokes attributes Friday, December 4, 2015 www.qsoftvietnam.com 22 • stroke • stroke-width • stroke-linecap – butt – square – round • stroke-dasharray – number,number,number … • stroke-opacity • fill • fill-opacity
  • 23. Friday, December 4, 2015 www.qsoftvietnam.com 23 Fills & Strokes Use?
  • 24. Gradients Friday, December 4, 2015 www.qsoftvietnam.com 24  Linear Gradient  Radial Gradient  Linear Gradient • 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
  • 25. Friday, December 4, 2015 www.qsoftvietnam.com 25
  • 26. Gradients Friday, December 4, 2015 www.qsoftvietnam.com 26  Radial Gradient • cx, cy, r, fx, fy • Center and Focal point • cx, cy, r, fx, fy : 0.25 = 25% • spreadMethod • pad • repeat • reflect
  • 27. Friday, December 4, 2015 www.qsoftvietnam.com 27
  • 28. Friday, December 4, 2015 www.qsoftvietnam.com 28
  • 29. Patterns Friday, December 4, 2015 www.qsoftvietnam.com 29  Like gradients, the <pattern> element should be put in the <defs> section of your SVG file.
  • 30. Friday, December 4, 2015 www.qsoftvietnam.com 30 Patterns
  • 31. Patterns Friday, December 4, 2015 www.qsoftvietnam.com 31  patternUnits="userSpaceOnUse“  patternContentUnits="objectBoundingBox"
  • 32. Animation Friday, December 4, 2015 www.qsoftvietnam.com 32  <set>  <animate>  <animateTransform>  <animateMotion>  <animateColor>
  • 33. Animation Friday, December 4, 2015 www.qsoftvietnam.com 33  Set The set element is the simplest of the SVG animation elements. It simply sets an attribute to a certain value after a specific time interval has passed. As such, the shape is not continuously animating, but just changes attribute value once. <set attributeName="r" attributeType="XML" to="100" begin="0s“ />
  • 34. Animation Friday, December 4, 2015 www.qsoftvietnam.com 34  Animate The animate element is used to animate an attribute of an SVG shape. <animate attributeName="cx" attributeType="XML" from="30" to="470" begin="0s" dur="5s" fill="remove" repeatCount="indefinite" />
  • 35. Animation Friday, December 4, 2015 www.qsoftvietnam.com 35  Animate Tranform The <animateTransform> element can animate the transform attribute of a shape. The <animate> element cannot do that. <animateTransform attributeName="transform" type="rotate" from="0 100 100" to="360 100 100" begin="0s" dur="10s" repeatCount="indefinite" />
  • 36. Animation Friday, December 4, 2015 www.qsoftvietnam.com 36  Animate Motion The <animateMotion> element can animate the movement of a shape along a path. It can also rotate the shape to match the slope of the path, like a car driving up and down hill. <animateMotion path="M10,50 q60,50 100,0 q60,-50 100,0" begin="0s" dur="10s" repeatCount="indefinite" rotate="auto" />
  • 37. Friday, December 4, 2015 www.qsoftvietnam.com 37 Texts <text> Bringing text into an SVG image <text> x dy dxy rotate
  • 38. Friday, December 4, 2015 www.qsoftvietnam.com 38 Texts <svg viewBox = "0 0 200 200" version = "1.1"> <text x = "10" y = "25" fill = "red" transform="rotate(30 20,40)" font-size = "15"> Example </text> <text x="0" y="0" dx = "10" dy = "40" fill = "blue" transform="rotate(30 20,40)" font-size = "15"> Example </text> </svg>
  • 39. Friday, December 4, 2015 www.qsoftvietnam.com 39 Texts -TextPath • In addition to text drawn in a straight line, SVG also includes the ability to place text along the shape of a <path> element. • To specify that a block of text is to be rendered along the shape of a <path>, include the given text within a textPath element which includes an xlink:href attribute with a reference to a <path> element.
  • 40. Friday, December 4, 2015 www.qsoftvietnam.com 40
  • 41. Friday, December 4, 2015 www.qsoftvietnam.com 41 Transformations • Translation • Rotation • Embedding SVG in SVG • Skewing • Scaling • Complex transformations with matrix() • Effects on Coordinate Systems
  • 42. Friday, December 4, 2015 www.qsoftvietnam.com 42 Transformations  Translation • It may be necessary to move an element around, even though you can position it with the according attributes. For this purpose, the translate()transformation stands ready. • translate(x,y)
  • 43. Friday, December 4, 2015 www.qsoftvietnam.com 43 Transformations  Rotation • rorate(degrees) • This example shows a square that is rotated by 45 degrees.
  • 44. Friday, December 4, 2015 www.qsoftvietnam.com 44 Clipping • Clipping refers to removing parts of elements defined by other parts. • In this case, any half-transparent effects are not possible, it's an all-or-nothing approach. • <clipPath > • clip-path="url(#...)"
  • 45. Friday, December 4, 2015 www.qsoftvietnam.com 45 SVG Image Tag
  • 46. Friday, December 4, 2015 www.qsoftvietnam.com 46 Tools for SVG • Inkscape https://inkscape.org • Adobe Illustrator http://www.adobe.com/products/illustrator • Apache Batik http://xmlgraphics.apache.org/batik/
  • 47. Friday, December 4, 2015 www.qsoftvietnam.com 47 Reference • http://www.w3schools.com/svg/default.asp • http://tutorials.jenkov.com/svg • https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial • https://developer.mozilla.org/en- US/docs/Web/API/SVGAElement • https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute
  • 48. THANK YOU FOR YOUR ATTENTION! Friday, December 4, 2015 www.qsoftvietnam.com 48

Editor's Notes

  1. baseProfile : thuộc tính luôn luôn nên sử dụng để thay thế
  2. Mx,y: tọa độ điểm tuyệt đối bắt đầu vẽ mx,y: tọa độ điểm tương đối so với x,y
  3. Vẽ một đường thẳng
  4. Bezier: có rất nhiều các loại đường cong Cubic và Quadratic là hai loại đơn giản mà path hỗ trợ Cubic là đường cong 1 khối Quadratic là đường cong bậc 2
  5. T : Sâu chuỗi nhiều đường cong bậc hai
  6. Vẽ các loại đường cong khác. Có 2 hình tròn hoặc elip giao nhau tại điểm đầu lệnh M và điểm cuối là x, y được tạo ra tương ứng 4 vòng cung Rx bán kính ngang, Ry bán kính dọc, x-axis-rotation mô tả chuyển động quay. large-arc-flag vòng cung cần lấy nhỏ hơn 180 độ (0) hay lớn hơn 180 độ (1) sweep-flag kết hợp large-arc-flag : rơi vào 1 trong 4 case. Tâm đường tròn nối hai điểm giao, vòng tròn < 180 hay > 180, kết hợp theo case sẽ ra hình
  7. Nối từ điểm hiện tại đến điểm đầu tiên của path
  8. sdfasdfasdfas
  9. Màu mặc định là màu đen. x1, x2, y1, y2 là điểm bắt đầu và kết thúc Mặc định là x1 != x2, y1 = y2 defs: được định nghĩa để chứa các yếu tố đặc biệt
  10. Màu mặc định là màu đen. Mặc định là x1 != x2, y1 = y2
  11. Focal: tiêu điểm
  12. Tự động nhân bản dựa theo kích thước của patterns
  13. Làm một hình có thể chuyển động
  14. Làm biến đổi thuộc tính của một hình mà animate không thể làm được
  15. Chạy theo một đường path
  16. Translate(x,y) dịch chuyển, cộng thêm vào tọa độ x, y tuyệt đối
  17. Loại bỏ các phần của hình dựa trên hình khác. Việc giữ lại phần đó bằng cách làm trong suốt là không thể làm được.
  18. Nhúng một image vào svg. Dùng định dạng <img src=“”/> của html vẫn chèn được nhưng sẽ không sử dụng được các thuộc tính của svg cung cấp