'How can i draw the spring motion in the gif file in golang?

Gif file that i have to make

This gif file is what i have to make. I draw a mass circle like this

func (s *SpSim) circleXY(l, i int) [2]int {
    r := s.Ginfo.CR
    xi := int(float64(r) * math.Cos(2*math.Pi*float64(i)/100))
    xi += s.Ginfo.Pad + s.Ginfo.SprWidth/2
    yi := int(float64(r) * math.Sin(2*math.Pi*float64(i)/100))
    yi += l
    return [2]int{xi, yi}
}

but I can't think how to draw the spring part for the gif file. How can I make a spring attached to the ceiling and the mass? I'm trying to make a function that draws the spring like this

func (s *SpSim) addSpring(c *image.Paletted, count int) {

}

but I can't fill the function TT

go


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source