資料來源 imooc 慕課網
1.1 位圖 & 矢量圖
1.2 基本圖形
rect
circle
ellipse
line
polyline
polygon
The following commands are available for path data:
? M = move to
? L = line to
? H = horizontal line to
? V = vertical line to
? C = curve to
? S = smooth curve to
? Q = quadratic Bézier curve 二次貝塞爾曲線
? T = smooth quadratic Bézier curveto 光滑二次貝塞爾曲線
? A = elliptical Arc 橢圓弧
? Z = close path
填充 描邊 和 變換
- fill
- stroke
- stroke-width
- transform
1.3 基本操作API
創建圖形:
document.createElementNS(namespaceURI, qualifiedName[, options]);
namespaceURI
:string that specifies the namespace to associate with the element.
qulifiedName
:A string that specifies the type of element to be created > a nodeName
optiond
:A optional object ElementCreationOptions containing a single property namedis
, whose value is the tag name for a custom element previously defined usingcustomElements.define()
.
(創建之后記得用appendChild()
添加)添加圖形:
document.appendChild(childElement)
獲取 / 設置:
element.setAttribute(name, value)
element.getAttribute(name)