svg basics

32
SVG Scalable Vector Graphics

Upload: michael-van-engelshoven

Post on 01-Sep-2014

329 views

Category:

Technology


2 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Svg Basics

SVGScalable Vector Graphics

Page 2: Svg Basics

Im Vergleich zu z.B. PNG

firefox.png firefox.svg128px × 128px ∞

21KB 46KB21KB (gzip) 13KB (gzip)

Page 3: Svg Basics

Browser-Support

3.0+ 4.0+ 3.1+ 9.0+ 9.0+

Page 4: Svg Basics

XML-Dokument<?xml version="1.0" encoding="UTF-8" standalone="no"?>

<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="400" height="300"> <!-- ... --> </svg>

Page 5: Svg Basics

Basiselemente

Page 6: Svg Basics

Rechtecke

<rect width="66" height="30" x="21" y="32" />

Page 7: Svg Basics

Kreise & Ellipsen

<circle cx="75" cy="100" r="50" />

<ellipse cx="200" cy="150" rx="150" ry="75" />

Page 8: Svg Basics

Pfade

<path d="M 12,10 C 39,22 43,50 9,52 C 62,114 101,145 101,145" />

Page 9: Svg Basics

Polygone

<path d="M 149,109 L 149,127 L 127,144 L 140,172 L 188,167 L 191,119 z" />

Page 10: Svg Basics

Text

Hello, out there

<text x="0" y="150" font-family="Verdana" font-size="45" fill="#c4a000"> Hello, out there</text>

Page 11: Svg Basics

Styling der Elemente

Page 12: Svg Basics

Stroke

<circle ... stroke="red" stroke-width="5" stroke-opacity=".5" />

Page 13: Svg Basics

Gestrichelte Linien

<rect ... stroke="blue" stroke-width="2" stroke-dashArray="20 5 10 5" />

Page 14: Svg Basics

Fill

<circle ... fill="rgb(255, 0, 0)" fill-opacity=".5" />

Page 15: Svg Basics

Styling auch per CSSsvg rect.someClass { stroke: #0283c5; stroke-width: 6; fill: none;}

Page 16: Svg Basics

Transformationen

Page 17: Svg Basics

Verschiebung

<rect x="150" y="100" width="100" height="100" ... transform="translate(-50 -50)" />

Page 18: Svg Basics

Skalierung

<rect x="150" y="100" width="100" height="100" ... transform="scale(.75, 1.5)" />

Page 19: Svg Basics

Skalierung um das Zentrum

<!-- translate(-centerX*(factor-1), -centerY*(factor-1)) scale(factor) -->

<rect x="150" y="100" width="100" height="100" transform="translate(50, -75) scale(.75, 1.5)" />

Page 20: Svg Basics

Drehung

<rect x="150" y="100" width="100" height="100" ... transform="rotate(45 200 150)" />

Page 21: Svg Basics

Scherung X-Achse

<rect x="150" y="100" width="100" height="100" ... transform="skewX(20)" />

Page 22: Svg Basics

Scherung Y-Achse

<rect x="150" y="100" width="100" height="100" ... transform="skewY(20)" />

Page 23: Svg Basics

Gruppierung von Elementen

<g stroke="#73d216" fill="#73d216" fill-opacity="0.4" stroke-width="3" fill="none" <rect x="0" y="0" width="200" stroke="red" height="150" /> <ellipse cx="200" cy="150" rx="150" ry="75" /></g>

Page 24: Svg Basics

Clipping

<clipPath id="clip-box"> <rect x="0" y="0" width="200" height="150" /></clipPath>

<ellipse cx="200" cy="150" rx="150" ry="75" />

Page 25: Svg Basics

SVG in HTML einbinden

Page 26: Svg Basics

Inline im HTML verwenden<h1>Some Heading</h1><div class="image"> <svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="400" height="300"

<!-- ... -->

</svg></div>

Page 27: Svg Basics

Als externes Bild einbinden<img class="logo" src="myImage.svg" />

Page 28: Svg Basics

Als CSS-Background einbinden.logo { display: block; text-indent: -9999px; width: 279px; height: 132px; background: url(brainbits.svg); background-size: 279px 132px;}

Page 29: Svg Basics

Fallback z.B. mit Modernizr<img class="logo" src="myImage.svg" data-fallback="myImage.png" />

<script>

</script>

if (!Modernizr.svg) { var image = $("img.logo"); image.attr("src", image.data('fallback')); }

Page 30: Svg Basics

Viel Spass!

http://slidesha.re/W1R1Nh

Page 31: Svg Basics

ReferenzenScalable Vector Graphics – WikipediaW3C Recommendation – SVG 1.1 2nd EditionO'Reily SVG Essentials – Transforming theCoordinate SystemCSS-Tricks – Using SVG

© 2013 Michael van Engelshoven

Page 32: Svg Basics

© 2013 Michael van Engelshoven