SoFunction
Updated on 2025-03-01

Go language to create a gif dynamic image

As the question is, the key is not how the picture is, but that go can be used to implement dynamic picture verification code. In addition, go supports cgi and fcgi, can it be used to add existing servers?

package main
import (
  "/hydra13142/cube"
  "/hydra13142/geom"
  "/hydra13142/paint"
  "image"
  "image/color/palette"
  "image/gif"
  "math"
  "os"
)
var (
  pln *
  unx 
  uny 
)
const (
  H = 18
  W = 36
)
func init() {
  pln, _ = ({}, {4, 4, 3})
  uny = ({}, ({0, 0, 10})).Unit()
  unx = (uny, {4, 4, 3}).Unit()
}
func main() {
  var x [H + 1][W]
  var y [H + 1][W]
  dz :=  / H
  dxy :=  * 2 / W
  for i := 0; i <= H; i++ {
    az := float64(i)*dz - /2
    r := 140 * (az)
    z := 140 * (az)
    for j := 0; j < W; j++ {
      axy := float64(j) * dxy
      x[i][j] = {(axy) * r, (axy) * r, z}
    }
  }
  pics := make([]*, 0, 20)
  img := {
    FR: ,
    BG: ,
  }
  stp := dxy / 20
  delay := make([]int, 0, 20)
  for t := 0; t < 20; t++ {
     = ((0, 0, 300, 300), palette.Plan9)
    for i := 0; i <= H; i++ {
      for j := 0; j < W; j++ {
        ox := ({}, x[i][j])
        y[i][j] = {(ox, unx), (ox, uny)}
        a, b := x[i][j].X, x[i][j].Y
        x[i][j].X = a*(stp) - b*(stp)
        x[i][j].Y = b*(stp) + a*(stp)
      }
    }
    for i := 0; i < H; i++ {
      for j := 0; j < W; j++ {
        (
          150+int(y[i][j].X),
          150-int(y[i][j].Y),
          150+int(y[i][(j+1)%W].X),
          150-int(y[i][(j+1)%W].Y),
        )
        (
          150+int(y[i][j].X),
          150-int(y[i][j].Y),
          150+int(y[i+1][j].X),
          150-int(y[i+1][j].Y),
        )
      }
    }
    pics = append(pics, .(*))
    delay = append(delay, 5)
  }
  file, _ := ("")
  defer ()
  (file, &{
    Image:   pics,
    Delay:   delay,
    LoopCount: 5 * len(delay),
  })
}

package main
import (
  "/hydra13142/cube"
  "/hydra13142/geom"
  "/hydra13142/paint"
  "image"
  "image/color/palette"
  "image/gif"
  "math"
  "os"
)
var (
  pln   *
  unx, uny 
)
const (
  H = 18
  W = 96
)
func init() {
  pln, _ = ({}, {2, 2, 1})
  uny = ({}, ({0, 0, 10})).Unit()
  unx = (uny, {2, 2, 1}).Unit()
}
func main() {
  var x [H + 1][W]
  var y [H + 1][W]
  dz :=  / H
  dxy :=  * 4 / W
  for i := 0; i <= H; i++ {
    az := float64(i)*dz - /2
    r := 300 * (az)
    z := 100 * (az)
    for j := 0; j < W; j++ {
      axy := float64(j) * dxy
      R := float64(j) * r / W
      x[i][j] = {(axy) * R, (axy) * R, z}
    }
  }
  pics := make([]*, 0, 20)
  img := {
    FR: ,
    BG: ,
  }
  stp :=  / W
  delay := make([]int, 0, 2*W)
  for t := 0; t < 2*W; t++ {
     = ((0, 0, 600, 300), palette.Plan9)
    for i := 0; i <= H; i++ {
      for j := 0; j < W; j++ {
        ox := ({}, x[i][j])
        y[i][j] = {(ox, unx), (ox, uny)}
        a, b := x[i][j].X, x[i][j].Y
        x[i][j].X = a*(stp) - b*(stp)
        x[i][j].Y = b*(stp) + a*(stp)
      }
    }
    (
      300+int(y[0][0].X),
      150-int(y[0][0].Y),
      300+int(y[H][0].X),
      150-int(y[H][0].Y),
    )
    for i := 0; i < H; i++ {
      for j := 1; j < W; j++ {
        (
          300+int(y[i][j].X),
          150-int(y[i][j].Y),
          300+int(y[i][j-1].X),
          150-int(y[i][j-1].Y),
        )
        (
          300+int(y[i][j].X),
          150-int(y[i][j].Y),
          300+int(y[i+1][j].X),
          150-int(y[i+1][j].Y),
        )
      }
    }
    pics = append(pics, .(*))
    delay = append(delay, 5)
  }
  file, _ := ("")
  defer ()
  (file, &{
    Image:   pics,
    Delay:   delay,
    LoopCount: 5 * len(delay),
  })
}

package main
import (
  "/hydra13142/cube"
  "/hydra13142/geom"
  "/hydra13142/paint"
  "image"
  "image/color/palette"
  "image/gif"
  "math"
  "os"
)
var (
  pln   *
  unx, uny 
)
const (
  H = 9
  W = 36
)
func init() {
  pln, _ = ({}, {4, 4, 3})
  uny = ({}, ({0, 0, 10})).Unit()
  unx = (uny, {4, 4, 3}).Unit()
}
func main() {
  var x [H*W + 1]
  var y [H*W + 1]
  dxy := ( * 2) / W
  dz :=  / H
  for i := 0; i <= H*W; i++ {
    az := float64(i)*dz/W - /2
    r := 140 * (az)
    z := 140 * (az) 
    axy := float64(i) * dxy
    x[i] = {(axy) * r, (axy) * r, z}
  }
  pics := make([]*, 0, 20)
  img := {
    FR: ,
    BG: ,
  }
  stp :=  * 2 / (W * 3)
  delay := make([]int, 0, 3*W)
  for t := 0; t < 3*W; t++ {
     = ((0, 0, 300, 300), palette.Plan9)
    for i := 0; i <= H*W; i++ {
      ox := ({}, x[i])
      y[i] = {(ox, unx), (ox, uny)}
      a, b := x[i].X, x[i].Z
      x[i].X = a*(stp) - b*(stp)
      x[i].Z = b*(stp) + a*(stp)
    }
    (
      150+int(y[0].X),
      150-int(y[0].Y),
      150+int(y[H*W].X),
      150-int(y[H*W].Y),
    )
    for i := 0; i < H*W; i++ {
      (
        150+int(y[i].X),
        150-int(y[i].Y),
        150+int(y[i+1].X),
        150-int(y[i+1].Y),
      )
    }
    pics = append(pics, .(*))
    delay = append(delay, 8)
  }
  file, _ := ("")
  defer ()
  (file, &{
    Image:   pics,
    Delay:   delay,
    LoopCount: 5 * len(delay),
  })
}

The above is the entire content of this article, I hope you like it.