Skip to content

Commit 2a4094c

Browse files
committed
init
1 parent 099f3f0 commit 2a4094c

File tree

4 files changed

+40
-0
lines changed

4 files changed

+40
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@
1313

1414
# Dependency directories (remove the comment below to include it)
1515
# vendor/
16+
17+
.idea
18+
.DS_Store

go.mod

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module Go-svg
2+
3+
go 1.16
4+
5+
require github.com/ajstarks/svgo v0.0.0-20210406150507-75cfd577ce75

go.sum

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
github.com/ajstarks/svgo v0.0.0-20210406150507-75cfd577ce75 h1:tuK1xIp+jrEEF0l3xXab78w89ilYr0Am170KdSml2xc=
2+
github.com/ajstarks/svgo v0.0.0-20210406150507-75cfd577ce75/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw=

main.go

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package main
2+
3+
import (
4+
"github.com/ajstarks/svgo"
5+
"log"
6+
"net/http"
7+
)
8+
9+
/**
10+
* @Author: super
11+
* @Date: 2021-06-26 18:50
12+
* @Description:
13+
**/
14+
func main() {
15+
http.Handle("/circle", http.HandlerFunc(circle))
16+
err := http.ListenAndServe(":2003", nil)
17+
if err != nil {
18+
log.Fatal("ListenAndServe:", err)
19+
}
20+
}
21+
22+
func circle(w http.ResponseWriter, req *http.Request) {
23+
w.Header().Set("Content-Type", "image/svg+xml")
24+
s := svg.New(w)
25+
s.Start(1000, 500)
26+
s.Text(10, 20, "那一天我二十一岁,在我一生的黄金时代。我有好多奢望。我想爱,想吃,还想在一瞬间变成天上半明半暗的云。")
27+
s.Text(10, 40, "后来我才知道,生活就是个缓慢受锤的过程,人一天天老下去,奢望也一天天消失,最后变得像挨了锤的牛一样。")
28+
s.Text(10, 60, "可是我过二十一岁生日时没有预见到这一点。我觉得自己会永远生猛下去,什么也锤不了我。")
29+
s.End()
30+
}

0 commit comments

Comments
 (0)