Initial commit: img-infinite-canvas AI design workbench MVP
Moteva-style AI design workbench replica. Home prompt creates a project; the project page provides an infinite canvas with node drag, zoom/pan, a design chat panel, history replay, image asset upload, and project save/regenerate. - Backend: go-zero, DDD layering, sqlc/pgx, optional PostgreSQL; memory or Redis cache; asynq job queue; MinIO/S3/R2/OSS object storage; sky-valley/pi agent runtime adapter. - Frontend: Next.js App Router + Vite artifact build, TypeScript, i18n, shadcn/ui components, auth (OTP/Turnstile/Google/WeChat). - Deploy: Docker Compose and k3s manifests. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
package design
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
DefaultGeneratedImageSize = "1024x1024"
|
||||
DefaultGeneratedImageWidth = 1024
|
||||
DefaultGeneratedImageHeight = 1024
|
||||
)
|
||||
|
||||
func ParseImageSize(size string) (float64, float64, bool) {
|
||||
size = strings.ToLower(strings.TrimSpace(size))
|
||||
if size == "" {
|
||||
return 0, 0, false
|
||||
}
|
||||
size = strings.NewReplacer(" ", "", "\t", "", "\n", "", "×", "x", "*", "x").Replace(size)
|
||||
parts := strings.Split(size, "x")
|
||||
if len(parts) != 2 {
|
||||
return 0, 0, false
|
||||
}
|
||||
width, err := strconv.ParseFloat(parts[0], 64)
|
||||
if err != nil || width <= 0 {
|
||||
return 0, 0, false
|
||||
}
|
||||
height, err := strconv.ParseFloat(parts[1], 64)
|
||||
if err != nil || height <= 0 {
|
||||
return 0, 0, false
|
||||
}
|
||||
return width, height, true
|
||||
}
|
||||
|
||||
func GeneratedImageDimensions(size string) (float64, float64) {
|
||||
if width, height, ok := ParseImageSize(size); ok {
|
||||
return width, height
|
||||
}
|
||||
return DefaultGeneratedImageWidth, DefaultGeneratedImageHeight
|
||||
}
|
||||
Reference in New Issue
Block a user