homepage rework for socials and projects
This commit is contained in:
parent
fe84a59326
commit
69e2e22e47
12 changed files with 432 additions and 137 deletions
|
@ -1,13 +1,9 @@
|
|||
package controller
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/png"
|
||||
|
||||
"github.com/skip2/go-qrcode"
|
||||
)
|
||||
|
@ -33,69 +29,6 @@ const (
|
|||
HIGH
|
||||
)
|
||||
|
||||
func noDepsGenerateQRCode() (string, error) {
|
||||
version := 1
|
||||
|
||||
size := 0
|
||||
size = 21 + version * 4
|
||||
if version > 10 {
|
||||
return "", errors.New(fmt.Sprintf("QR version %d not supported", version))
|
||||
}
|
||||
|
||||
img := image.NewGray(image.Rect(0, 0, size + margin * 2, size + margin * 2))
|
||||
|
||||
// fill white
|
||||
for y := range size + margin * 2 {
|
||||
for x := range size + margin * 2 {
|
||||
img.Set(x, y, color.White)
|
||||
}
|
||||
}
|
||||
|
||||
// draw alignment squares
|
||||
drawLargeAlignmentSquare(margin, margin, img)
|
||||
drawLargeAlignmentSquare(margin, margin + size - 7, img)
|
||||
drawLargeAlignmentSquare(margin + size - 7, margin, img)
|
||||
drawSmallAlignmentSquare(size - 5, size - 5, img)
|
||||
/*
|
||||
if version > 4 {
|
||||
space := version * 3 - 2
|
||||
end := size / space
|
||||
for y := range size / space + 1 {
|
||||
for x := range size / space + 1 {
|
||||
if x == 0 && y == 0 { continue }
|
||||
if x == 0 && y == end { continue }
|
||||
if x == end && y == 0 { continue }
|
||||
if x == end && y == end { continue }
|
||||
drawSmallAlignmentSquare(
|
||||
x * space + margin + 4,
|
||||
y * space + margin + 4,
|
||||
img,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
// draw timing bits
|
||||
for i := margin + 6; i < size - 4; i++ {
|
||||
if (i % 2 == 0) {
|
||||
img.Set(i, margin + 6, color.Black)
|
||||
img.Set(margin + 6, i, color.Black)
|
||||
}
|
||||
}
|
||||
img.Set(margin + 8, size - 4, color.Black)
|
||||
|
||||
var imgBuf bytes.Buffer
|
||||
err := png.Encode(&imgBuf, img)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
base64Img := base64.StdEncoding.EncodeToString(imgBuf.Bytes())
|
||||
|
||||
return "data:image/png;base64," + base64Img, nil
|
||||
}
|
||||
|
||||
func drawLargeAlignmentSquare(x int, y int, img *image.Gray) {
|
||||
for yi := range 7 {
|
||||
for xi := range 7 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue