Scalable vector graphics

12
SCALABLE VECTOR GRAPHICS BS Study

Transcript of Scalable vector graphics

Page 1: Scalable vector graphics

SCALABLE VECTOR GRAPHICS

BS Study

Page 2: Scalable vector graphics

Why SVG?

SVG is a DOM element

Search

Index

Scripting

Etc…

Page 3: Scalable vector graphics

Why not VML?

ECMA-376에규정

M$ office용으로개발

XML 표준개무시

IE9 이후안녕~~

Page 4: Scalable vector graphics

Basic SVG tags

tagName 비고

<svg> 모든 svg element의바탕

<line> 선긋기

<circle> 원

<ellipse> 타원

<rect> 사각형

<text> 텍스트

<g> 도형그룹

<path> 자유곡선

Page 5: Scalable vector graphics

Let’s get started…

<svg width="100" height="100">

<circle cx="50" cy="50" r="40"

fill="yellow" stroke="black"

stroke-width="5" stroke-dasharray="5, 2"

/>

</svg>

http://ligo.kr/vdd

Page 6: Scalable vector graphics

Create a SVG element

document.createElement('svg'); // <- does not work!

document.createElementNS(

'http://www.w3.org/2000/svg', 'svg'

); // <- it works

Page 7: Scalable vector graphics

Styling SVG element

svgElement.setAttribute(key, value);

Page 8: Scalable vector graphics

http://ligo.kr/vdd

시계를 대충 만들어 봅시다 :D

Page 9: Scalable vector graphics

How to build up radial coordinates?

x : sin(Θ) * r

y : -cos(Θ) * r

(※ 360˚ = 2πrad)

x: cx + Math.sin(Θ) * r,

y: cy - Math.cos(Θ) * r

Θ

Page 10: Scalable vector graphics

line cap, line join

linecap 비고

butt

round

square

linejoin 비고

miter

round

bevel

Page 11: Scalable vector graphics

Date object

var date = new Date();

date.getHours();

date.getMinutes();

date.getSeconds();

date.getMilliseconds();

Page 12: Scalable vector graphics

fin.

Thank you!!

[email protected]://facebook.com/overockaffehttp://twitter.com/overockaffe