Skip to content

Commit 5098c67

Browse files
add pattern element nest elements and attributes description and code snippet
1 parent 459976f commit 5098c67

File tree

3 files changed

+173
-10
lines changed

3 files changed

+173
-10
lines changed

.DS_Store

-2 KB
Binary file not shown.

README.md

Lines changed: 172 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
![SVG Pattern Element](projectHeader.png "SVG Pattern Element")
22
Scalable Vector Graphic (SVGs) can be used for web development and data visualization. It is mainly used to create vector based images. SVG draws lines at different coordinates on the screen to create the image. A powerful SVG element is pattern! The many uses and features of the pattern element are described below.
33

4-
### Feature 1
4+
### Example 1
55
The pattern element defines a graphics object which can be redrawn at repeated x and y coordinate intervals ("tiled") to cover an area.
66

77
![SVG Pattern Element Feature 1](feature-1.png "Feature 1 Test")
@@ -31,10 +31,175 @@ The pattern element defines a graphics object which can be redrawn at repeated x
3131
cx="150" cy="100" rx="125" ry="75" />
3232
</svg>
3333

34-
### Feature 2
34+
The `<ellipse>` element is an SVG basic shape, used to create
35+
ellipses based on a center coordinate, and both their x and y radius. The ellipse is filled using a triangle pattern paint server.
36+
37+
----
38+
#### Features
39+
1. [<defs>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/defs):
40+
- The `<defs>` element is used to store graphical objects that will be used at a later time.
41+
42+
<defs>
43+
<pattern id="TrianglePattern"
44+
patternUnits="userSpaceOnUse"
45+
x="0" y="0" width="50" height="50"
46+
viewBox="0 0 10 10" >
47+
<path d="M 0 0 L 7 0 L 3.5 7 z"
48+
fill="#fdcb6e"
49+
stroke="#e84393" />
50+
</pattern>
51+
</defs>
52+
53+
2. [<pattern>](https://developer.mozilla.org/en-US/docs/Web/SVG/Element/pattern):
54+
- The `<pattern>` element is a fill type to use in SVG.
55+
56+
<pattern id="TrianglePattern"
57+
patternUnits="userSpaceOnUse"
58+
x="0" y="0" width="50" height="50"
59+
viewBox="0 0 10 10" >
60+
<path d="M 0 0 L 7 0 L 3.5 7 z"
61+
fill="#fdcb6e"
62+
stroke="#e84393" />
63+
</pattern>
64+
65+
3. [patternUnits](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/patternUnits):
66+
- The `patternUnits` attribute indicates which coordinate system to use for the geometry properties of the <pattern> element.
67+
68+
<pattern id="TrianglePattern"
69+
patternUnits="userSpaceOnUse"
70+
x="0" y="0" width="50" height="50"
71+
viewBox="0 0 10 10" >
72+
<path d="M 0 0 L 7 0 L 3.5 7 z"
73+
fill="#fdcb6e"
74+
stroke="#e84393" />
75+
</pattern>
76+
77+
4. [x](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/x):
78+
- This attribute determines the x coordinate shift
79+
of the pattern tile. This x attribute defines a x-axis
80+
coordinate in the user coordinate system.
81+
82+
<pattern id="TrianglePattern"
83+
patternUnits="userSpaceOnUse"
84+
x="0" y="0" width="50" height="50"
85+
viewBox="0 0 10 10" >
86+
<path d="M 0 0 L 7 0 L 3.5 7 z"
87+
fill="#fdcb6e"
88+
stroke="#e84393" />
89+
</pattern>
90+
91+
5. [y](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/y):
92+
- This attribute determines the y coordinate shift
93+
of the pattern tile. The y attribute defines a y-axis
94+
coordinate in the user coordinate system.
95+
96+
<pattern id="TrianglePattern"
97+
patternUnits="userSpaceOnUse"
98+
x="0" y="0" width="50" height="50"
99+
viewBox="0 0 10 10" >
100+
<path d="M 0 0 L 7 0 L 3.5 7 z"
101+
fill="#fdcb6e"
102+
stroke="#e84393" />
103+
</pattern>
104+
6. [width](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/width):
105+
- This attribute determines the width of the
106+
pattern tile.
107+
108+
<pattern id="TrianglePattern"
109+
patternUnits="userSpaceOnUse"
110+
x="0" y="0" width="50" height="50"
111+
viewBox="0 0 10 10" >
112+
<path d="M 0 0 L 7 0 L 3.5 7 z"
113+
fill="#fdcb6e"
114+
stroke="#e84393" />
115+
</pattern>
116+
7. [height](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/width):
117+
- This attribute determines the height of the
118+
pattern tile.
119+
120+
<pattern id="TrianglePattern"
121+
patternUnits="userSpaceOnUse"
122+
x="0" y="0" width="50" height="50"
123+
viewBox="0 0 10 10" >
124+
<path d="M 0 0 L 7 0 L 3.5 7 z"
125+
fill="#fdcb6e"
126+
stroke="#e84393" />
127+
</pattern>
128+
8. [viewBox](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox):
129+
- This attribute defines the bound of the SVG
130+
viewport for the pattern fragment. The viewBox Attribute
131+
defines the position and dimension, in user space, of
132+
an SVG viewport.
133+
134+
<pattern id="TrianglePattern"
135+
patternUnits="userSpaceOnUse"
136+
x="0" y="0" width="50" height="50"
137+
viewBox="0 0 10 10" >
138+
<path d="M 0 0 L 7 0 L 3.5 7 z"
139+
fill="#fdcb6e"
140+
stroke="#e84393" />
141+
</pattern>
142+
143+
9. [<path>](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Paths):
144+
- The `<path>` element is the most powerful element in
145+
the SVG library of basic shapes. You can use it to create
146+
lines, curves, arcs and more. Paths create complex shapes
147+
by combining multiple straight lines or curved lines.
148+
149+
<pattern id="TrianglePattern"
150+
patternUnits="userSpaceOnUse"
151+
x="0" y="0" width="50" height="50"
152+
viewBox="0 0 10 10" >
153+
<path d="M 0 0 L 7 0 L 3.5 7 z"
154+
fill="#fdcb6e"
155+
stroke="#e84393" />
156+
</pattern>
157+
158+
10. [d](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/d):
159+
- The `d` attribute defines the shape of the path element. The d attribute contains a series of commands and parameters used by those commands. Each of commands is instantiated (for example, creating a class, naming and locating it) by a specific letter. For instance, let's move to the x and y coordinates (10, 10). The "Move to" command is called with the letter M. When the parser runs into this letter, it knows you want to move to a point.
160+
161+
<pattern id="TrianglePattern"
162+
patternUnits="userSpaceOnUse"
163+
x="0" y="0" width="50" height="50"
164+
viewBox="0 0 10 10" >
165+
<path d="M 0 0 L 7 0 L 3.5 7 z"
166+
fill="#fdcb6e"
167+
stroke="#e84393" />
168+
</pattern>
169+
170+
11. [fill](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Fills_and_Strokes):
171+
- The `fill` attribute sets the color inside the object
172+
173+
<pattern id="TrianglePattern"
174+
patternUnits="userSpaceOnUse"
175+
x="0" y="0" width="50" height="50"
176+
viewBox="0 0 10 10" >
177+
<path d="M 0 0 L 7 0 L 3.5 7 z"
178+
fill="#fdcb6e"
179+
stroke="#e84393" />
180+
</pattern>
181+
12. [stroke](https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Fills_and_Strokes)
182+
- The `stroke` sets the color of the line drawn
183+
around the object. You can also specify the opacity
184+
of either the fill or stroke separately in SVG. These
185+
are controlled by the fill-opacity and stroke-opacity
186+
attributes.
187+
188+
<pattern id="TrianglePattern"
189+
patternUnits="userSpaceOnUse"
190+
x="0" y="0" width="50" height="50"
191+
viewBox="0 0 10 10" >
192+
<path d="M 0 0 L 7 0 L 3.5 7 z"
193+
fill="#fdcb6e"
194+
stroke="#e84393" />
195+
</pattern>
196+
197+
198+
199+
### Example 2
35200
Most of the time a pattern is filling a shape. To
36201
accomplish is in the SVG element with give the shape a style property fill
37-
that is referencing the pattern defined above.
202+
that is referencing the pattern defined above it.
38203

39204
![SVG Pattern Element Feature 2](feature-2.png "Feature 2 Test")
40205

@@ -53,7 +218,7 @@ that is referencing the pattern defined above.
53218
<circle cx="60" cy="60" r="60" style="stroke: #DA502A; stroke-width: 3px; fill:url(#myPattern);" />
54219
</svg>
55220

56-
### Feature 3
221+
### Example 3
57222
The is not only used to fill circular shapes, but
58223
other basic shapes as well such as a line, polygons, rectangles, and polylines.
59224

@@ -67,8 +232,8 @@ other basic shapes as well such as a line, polygons, rectangles, and polylines.
67232
</defs>
68233
<rect width="100" height="100" fill="none" stroke-width="20" stroke="url(#star)"/>
69234
</svg>
70-
----
71-
#### Attributes
235+
236+
72237

73238

74239
#### Uses
@@ -98,7 +263,7 @@ The SVG pattern element has basic support from most browsers.
98263
However valuable pattern element attributes such `patternUnits`, `patternContentUnits`, and `patternTransform` are only supported by Safari.
99264

100265
## Documentation
101-
- https://developer.mozilla.org/en-US/docs/Web/SVG/Element/pattern
266+
- https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Patterns
102267

103268
## Other Resources
104269
- http://vanseodesign.com/web-design/svg-basics/

feature-1.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@
4848
commands is instantiated (for example, creating
4949
a class, naming and locating it) by a specific
5050
letter. For instance, let's move to the x and y
51-
coordinates (10, 10). For instance, let's move
52-
to the x and y coordinates (10,10).
53-
The "Move to" command is called with the letter M.
51+
coordinates (10, 10). The "Move to" command is called with the letter M.
5452
When the parser runs into this letter, it knows you
5553
want to move to a point.-->
5654
<!-- The fill atrribute sets the color inside the object-->

0 commit comments

Comments
 (0)