ToSVGPath returns a string representation of the path
()
| 59 | |
| 60 | // ToSVGPath returns a string representation of the path |
| 61 | func (p Path) ToSVGPath() string { |
| 62 | s := "" |
| 63 | for i := 0; i < len(p); { |
| 64 | if i != 0 { |
| 65 | s += " " |
| 66 | } |
| 67 | switch PathCommand(p[i]) { |
| 68 | case PathMoveTo: |
| 69 | s += fmt.Sprintf("M%4.3f,%4.3f", float32(p[i+1])/64, float32(p[i+2])/64) |
| 70 | i += 3 |
| 71 | case PathLineTo: |
| 72 | s += fmt.Sprintf("L%4.3f,%4.3f", float32(p[i+1])/64, float32(p[i+2])/64) |
| 73 | i += 3 |
| 74 | case PathQuadTo: |
| 75 | s += fmt.Sprintf("Q%4.3f,%4.3f,%4.3f,%4.3f", float32(p[i+1])/64, float32(p[i+2])/64, |
| 76 | float32(p[i+3])/64, float32(p[i+4])/64) |
| 77 | i += 5 |
| 78 | case PathCubicTo: |
| 79 | s += "C" + fmt.Sprintf("C%4.3f,%4.3f,%4.3f,%4.3f,%4.3f,%4.3f", float32(p[i+1])/64, float32(p[i+2])/64, |
| 80 | float32(p[i+3])/64, float32(p[i+4])/64, float32(p[i+5])/64, float32(p[i+6])/64) |
| 81 | i += 7 |
| 82 | case PathClose: |
| 83 | s += "Z" |
| 84 | i++ |
| 85 | default: |
| 86 | panic("freetype/rasterx: bad pather") |
| 87 | } |
| 88 | } |
| 89 | return s |
| 90 | } |
| 91 | |
| 92 | // String returns a readable representation of a Path. |
| 93 | func (p Path) String() string { |