-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
1141 lines (1038 loc) · 34.6 KB
/
index.md
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
---
title: d
slug: Web/SVG/Attribute/d
page-type: svg-attribute
browser-compat: svg.elements.path.d
---
{{SVGRef}}
The **`d`** attribute defines a path to be drawn.
A path definition is a list of [path commands](#path_commands) where each command is composed of a command letter and numbers that represent the command parameters.
The commands are [detailed below](#path_commands).
You can use this attribute with the following SVG elements: [`<path>`](#path), [`<glyph>`](#glyph), [`<missing-glyph>`](#missing-glyph).
`d` is a presentation attribute, and hence can also be [used as a CSS property](#using_d_as_a_css_property).
## Example
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path
fill="none"
stroke="red"
d="M 10,30
A 20,20 0,0,1 50,30
A 20,20 0,0,1 90,30
Q 90,60 50,90
Q 10,60 10,30 z" />
</svg>
```
{{EmbedLiveSample('Example', '100%', 200)}}
## path
For {{SVGElement('path')}}, `d` is a string containing a series of path commands that define the path to be drawn.
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td>
<strong><a href="/en-US/docs/Web/SVG/Content_type#string"><string></a></strong>
</td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><em>none</em></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>Yes</td>
</tr>
</tbody>
</table>
## glyph
> **Warning:** As of SVG2 {{SVGElement('glyph')}} is deprecated and shouldn't be used.
For {{SVGElement('glyph')}}, `d` is a string containing a series of path commands that define the outline shape of the glyph.
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td>
<strong><a href="/en-US/docs/Web/SVG/Content_type#string"><string></a></strong>
</td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><em>none</em></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>Yes</td>
</tr>
</tbody>
</table>
> **Note:** The point of origin (the coordinate `0`, `0`) is usually the _upper left corner_ of the context. However the {{SVGElement("glyph")}} element has its origin in the _bottom left corner_ of its letterbox.
## missing-glyph
> **Warning:** As of SVG2 {{SVGElement('missing-glyph')}} is deprecated and shouldn't be used.
For {{SVGElement('missing-glyph')}}, `d` is a string containing a series of path commands that define the outline shape of the glyph.
<table class="properties">
<tbody>
<tr>
<th scope="row">Value</th>
<td>
<strong><a href="/en-US/docs/Web/SVG/Content_type#string"><string></a></strong>
</td>
</tr>
<tr>
<th scope="row">Default value</th>
<td><em>none</em></td>
</tr>
<tr>
<th scope="row">Animatable</th>
<td>Yes</td>
</tr>
</tbody>
</table>
## Using d as a CSS property
`d` is a presentation attribute, and hence can be also be modified using CSS.
The property takes either [path()](/en-US/docs/Web/CSS/basic-shape/path) or `none`.
The example below shows how you might apply a new path on hover over an element.
The new path is the same as the old one, but adds a line across the heart.
```css
html,
body,
svg {
height: 100%;
}
/* This path is displayed on hover*/
#svg_css_ex1:hover path {
d: path(
"M10,30 A20,20 0,0,1 50,30 A20,20 0,0,1 90,30 Q90,60 50,90 Q10,60 10,30 z M5,5 L90,90"
);
}
```
```html
<svg id="svg_css_ex1" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path
fill="none"
stroke="red"
d="M 10,30
A 20,20 0,0,1 50,30
A 20,20 0,0,1 90,30
Q 90,60 50,90
Q 10,60 10,30 z
" />
</svg>
```
{{EmbedLiveSample('Using d as a CSS Property', '100%', 200)}}
## Path commands
Path commands are instructions that define a path to be drawn. Each command is composed of a command letter and numbers that represent the command parameters.
SVG defines 6 types of path commands, for a total of 20 commands:
- [MoveTo](#moveto_path_commands): `M`, `m`
- [LineTo](#lineto_path_commands): `L`, `l`, `H`, `h`, `V`, `v`
- [Cubic Bézier curve](#cubic_bézier_curve): `C`, `c`, `S`, `s`
- [Quadratic Bézier curve](#quadratic_bézier_curve): `Q`, `q`, `T`, `t`
- [Elliptical arc curve](#elliptical_arc_curve): `A`, `a`
- [ClosePath](#closepath): `Z`, `z`
> **Note:** Commands are _case-sensitive_. An upper-case command specifies absolute coordinates, while a lower-case command specifies coordinates relative to the current position.
It is always possible to specify a negative value as an argument to a command:
- negative angles will be anti-clockwise;
- _absolute_ negative _x_ and _y_ values are interpreted as negative coordinates;
- _relative_ negative _x_ values move to the left, and relative negative _y_ values move upwards.
### MoveTo path commands
_MoveTo_ instructions can be thought of as picking up the drawing instrument, and setting it down somewhere else—in other words, moving the _current point_ (_P<sub>o</sub>_; {_x<sub>o</sub>_, _y<sub>o</sub>_}). There is no line drawn between _P<sub>o</sub>_ and the new _current point_ (_P<sub>n</sub>_; {_x<sub>n</sub>_, _y<sub>n</sub>_}).
<table class="no-markdown">
<tbody>
<tr>
<th scope="col">Command</th>
<th scope="col">Parameters</th>
<th scope="col">Notes</th>
</tr>
<tr>
<th scope="row">M</th>
<td>
(<code><var>x</var></code
>, <code><var>y</var></code
>)+
</td>
<td>
<p>
Move the <em>current point</em> to the coordinate
<code><var>x</var></code
>,<code><var>y</var></code
>. Any subsequent coordinate pair(s) are interpreted as parameter(s)
for implicit absolute LineTo (<code>L</code>) command(s) (<em
>see below</em
>).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>n</sub></var> = {<code
><var>x</var></code
>, <code><var>y</var></code
>}
</p>
</td>
</tr>
<tr>
<th scope="row">m</th>
<td>
(<code><var>dx</var></code
>, <code><var>dy</var></code
>)+
</td>
<td>
<p>
Move the <em>current point</em> by shifting the last known position of
the path by <code><var>dx</var></code> along the x-axis and by
<code><var>dy</var></code> along the y-axis. Any subsequent coordinate
pair(s) are interpreted as parameter(s) for implicit relative LineTo
(<code>l</code>) command(s) (<em>see below</em>).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>n</sub></var> = {<var
>x<sub>o</sub></var
>
+ <code><var>dx</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>}
</p>
</td>
</tr>
</tbody>
</table>
#### Examples
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<path
fill="none"
stroke="red"
d="M 10,10 h 10
m 0,10 h 10
m 0,10 h 10
M 40,20 h 10
m 0,10 h 10
m 0,10 h 10
m 0,10 h 10
M 50,50 h 10
m-20,10 h 10
m-20,10 h 10
m-20,10 h 10" />
</svg>
```
{{EmbedLiveSample('MoveTo_path_commands', '100%', 200)}}
### LineTo path commands
_LineTo_ instructions draw a straight line from the _current point_ (_P<sub>o</sub>_; {_x<sub>o</sub>_, _y<sub>o</sub>_}) to the _end point_ (_P<sub>n</sub>_; {_x<sub>n</sub>_, _y<sub>n</sub>_}), based on the parameters specified. The _end point_ (_P<sub>n</sub>_) then becomes the _current point_ for the next command (_P<sub>o</sub>′_).
<table class="no-markdown">
<tbody>
<tr>
<th scope="col">Command</th>
<th scope="col">Parameters</th>
<th scope="col">Notes</th>
</tr>
<tr>
<th scope="row">L</th>
<td>(<code>x</code>, <code>y</code>)+</td>
<td>
<p>
Draw a line from the <em>current point</em> to the
<em>end point</em> specified by <code><var>x</var></code
>,<code><var>y</var></code
>. Any subsequent coordinate pair(s) are interpreted as parameter(s)
for implicit absolute LineTo (<code>L</code>) command(s).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<code><var>x</var></code
>, <code><var>y</var></code
>}
</p>
</td>
</tr>
<tr>
<th scope="row">l</th>
<td>
(<code><var>dx</var></code
>, <code><var>dy</var></code
>)+
</td>
<td>
<p>
Draw a line from the <em>current point</em> to the
<em>end point,</em> which is the <em>current point</em> shifted by
<code><var>dx</var></code> along the x-axis and
<code><var>dy</var></code> along the y-axis. Any subsequent coordinate
pair(s) are interpreted as parameter(s) for implicit relative LineTo
(<code>l</code>) command(s) (<em>see below</em>).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<var>x<sub>o</sub></var> +
<code><var>dx</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>}
</p>
</td>
</tr>
<tr>
<th scope="row">H</th>
<td>
<code><var>x</var></code
>+
</td>
<td>
<p>
Draw a horizontal line from the <em>current point</em> to the
<em>end point</em>, which is specified by the
<code><var>x</var></code> parameter and the <em>current point's</em>
<code>y</code> coordinate. Any subsequent value(s) are interpreted as
parameter(s) for implicit absolute horizontal LineTo (<code>H</code>)
command(s).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<code><var>x</var></code
>, <var>y<sub>o</sub></var
>}
</p>
</td>
</tr>
<tr>
<th scope="row">h</th>
<td>
<code><var>dx</var></code
>+
</td>
<td>
<p>
Draw a horizontal line from the <em>current point</em> to the
<em>end point,</em> which is specified by the
<em>current point</em> shifted by <code><var>dx</var></code> along the
x-axis and the <em>current point's</em> <code>y</code> coordinate. Any
subsequent value(s) are interpreted as parameter(s) for implicit
relative horizontal LineTo (<code>h</code>) command(s).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<var>x<sub>o</sub></var> +
<code><var>dx</var></code
>, <var>y<sub>o</sub></var
>}
</p>
</td>
</tr>
<tr>
<th scope="row">V</th>
<td>
<code><var>y</var></code
>+
</td>
<td>
<p>
Draw a vertical line from the <em>current point</em> to the
<em>end point</em>, which is specified by the
<code><var>y</var></code> parameter and the <em>current point's</em>
<code>x</code> coordinate. Any subsequent values are interpreted as
parameters for implicit absolute vertical LineTo (<code>V</code>)
command(s).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<var>x<sub>o</sub></var
>, <code><var>y</var></code
>}
</p>
</td>
</tr>
<tr>
<th scope="row">v</th>
<td>
<code><var>dy</var></code
>+
</td>
<td>
<p>
Draw a vertical line from the <em>current point</em> to the
<em>end point,</em> which is specified by the
<em>current point</em> shifted by <code><var>dy</var></code> along the
y-axis and the <em>current point's</em> <code>x</code> coordinate. Any
subsequent value(s) are interpreted as parameter(s) for implicit
relative vertical LineTo (<code>v</code>) command(s).
</p>
<p>
<strong>Formula:</strong> <var>P<sub>o</sub>′</var> =
<var>P<sub>n</sub></var> = {<var>x<sub>o</sub></var
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>}
</p>
</td>
</tr>
</tbody>
</table>
#### Examples
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg viewBox="0 0 200 100" xmlns="http://www.w3.org/2000/svg">
<!-- LineTo commands with absolute coordinates -->
<path
fill="none"
stroke="red"
d="M 10,10
L 90,90
V 10
H 50" />
<!-- LineTo commands with relative coordinates -->
<path
fill="none"
stroke="red"
d="M 110,10
l 80,80
v -80
h -40" />
</svg>
```
{{EmbedLiveSample('LineTo_path_commands', '100%', 200)}}
### Cubic Bézier curve
_Cubic [Bézier curves](/en-US/docs/Glossary/Bezier_curve)_ are smooth curve definitions using four points:
- starting point (current point)
- : (_P<sub>o</sub>_ = {_x<sub>o</sub>_, _y<sub>o</sub>_})
- end point
- : (_P<sub>n</sub>_ = {_x<sub>n</sub>_, _y<sub>n</sub>_})
- start control point
- : (_P<sub>cs</sub>_ = {_x<sub>cs</sub>_, _y<sub>cs</sub>_})
(controls curvature near the start of the curve)
- end control point
- : (_P<sub>ce</sub>_ = {_x<sub>ce</sub>_, _y<sub>ce</sub>_})
(controls curvature near the end of the curve)
After drawing, the _end point_ (_P<sub>n</sub>_) becomes the _current point_ for the next command (_P<sub>o</sub>′_).
<table class="no-markdown">
<tbody>
<tr>
<th scope="col">Command</th>
<th scope="col">Parameters</th>
<th scope="col">Notes</th>
</tr>
<tr>
<th scope="row">C</th>
<td>
(<code><var>x1</var></code
>,<code><var>y1</var></code
>, <code><var>x2</var></code
>,<code><var>y2</var></code
>, <code><var>x</var></code
>,<code><var>y</var></code
>)+
</td>
<td>
<p>
Draw a cubic Bézier curve from the <em>current point</em> to the
<em>end point</em> specified by <code><var>x</var></code
>,<code><var>y</var></code
>. The <em>start control point</em> is specified by
<code><var>x1</var></code
>,<code><var>y1</var></code> and the <em>end control point</em> is
specified by <code><var>x2</var></code
>,<code><var>y2</var></code
>. Any subsequent triplet(s) of coordinate pairs are interpreted as
parameter(s) for implicit absolute cubic Bézier curve (<code>C</code>)
command(s).
</p>
<dl>
<dt>Formulae:</dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<code
><var>x</var></code
>, <code><var>y</var></code
>} ;<br /><var>P<sub>cs</sub></var> = {<code><var>x1</var></code
>, <code><var>y1</var></code
>} ;<br /><var>P<sub>ce</sub></var> = {<code><var>x2</var></code
>, <code><var>y2</var></code
>}
</dd>
</dl>
</td>
</tr>
<tr>
<th scope="row">c</th>
<td>
(<code><var>dx1</var></code
>,<code><var>dy1</var></code
>, <code><var>dx2</var></code
>,<code><var>dy2</var></code
>, <code><var>dx</var></code
>,<code><var>dy</var></code
>)+
</td>
<td>
<p>
Draw a cubic Bézier curve from the <em>current point</em> to the
<em>end point,</em> which is the <em>current point</em> shifted by
<code><var>dx</var></code> along the x-axis and
<code><var>dy</var></code> along the y-axis. The
<em>start control point</em> is the <em>current point</em> (starting
point of the curve) shifted by <code><var>dx1</var></code> along the
x-axis and <code><var>dy1</var></code> along the y-axis. The
<em>end control point</em> is the <em>current point</em> (starting
point of the curve) shifted by <code><var>dx2</var></code> along the
x-axis and <code><var>dy2</var></code> along the y-axis. Any
subsequent triplet(s) of coordinate pairs are interpreted as
parameter(s) for implicit relative cubic Bézier curve (<code>c</code>)
command(s).
</p>
<dl>
<dt>Formulae:</dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<var
>x<sub>o</sub></var
>
+ <code><var>dx</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>} ;<br /><var>P<sub>cs</sub></var> = {<var>x<sub>o</sub></var> +
<code><var>dx1</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy1</var></code
>} ;<br /><var>P<sub>ce</sub></var> = {<var>x<sub>o</sub></var> +
<code><var>dx2</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy2</var></code
>}
</dd>
</dl>
</td>
</tr>
<tr>
<th scope="row">S</th>
<td>
(<code><var>x2</var></code
>,<code><var>y2</var></code
>, <code><var>x</var></code
>,<code><var>y</var></code
>)+
</td>
<td>
Draw a smooth cubic Bézier curve from the <em>current point</em> to the
<em>end point</em> specified by <code><var>x</var></code
>,<code><var>y</var></code
>. The <em>end control point</em> is specified by
<code><var>x2</var></code
>,<code><var>y2</var></code
>. The <em>start control point</em> is the reflection of the
<em>end control point</em> of the previous curve command about the <em>current point</em>. If the
previous command wasn't a cubic Bézier curve, the
<em>start control point</em> is the same as the curve starting point
(<em>current point</em>). Any subsequent pair(s) of coordinate pairs are
interpreted as parameter(s) for implicit absolute smooth cubic Bézier
curve (<code>S</code>) commands.
</td>
</tr>
<tr>
<th scope="row">s</th>
<td>
(<code><var>dx2</var></code
>,<code><var>dy2</var></code
>, <code><var>dx</var></code
>,<code><var>dy</var></code
>)+
</td>
<td>
Draw a smooth cubic Bézier curve from the <em>current point</em> to the
<em>end point</em>, which is the <em>current point</em> shifted by
<code><var>dx</var></code> along the x-axis and
<code><var>dy</var></code> along the y-axis. The
<em>end control point</em> is the <em>current point</em> (starting point
of the curve) shifted by <code><var>dx2</var></code> along the x-axis
and <code><var>dy2</var></code> along the y-axis. The
<em>start control point</em> is the reflection of the
<em>end control point</em> of the previous curve command about the <em>current point</em>. If the
previous command wasn't a cubic Bézier curve, the
<em>start control point</em> is the same as the curve starting point
(<em>current point</em>). Any subsequent pair(s) of coordinate pairs are
interpreted as parameter(s) for implicit relative smooth cubic Bézier
curve (<code>s</code>) commands.
</td>
</tr>
</tbody>
</table>
#### Examples
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg
viewBox="0 0 200 100"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Cubic Bézier curve with absolute coordinates -->
<path
fill="none"
stroke="red"
d="M 10,90
C 30,90 25,10 50,10
S 70,90 90,90" />
<!-- Cubic Bézier curve with relative coordinates -->
<path
fill="none"
stroke="red"
d="M 110,90
c 20,0 15,-80 40,-80
s 20,80 40,80" />
<!-- Highlight the curve vertex and control points -->
<g id="ControlPoints">
<!-- First cubic command control points -->
<line x1="10" y1="90" x2="30" y2="90" stroke="lightgrey" />
<circle cx="30" cy="90" r="1.5" />
<line x1="50" y1="10" x2="25" y2="10" stroke="lightgrey" />
<circle cx="25" cy="10" r="1.5" />
<!-- Second smooth command control points (the first one is implicit) -->
<line
x1="50"
y1="10"
x2="75"
y2="10"
stroke="lightgrey"
stroke-dasharray="2" />
<circle cx="75" cy="10" r="1.5" fill="lightgrey" />
<line x1="90" y1="90" x2="70" y2="90" stroke="lightgrey" />
<circle cx="70" cy="90" r="1.5" />
<!-- curve vertex points -->
<circle cx="10" cy="90" r="1.5" />
<circle cx="50" cy="10" r="1.5" />
<circle cx="90" cy="90" r="1.5" />
</g>
<use href="#ControlPoints" x="100" />
</svg>
```
{{EmbedLiveSample('Cubic_Bézier_Curve', '100%', 200)}}
### Quadratic Bézier curve
_Quadratic [Bézier curves](/en-US/docs/Glossary/Bezier_curve)_ are smooth curve definitions using three points:
- starting point (current point)
- : _P<sub>o</sub>_ = {_x<sub>o</sub>_, _y<sub>o</sub>_}
- end point
- : _P<sub>n</sub>_ = {_x<sub>n</sub>_, _y<sub>n</sub>_}
- control point
- : _P<sub>c</sub>_ = {_x<sub>c</sub>_, _y<sub>c</sub>_}
(controls curvature)
After drawing, the _end point_ (_P<sub>n</sub>_) becomes the _current point_ for the next command (_P<sub>o</sub>′_).
<table class="no-markdown">
<tbody>
<tr>
<th scope="col">Command</th>
<th scope="col">Parameters</th>
<th scope="col">Notes</th>
</tr>
<tr>
<th scope="row">Q</th>
<td>
(<code><var>x1</var></code
>,<code><var>y1</var></code
>, <code><var>x</var></code
>,<code><var>y</var></code
>)+
</td>
<td>
<p>
Draw a quadratic Bézier curve from the <em>current point</em> to the
<em>end point</em> specified by <code><var>x</var></code
>,<code><var>y</var></code
>. The <em>control point</em> is specified by
<code><var>x1</var></code
>,<code><var>y1</var></code
>. Any subsequent pair(s) of coordinate pairs are interpreted as
parameter(s) for implicit absolute quadratic Bézier curve
(<code>Q</code>) command(s).
</p>
<dl>
<dt><strong>Formulae:</strong></dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<code
><var>x</var></code
>, <code><var>y</var></code
>} ;<br /><var>P<sub>c</sub></var> = {<code><var>x1</var></code
>, <code><var>y1</var></code
>}
</dd>
</dl>
</td>
</tr>
<tr>
<th scope="row">q</th>
<td>
(<code><var>dx1</var></code
>,<code><var>dy1</var></code
>, <code><var>dx</var></code
>,<code><var>dy</var></code
>)+
</td>
<td>
<p>
Draw a quadratic Bézier curve from the <em>current point</em> to the
<em>end point</em>, which is the <em>current point</em> shifted by
<code><var>dx</var></code> along the x-axis and
<code><var>dy</var></code> along the y-axis. The
<em>control point</em> is the <em>current point</em> (starting point
of the curve) shifted by <code><var>dx1</var></code> along the x-axis
and <code><var>dy1</var></code> along the y-axis. Any subsequent
pair(s) of coordinate pairs are interpreted as parameter(s) for
implicit relative quadratic Bézier curve (<code>q</code>) command(s).
</p>
<dl>
<dt>Formulae:</dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<var
>x<sub>o</sub></var
>
+ <code><var>dx</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>} ;<br /><var>P<sub>c</sub></var> = {<var>x<sub>o</sub></var> +
<code><var>dx1</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy1</var></code
>}
</dd>
</dl>
</td>
</tr>
<tr>
<th scope="row">T</th>
<td>
(<code><var>x</var></code
>,<code><var>y</var></code
>)+
</td>
<td>
<p>
Draw a smooth quadratic Bézier curve from the
<em>current point</em> to the <em>end point</em> specified by
<code><var>x</var></code
>,<code><var>y</var></code
>. The <em>control point</em> is the reflection of the
<em>control point</em> of the previous curve command about the <em>current point</em>. If the previous
command wasn't a quadratic Bézier curve, the <em>control point</em> is
the same as the curve starting point (<em>current point</em>). Any
subsequent coordinate pair(s) are interpreted as parameter(s) for
implicit absolute smooth quadratic Bézier curve (<code>T</code>)
command(s).
</p>
<dl>
<dt>Formula:</dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<code
><var>x</var></code
>, <code><var>y</var></code
>}
</dd>
</dl>
</td>
</tr>
<tr>
<th scope="row">t</th>
<td>
(<code><var>dx</var></code
>,<code><var>dy</var></code
>)+
</td>
<td>
<p>
Draw a smooth quadratic Bézier curve from the
<em>current point</em> to the <em>end point</em>, which is the
<em>current point</em> shifted by <code><var>dx</var></code> along the
x-axis and <code><var>dy</var></code> along the y-axis. The
<em>control point</em> is the reflection of the
<em>control point</em> of the previous curve command about the <em>current point</em>. If the previous
command wasn't a quadratic Bézier curve, the <em>control point</em> is
the same as the curve starting point (<em>current point</em>). Any
subsequent coordinate pair(s) are interpreted as parameter(s) for
implicit relative smooth quadratic Bézier curve (<code>t</code>)
command(s).
</p>
<dl>
<dt>Formulae:</dt>
<dd>
<var>P<sub>o</sub>′</var> = <var>P<sub>n</sub></var> = {<var
>x<sub>o</sub></var
>
+ <code><var>dx</var></code
>, <var>y<sub>o</sub></var> + <code><var>dy</var></code
>}
</dd>
</dl>
</td>
</tr>
</tbody>
</table>
#### Examples
```css hidden
html,
body,
svg {
height: 100%;
}
```
```html
<svg
viewBox="0 0 200 100"
xmlns="http://www.w3.org/2000/svg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<!-- Quadratic Bézier curve with implicit repetition -->
<path
fill="none"
stroke="red"
d="M 10,50
Q 25,25 40,50
t 30,0 30,0 30,0 30,0 30,0" />
<!-- Highlight the curve vertex and control points -->
<g>
<polyline
points="10,50 25,25 40,50"
stroke="rgb(0 0 0 / 20%)"
fill="none" />
<circle cx="25" cy="25" r="1.5" />
<!-- Curve vertex points -->
<circle cx="10" cy="50" r="1.5" />
<circle cx="40" cy="50" r="1.5" />
<g id="SmoothQuadraticDown">
<polyline
points="40,50 55,75 70,50"
stroke="rgb(0 0 0 / 20%)"
stroke-dasharray="2"
fill="none" />
<circle cx="55" cy="75" r="1.5" fill="lightgrey" />
<circle cx="70" cy="50" r="1.5" />
</g>
<g id="SmoothQuadraticUp">
<polyline
points="70,50 85,25 100,50"
stroke="rgb(0 0 0 / 20%)"
stroke-dasharray="2"
fill="none" />
<circle cx="85" cy="25" r="1.5" fill="lightgrey" />
<circle cx="100" cy="50" r="1.5" />
</g>
<use href="#SmoothQuadraticDown" x="60" />
<use href="#SmoothQuadraticUp" x="60" />
<use href="#SmoothQuadraticDown" x="120" />
</g>
</svg>
```
{{EmbedLiveSample('Quadratic_Bézier_Curve', '100%', 200)}}
### Elliptical arc curve
_Elliptical arc curves_ are curves defined as a portion of an ellipse. It is sometimes easier to draw highly regular curves with an elliptical arc than with a Bézier curve.
<table class="no-markdown">
<tbody>
<tr>
<th scope="col">Command</th>
<th scope="col">Parameters</th>
<th scope="col">Notes</th>
</tr>
<tr>
<th scope="row">A</th>
<td>
(<code><var>rx</var></code> <code><var>ry</var></code>
<code><var>angle</var></code> <code><var>large-arc-flag</var></code>
<code><var>sweep-flag</var></code> <code><var>x</var></code>
<code><var>y</var></code
>)+
</td>
<td>
<p>
Draw an Arc curve from the current point to the coordinate
<code><var>x</var></code
>,<code><var>y</var></code
>. The center of the ellipse used to draw the arc is determined
automatically based on the other parameters of the command:
</p>
<ul>
<li>
<code><var>rx</var></code> and <code><var>ry</var></code> are the
two radii of the ellipse;
</li>
<li>
<code><var>angle</var></code> represents a rotation (in degrees) of
the ellipse relative to the x-axis;
</li>
<li>
<code><var>large-arc-flag</var></code> and
<code><var>sweep-flag</var></code> allows to chose which arc must be
drawn as 4 possible arcs can be drawn out of the other parameters.
<ul>
<li>
<code><var>large-arc-flag</var></code> allows to chose one of
the large arc (<code>1</code>) or small arc (<code>0</code>),
</li>
<li>
<code><var>sweep-flag</var></code> allows to chose one of the
clockwise turning arc (<code>1</code>) or counterclockwise
turning arc (<code>0</code>)
</li>
</ul>
</li>
</ul>
The coordinate <code><var>x</var></code
>,<code><var>y</var></code> becomes the new current point for the next
command. All subsequent sets of parameters are considered implicit
absolute arc curve (<code>A</code>) commands.
</td>
</tr>
<tr>
<th scope="row">a</th>
<td>
(<code><var>rx</var></code> <code><var>ry</var></code>
<code><var>angle</var></code> <code><var>large-arc-flag</var></code>
<code><var>sweep-flag</var></code> <code><var>dx</var></code>
<code><var>dy</var></code
>)+
</td>
<td>
<p>
Draw an Arc curve from the current point to a point for which
coordinates are those of the current point shifted by
<code><var>dx</var></code> along the x-axis and
<code><var>dy</var></code> along the y-axis. The center of the ellipse
used to draw the arc is determined automatically based on the other
parameters of the command:
</p>
<ul>
<li>
<code><var>rx</var></code> and <code><var>ry</var></code> are the
two radii of the ellipse;
</li>
<li>
<code><var>angle</var></code> represents a rotation (in degrees) of
the ellipse relative to the x-axis;
</li>
<li>
<code><var>large-arc-flag</var></code> and