Comments (4)
This looks interesting. How about:
// Textspan begins text, assuming a tspan will be included, end with TextEnd()
// Standard Reference: https://www.w3.org/TR/SVG11/text.html#TSpanElement
func (svg *SVG) Textspan(x int, y int, t string, s ...string) {
svg.printf(`<text %s %s`, loc(x, y), endstyle(s, ">"))
xml.Escape(svg.Writer, []byte(t))
}
// Span makes styled spanned text, should be proceeded by Textspan
// Standard Reference: https://www.w3.org/TR/SVG11/text.html#TSpanElement
func (svg *SVG) Span(t string, s ...string) {
if len(s) == 0 {
xml.Escape(svg.Writer, []byte(t))
return
}
svg.printf(`<tspan %s`, endstyle(s, ">"))
xml.Escape(svg.Writer, []byte(t))
svg.printf(`</tspan>`)
}
// TextEnd ends spanned text
// Standard Reference: https://www.w3.org/TR/SVG11/text.html#TSpanElement
func (svg *SVG) TextEnd() {
svg.println(`</text>`)
}
from svgo.
Example use:
package main
import (
"os"
svg "github.com/ajstarks/svgo"
)
func main() {
width := 500
height := 500
canvas := svg.New(os.Stdout)
canvas.Start(width, height)
canvas.Circle(width/2, height/2, 100)
canvas.Gstyle("text-anchor:middle;fill:white")
canvas.Textspan(width/2, height/2, "Hello ", "font-size:30px")
canvas.Span("SVG", "font-size:50px")
canvas.TextEnd()
canvas.Gend()
canvas.End()
}
from svgo.
Added with 1f3ef52
from svgo.
Lovely thanks!
from svgo.
Related Issues (20)
- How I can manipulate with events? HOT 1
- Grid of colors to svg HOT 1
- Text() attribute styling/spacing HOT 7
- Including units and floating point values HOT 2
- Just Want to Say Thank You HOT 1
- Pdf to SVG HOT 1
- Pdf to SVG HOT 1
- Add <title> to individual element? HOT 2
- Defining marker orientation HOT 4
- Potential code quality issues found
- Getting the getComputedTextLength() HOT 2
- Please add module support! HOT 2
- rotate(deg, cx, cy) HOT 1
- Support importing a svg into the SVG object HOT 4
- add method
- html to svg HOT 1
- Dead link to SVGo Paper HOT 1
- Add method for rotation around the center
- Please add LICENSE HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svgo.