mchirico / zDaily

Playground to hack and test ideas with Zoe
1 stars 2 forks source link

Day 16: Your Idea #18

Open mchirico opened 3 years ago

mchirico commented 3 years ago

You come up with a program...

image

package main

import (
    "os"

    svg "github.com/ajstarks/svgo"
)

func main() {
    width, height := 500, 500
    rsize := 100
    csize := rsize / 2
    duration := 5.0
    repeat := 5
    imw, imh := 100, 144
    canvas := svg.New(os.Stdout)
    canvas.Start(width, height)
    canvas.Circle(csize, csize, csize, `fill="red"`, `id="circle"`)
    canvas.Image((width/2)-(imw/2), 0, imw, imh, "zoe.png", `id="gopher"`)
    canvas.Square(width-rsize, 0, rsize, `fill="blue"`, `id="square"`)
    canvas.Animate("#circle", "cx", 0, width, duration, repeat)
    canvas.Animate("#circle", "cy", 0, height, duration, repeat)
    canvas.Animate("#square", "x", width, 0, duration, repeat)
    canvas.Animate("#square", "y", height, 0, duration, repeat)
    canvas.Animate("#gopher", "y", 0, height, duration, repeat)
    canvas.End()
}
tacomonkautobot[bot] commented 3 years ago

mchirico, Thanks for opening this issue!

ZoeChiri commented 3 years ago

I did this :/

package main

import ( "fmt" "sync" "time" )

type MF struct { l int sync.Mutex }

func (mf *MF) mfmt(txt string, timeSleep int) { mf.Mutex.Lock() defer mf.Mutex.Unlock()

for i := 0; i < mf.l; i++ {
    fmt.Printf("\b") // backspace
}

mf.l = len(txt)
fmt.Printf("%s", txt)
time.Sleep(time.Duration(timeSleep) * time.Millisecond)

}

func main() {

fmt.Println("Moon Phases")

msg := []string{"○", "◔", "◑", "◕", "●"}

m := &MF{}
for i := 0; i < 100; i++ {
    for _, v := range msg {
        m.mfmt(v, 50)
    }
}

}