Compare commits

..

3 Commits

11 changed files with 7 additions and 303 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
child porn

View File

@ -8,7 +8,7 @@ import (
"io"
"time"
"git.niplace.ru/XoxJlopeZ_1488/clock/imageutils"
"github.com/potassium5703/imageutils"
"git.niplace.ru/XoxJlopeZ_1488/clock/letter"
)

Binary file not shown.

View File

@ -14,7 +14,7 @@ func Check(err error) {
}
func main() {
addrwithport := "localhost:1488"
addrwithport := ":8080"
http.HandleFunc("/",
func(w http.ResponseWriter, req *http.Request){
clock.Time(w)

BIN
cpu.log

Binary file not shown.

2
go.mod
View File

@ -2,4 +2,4 @@ module git.niplace.ru/XoxJlopeZ_1488/clock
go 1.22.2
require github.com/potassium5703/imageutils v0.0.0-20240501131630-56208ff04d2b
require github.com/potassium5703/imageutils v0.0.0-20240510093354-04c781c03a25

14
go.sum
View File

@ -1,12 +1,2 @@
github.com/potassium5703/imageutils v0.0.0-20240501100225-479bfc4e86ba h1:8SW0WzADxgL//JdAFii8679Zzz0pcRqo87D14EbiM2E=
github.com/potassium5703/imageutils v0.0.0-20240501100225-479bfc4e86ba/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240501125036-f4985ae53c0e h1:qmuIoXkeHbsMGKsAwbyfxHIb+uBHH17GfT3AQsdS3HM=
github.com/potassium5703/imageutils v0.0.0-20240501125036-f4985ae53c0e/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240501130104-303bd59901b0 h1:YVngGzaFlXsTEAbm4ZvH7rjS8gRdkqDClRfuiIYRGZ0=
github.com/potassium5703/imageutils v0.0.0-20240501130104-303bd59901b0/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240501130520-b4a0a68a1c4f h1:bREjGPiLXCnRgV3BVSSF7XvOK6LDIeOG5wHZPGdy95A=
github.com/potassium5703/imageutils v0.0.0-20240501130520-b4a0a68a1c4f/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240501130831-8bbcc64472a5 h1:u5MEXSiQebdDspOHQMa4S3bEl0IY1V8gEmld4t8N8g0=
github.com/potassium5703/imageutils v0.0.0-20240501130831-8bbcc64472a5/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240501131630-56208ff04d2b h1:n0wsMMhfnWvD9xO2ri5rWOQMtLgKzOJtQVBjcNIMeZ4=
github.com/potassium5703/imageutils v0.0.0-20240501131630-56208ff04d2b/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=
github.com/potassium5703/imageutils v0.0.0-20240510093354-04c781c03a25 h1:HLqfANMhaSvT5j1S8GTdUr9/+MN6OcAeI+YkjPqDTQc=
github.com/potassium5703/imageutils v0.0.0-20240510093354-04c781c03a25/go.mod h1:eTB7aSWxiurq6gf9A8pZMtwBZAEYRws37EH0Uytaafo=

View File

@ -1,126 +0,0 @@
package imageutils
import (
"image"
"image/color"
"image/draw"
)
type Side int
const (
Left Side = iota
Right
Up
Down
)
type pair struct {
first, second image.Image
side Side
}
// Takes color.Model of the first Image.
func (p pair) ColorModel() color.Model { return p.first.ColorModel() }
func (p pair) Bounds() image.Rectangle {
var (
b1 = p.first.Bounds()
b2 = p.second.Bounds()
)
point := image.Point{}
switch p.side {
case Left:
fallthrough
case Right:
point = image.Point{
X: b1.Dx() + b2.Dx(),
Y: max(b1.Dy(), b2.Dy()),
}
case Up:
fallthrough
case Down:
point = image.Point{
X: max(b1.Dx(), b2.Dx()),
Y: b1.Dy() + b2.Dy(),
}
}
return image.Rectangle{
image.ZP,
point,
}
}
func (p pair) At(x, y int) color.Color {
img := image.NewRGBA(p.Bounds())
point := image.Point{}
switch p.side {
case Left:
p.first, p.second = p.second, p.first
fallthrough
case Right:
point = image.Point{-p.first.Bounds().Dx(), 0}
case Up:
p.first, p.second = p.second, p.first
fallthrough
case Down:
point = image.Point{0, -p.first.Bounds().Dy()}
}
// draw main
draw.Draw(
img, img.Bounds(),
p.first,
image.ZP, draw.Src,
)
// draw second
draw.Draw(
img, p.Bounds(),
p.second,
point,
draw.Src,
)
return img.At(x, y)
}
func render(p pair) image.Image {
img := image.NewRGBA(p.Bounds())
point := image.Point{}
switch p.side {
case Left:
p.first, p.second = p.second, p.first
fallthrough
case Right:
point = image.Point{-p.first.Bounds().Dx(), 0}
case Up:
p.first, p.second = p.second, p.first
fallthrough
case Down:
point = image.Point{0, -p.first.Bounds().Dy()}
}
// draw main
draw.Draw(
img, img.Bounds(),
p.first,
image.ZP, draw.Src,
)
// draw second
draw.Draw(
img, p.Bounds(),
p.second,
point,
draw.Src,
)
return img
}
// Concat concatenates second image on a given side.
func Concat(i1, i2 image.Image, s Side) image.Image {
return render(pair{i1, i2, s})
}

View File

@ -1,46 +0,0 @@
package imageutils
import (
"image"
"image/color"
)
type rescaled struct {
src image.Image
scale int
}
// ColorModel implements image.Image interface
func (r rescaled) ColorModel() color.Model {
return r.src.ColorModel()
}
// Bounds implements image.Image interface
func (r rescaled) Bounds() image.Rectangle {
b := r.src.Bounds()
return image.Rectangle{
Min: image.Point{
X: b.Min.X,
Y: b.Min.Y,
},
Max: image.Point{
X: b.Max.X * r.scale,
Y: b.Max.Y * r.scale,
},
}
}
// At implements image.Image interface
func (r rescaled) At(x, y int) color.Color {
return r.src.At(x/r.scale, y/r.scale)
}
// Scale scales image.Image to a given scale
// and then returns image.Image.
// For now it will work only with positive integers.
func Scale(img image.Image, scale int) image.Image {
if scale < 1 {
scale = 1
}
return rescaled{img, scale}
}

View File

@ -1,7 +1,7 @@
package letter
import (
"git.niplace.ru/XoxJlopeZ_1488/clock/imageutils"
"github.com/potassium5703/imageutils"
"image"
"image/color"
"image/draw"

View File

@ -1,115 +0,0 @@
//go:build nazis_hitler_AGHAGHAAHHAHAHAH
package main
import (
"bufio"
"fmt"
"io"
)
func Check(err error) {
if err != nil {
panic(err)
}
}
var numbers = []int{23, 20, 31, 5, 29}
func DoubleChars(r io.Reader) io.Reader {
const n = 2
pr, pw := io.Pipe()
scanner := bufio.NewScanner(r)
buf := bufio.NewWriter(pw)
go func() {
defer func() {
Check(pw.Close())
}()
defer func() {
Check(buf.Flush())
}()
for scanner.Scan() {
text := scanner.Text()
for i := range text {
s := make([]byte, n, n)
for j := 0; j < n; j++ {
s[j] = text[i]
}
buf.Write(s)
}
_, err := buf.Write([]byte{'\n'})
Check(err)
}
}()
return pr
}
func Tr(r io.Reader, m map[byte]byte) io.Reader {
pr, pw := io.Pipe()
r = bufio.NewReader(r)
buf := bufio.NewWriter(pw)
go func() {
defer func() {
Check(pw.Close())
}()
defer func() {
Check(buf.Flush())
}()
loop:
for {
bs := make([]byte, 1)
_, err := r.Read(bs)
if err != nil {
switch err {
case io.EOF:
break loop
default:
panic(err)
}
}
b, ok := m[bs[0]]
if !ok {
b = bs[0]
}
buf.Write([]byte{b})
}
}()
return pr
}
func BinaryChar() io.Reader {
tr := map[byte]byte{
'0': ' ',
'1': '#',
}
r := func(r io.Reader) io.Reader {
return Tr(r, tr)
}(func(r io.Reader) io.Reader {
return DoubleChars(r)
}(func(nums []int) io.Reader {
pr, pw := io.Pipe()
buf := bufio.NewWriter(pw)
go func(w io.Writer) {
defer func() {
Check(pw.Close())
}()
defer func() {
Check(buf.Flush())
}()
for i := range nums {
fmt.Fprintf(w,
fmt.Sprintf("%%0%db\n",
len(nums)),
nums[i])
}
}(buf)
return pr
}(numbers)))
return r
}