Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SVG File Not well drawn #44

Open
qxdo opened this issue Oct 30, 2023 · 0 comments
Open

SVG File Not well drawn #44

qxdo opened this issue Oct 30, 2023 · 0 comments

Comments

@qxdo
Copy link

qxdo commented Oct 30, 2023

I run demo code in the test case, just modified my svg file, like this,
`

str := []string{"00dbdcf748734ed890fbf39ca76ce266",
"1ade369b862d44118c126ff8f80bbd1b",
"1bedfd263a1f4ca58c660806e03e80e7",
"1d7d7deed0ae484a8e893950ad700582",
"1e6c8acc04134b5a91cf1ecc1d43c433",
"1ed618bb2816400bbc29e40fffae8114",
"1fbd523827844e4ebea89657ea16c3de",
"2be84432e3ea4e01a919be01ec79fff5",
"2c2766e105bf4081b7f46d50a840d017",
"4c8536828410457ebd2996e3b2437863",
"4d1078d7548045d7921329e9ea91fe0c",
"4f0f35b1b5454a4482cecb693564c98b",
"4fe9018d54ec43da999f6712e2b4afc9",
"5abbd764d36b470c804a4d0b51353eae",
"5ec8889735b04398a7e17a54761f0c31"}
for _, s := range str {
iconPath := "gg_demo/icons2/" + s + ".svg"

	icon, errSvg := oksvg.ReadIcon(iconPath, oksvg.WarnErrorMode)
	if errSvg != nil {
		fmt.Println(errSvg)
		return
	}
	w, h := int(icon.ViewBox.W), int(icon.ViewBox.H)
	img := image.NewRGBA(image.Rect(0, 0, w, h))
	tb := img.Bounds()
	tb.Max.X /= 2
	scannerGV := rasterx.NewScannerGV(w, h, img, img.Bounds())
	raster := rasterx.NewDasher(w, h, scannerGV)
	icon.Draw(raster, 1.0)
	if img != nil {
		p := strings.Split(iconPath, "/")
		err := SaveToPngFile(fmt.Sprintf("gg_demo/targets/%s.png", p[len(p)-1]), img)
		if err != nil {
			fmt.Println(err)
			return
		}
	}
}

`

and the final result like this:
image
source code is
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 83.51 83.46"> <title>&#x8D44;&#x6E90; 35</title> <path d="M.06 62.2V45.36c0-1.12.76-1.57 1.48-2.14 7.31-5.68 15.49-6.79 24.3-4.61 8.35 2.06 16 6.09 24 9.09a48.68 48.68 0 0 0 14.71 3.53 26 26 0 0 0 16.61-5c.59-.42 1.09-1.31 1.89-1s.42 1.32.43 2v13a3.67 3.67 0 0 1-1.71 3.31C73.14 70 63.77 70.08 54 67c-8-2.53-15.44-6.52-23.38-9.21-8.37-2.85-16.68-3.84-24.89.51a32.29 32.29 0 0 0-5.67 3.9z" fill="#146fb7"/> <path d="M.07 39.11V22.39c0-1.12.78-1.58 1.5-2.13 7.15-5.56 15.17-6.73 23.82-4.69 8 1.88 15.25 5.65 22.83 8.6 6.06 2.37 12.18 4.42 18.85 4.12a26.13 26.13 0 0 0 14.3-5.22c.51-.36 1-1.14 1.71-.73s.33 1.21.33 1.83c0 4.33-.05 8.66 0 13a3.88 3.88 0 0 1-1.85 3.51c-7.6 5.68-16 6.43-24.89 4.1-8.39-2.19-16-6.37-24.15-9.28-6.38-2.28-12.84-4-19.75-2.67-4.57.89-8.54 3.01-12.7 6.28z" fill="#ec2032"/> <path d="M.09 15.6V1.26A1.05 1.05 0 0 1 1.31.06h78.94c2.45 0 3.4.5 3.23 3.14-.25 3.73-.12 7.49 0 11.24a3.48 3.48 0 0 1-1.55 3.13c-7.7 5.93-16.23 6.69-25.32 4.28-8.39-2.23-16-6.4-24.17-9.31-6.14-2.2-12.36-3.83-19-2.71a28.08 28.08 0 0 0-11.53 5c-.51.28-.82.86-1.82.77z" fill="#ec2032"/> <path d="M41.47 83.41H2.53C.6 83.47-.08 83 0 81c.16-3.9.1-7.82 0-11.73a3.46 3.46 0 0 1 1.52-3.14c8.28-6.36 17.36-6.76 27-3.85 7.09 2.15 13.7 5.51 20.61 8.14 5.52 2.1 11.1 3.87 17.14 3.79a26.07 26.07 0 0 0 14.86-5c.58-.41 1.1-1.3 1.9-.91s.39 1.34.4 2c0 3.58-.12 7.16.07 10.73.11 2.12-.75 2.45-2.59 2.45-13.15-.1-26.3-.07-39.44-.07z" fill="#146fb7"/> </svg>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant