You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sorry for the continuous questions. I have my struct Gobang here, where Board is the game board, and X,Y are the position of next step (where I will put chess on). I want to draw a circle as a chess on the position of (X, Y). So I use the template to dynamically draw it, since X and Y will change every time.
type Gobang struct {
Board [16][16]int
X, Y float64
}
I use the html code below: if .X and .Y are not 0, I will draw a circle on (.X, .Y).
{{if ne .X 0.0}}
{{if ne .Y 0.0}}
<h1>test</h1>
<circle cx=".X" cy=".Y" r="12" fill="black" />
{{end}}
{{end}}
But when I run it with setting g.X and g.Y to 45 in go function, I got nothing on my board. And when I change the html code into: <circle cx="45" cy="45" r="12" fill="black" />
I can draw the circle normally on the right place.
I don't think that's the issue. I added the <h1> only after problem showed, and I wanted to test if the two "if" conditions work.
If I changed the ".X" and ".Y" into 45, 45, in <circle> tag, I can draw like this:
Modify: I didn't got nothing on my board when passing .X and .Y. I got a quarter of circle whose center is on (0,0), and radius is 12. So I think the <circle> tag didn't receive any value from cx and cy, so it used the default value 0,0.
Hi,
Sorry for the continuous questions. I have my struct Gobang here, where Board is the game board, and X,Y are the position of next step (where I will put chess on). I want to draw a circle as a chess on the position of (X, Y). So I use the template to dynamically draw it, since X and Y will change every time.
I use the html code below: if .X and .Y are not 0, I will draw a circle on (.X, .Y).
But when I run it with setting g.X and g.Y to 45 in go function, I got nothing on my board. And when I change the html code into:
<circle cx="45" cy="45" r="12" fill="black" />
I can draw the circle normally on the right place.
I also tested below code:
And I can got the "RIGHT" on the app window.
So I cannot pass in a dynamic parameter when drawing a circle with svg in html? How could that be?
Thanks!
The text was updated successfully, but these errors were encountered: