1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
---
title: معرفی SVG
slug: Web/SVG/Tutorial/Introduction
translation_of: Web/SVG/Tutorial/Introduction
---
<p>{{ PreviousNext("Web/SVG/Tutorial", "Web/SVG/Tutorial/Getting_Started") }}</p>
<p><img alt="" class="internal" src="/@api/deki/files/348/=SVG_Overview.png" style="float: right;"></p>
<p dir="rtl">SVG یگ زبان نشانه گذاری مبتنی بر XML و شبیه به XHTML است که برای طراحی گرافیکی استفاده میشود مانند تصاویری که سمت راست میبینید.با استفاده از آن هم می توان تصاویری متشکل از خطوط و اشکال هندسی متفاوت ساخت هم تصاویری که به اصطلاح <a href="https://fa.wikipedia.org/wiki/%DA%AF%D8%B1%D8%A7%D9%81%DB%8C%DA%A9_%D8%B4%D8%B7%D8%B1%D9%86%D8%AC%DB%8C">گرافیک شطرنجی</a> خوانده می شوند ویا حتی ترکیبی از هر دو. این نوع تصاویر و اجزایشان میتوانند تبدیل شوند یا با هم مخلوط شوند یا حتی فیلترسازی (فیلتر ها در فتوشاپ یا css) شده تا ظاهرشان به کلی تغییر کند.</p>
<p dir="rtl">SVG حدود سال های 1999 بعد از چندین رقابت فرمت ها(زبان های دیگر مبتنی بر XML) به <a href="https://w3.org">W3C </a>ارسال شد و از تصویب رسمی و کامل باز ماند. با اینکه این وضع برای مدت کوتاهی بود باز هم پشتیبانی مرورگر ها به کندی صورت میگرفت به همین دلیل استفاده گسترده ای از SVG در فضای وب نمیشود(این آمار مربوط به سال 2009 است اکنون یعنی در سال 2016 از SVG برای ساخت وبسایت ها و وب اپلیکیشن ها استفاده فراوانی می شود).</p>
<p>Even the implementations that are available often are not as fast as competing technologies like <a href="/en-US/HTML/Canvas" title="en-US/HTML/Canvas">HTML5 Canvas</a> or Adobe Flash as a full application interface. SVG does offer benefits over both implementations, some of which include having a <a href="/en-US/docs/Web/API">DOM interface</a> available for it, and not requiring third-party extensions. Whether or not to use it often depends on your specific use case.</p>
<h3 id="Basic_ingredients">Basic ingredients</h3>
<p><a href="/en-US/docs/Web/HTML">HTML</a> provides elements for defining headers, paragraphs, tables, and so on. In much the same way SVG provides elements for circles, rectangles, and simple and complex curves. A simple SVG document consists of nothing more than the {{ SVGElement('svg') }} root element and several basic shapes that build a graphic together. In addition there is the {{ SVGElement('g') }} element, which is used to group several basic shapes together.</p>
<p>Starting from there, the SVG image can become arbitrarily complex. SVG supports gradients, rotations, filter effects, animations, interactivity with JavaScript, and so on. But all these extra features of the language rely on this relatively small set of elements to define the graphic area.</p>
<h3 id="Before_you_start" name="Before_you_start">Before you start</h3>
<p>There are a number of drawing applications available such as <a class="external" href="http://www.inkscape.org/">Inkscape</a> which are free and use SVG as their native file format. However, this tutorial will rely on the trusty XML or text editor (your choice). The idea is to teach the internals of SVG to those who want to understand it, and that is best done by dirtying your hands with a bit of markup. You should note your final goal though. Not all SVG viewers are equal and so there is a good chance that something written for one app will not display exactly the same in another, simply because they support different levels of the SVG specification or another specification that you are using along with SVG (that is, <a href="/en-US/JavaScript" title="en-US/JavaScript">JavaScript</a> or <a href="/en-US/CSS" title="en-US/CSS">CSS</a>).</p>
<p>SVG is supported in all modern browsers and even a couple versions back in some cases. A fairly complete browser support table can be found on <a href="http://caniuse.com/svg">Can I use</a>. Firefox has supported some SVG content since version 1.5, and that support level has been growing with each release since. Hopefully, along with the tutorial here, MDN can help developers keep up with the differences between Gecko and some of the other major implementations.</p>
<p>Before starting you should have a basic understanding of XML or another markup language such as <abbr title="HyperText Markup Language">HTML</abbr>. If you are not too familiar with XML, here are some guidelines to keep in mind:</p>
<ul>
<li>SVG elements and attributes should all be entered in the case shown here since XML is case-sensitive (unlike HTML).</li>
<li>Attribute values in SVG must be placed inside quotes, even if they are numbers.</li>
</ul>
<p>SVG is a huge specification. This tutorial attempts to cover the basics. Once you are familiar you should be able to use the <a href="/en-US/SVG/Element" title="en-US/SVG/Element">Element Reference</a> and the <a href="/en-US/docs/DOM/DOM_Reference#SVG_interfaces" title="en-US/SVG/Interface">Interface Reference</a> to find out anything else you need to know.</p>
<h3 id="Flavors_of_SVG">Flavors of SVG</h3>
<p>Since becoming a recommendation in 2003, the most recent "full" SVG version is 1.1. It builds on top of SVG 1.0, but adds more modularization to ease implementation. <a href="http://www.w3.org/TR/SVG/">The second edition of SVG 1.1</a> became a Recommendation in 2011. "Full" SVG 1.2 was meant to be the next major release of SVG. It was dropped for the upcoming <a href="http://www.w3.org/TR/SVG2/">SVG 2.0</a>, which is under heavy development right now and follows a similar approach to CSS 3 in that it splits components in several loosely coupled specifications.</p>
<p>Apart from the full SVG recommendations, the working group at the W3C introduced SVG Tiny and SVG Basic in 2003. These two profiles are aimed mainly at mobile devices. The first, SVG Tiny, should yield graphic primitives for small devices with low capabilities. SVG Basic offers many features of full SVG, but doesn't include the ones which are hard to implement or heavy to render (like animations). In 2008, SVG Tiny 1.2 became a W3C Recommendation.</p>
<p>There were plans for an SVG Print specification, which would add support for multiple pages and enhanced color management. This work was discontinued.</p>
<p>{{ PreviousNext("Web/SVG/Tutorial", "Web/SVG/Tutorial/Getting_Started") }}</p>
|