Every like gives me a bigger pumpkin head
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

oh we cooking

Bailey Townsend 4ecbc3df

+143
+2
.gitignore
··· 1 + bighead 2 + .idea
base_images/pumpkin_body.png

This is a binary file and will not be displayed.

base_images/pumpkin_head.png

This is a binary file and will not be displayed.

+5
go.mod
··· 1 + module pumpkin_head 2 + 3 + go 1.25.5 4 + 5 + require golang.org/x/image v0.35.0
+2
go.sum
··· 1 + golang.org/x/image v0.35.0 h1:LKjiHdgMtO8z7Fh18nGY6KDcoEtVfsgLDPeLyguqb7I= 2 + golang.org/x/image v0.35.0/go.mod h1:MwPLTVgvxSASsxdLzKrl8BRFuyqMyGhLwmC+TO1Sybk=
+134
main.go
··· 1 + package main 2 + 3 + import ( 4 + "fmt" 5 + "image" 6 + "image/draw" 7 + "image/png" 8 + "os" 9 + "path/filepath" 10 + 11 + xdraw "golang.org/x/image/draw" 12 + ) 13 + 14 + type PumpkinHead struct { 15 + bodyImg image.Image 16 + headImg image.Image 17 + callCount int 18 + scaleStep float64 19 + outputDir string 20 + } 21 + 22 + func NewPumpkinHead(bodyPath, headPath, outputDir string) (*PumpkinHead, error) { 23 + // Load body image 24 + bodyFile, err := os.Open(bodyPath) 25 + if err != nil { 26 + return nil, fmt.Errorf("failed to open body image: %w", err) 27 + } 28 + defer bodyFile.Close() 29 + 30 + bodyImg, err := png.Decode(bodyFile) 31 + if err != nil { 32 + return nil, fmt.Errorf("failed to decode body image: %w", err) 33 + } 34 + 35 + // Load head image 36 + headFile, err := os.Open(headPath) 37 + if err != nil { 38 + return nil, fmt.Errorf("failed to open head image: %w", err) 39 + } 40 + defer headFile.Close() 41 + 42 + headImg, err := png.Decode(headFile) 43 + if err != nil { 44 + return nil, fmt.Errorf("failed to decode head image: %w", err) 45 + } 46 + 47 + // Create output directory if it doesn't exist 48 + if err := os.MkdirAll(outputDir, 0755); err != nil { 49 + return nil, fmt.Errorf("failed to create output directory: %w", err) 50 + } 51 + 52 + return &PumpkinHead{ 53 + bodyImg: bodyImg, 54 + headImg: headImg, 55 + callCount: 0, 56 + scaleStep: 0.1, // Grow by 10% each call 57 + outputDir: outputDir, 58 + }, nil 59 + } 60 + 61 + func (p *PumpkinHead) GrowHead() error { 62 + p.callCount++ 63 + 64 + // Calculate new scale (starts at 1.0, grows by scaleStep each time) 65 + scale := 1.0 + (float64(p.callCount) * p.scaleStep) 66 + 67 + fmt.Printf("Call #%d: Growing head to %.1fx original size\n", p.callCount, scale) 68 + 69 + // Get dimensions 70 + bodyBounds := p.bodyImg.Bounds() 71 + headBounds := p.headImg.Bounds() 72 + 73 + // Calculate scaled head dimensions 74 + newHeadWidth := int(float64(headBounds.Dx()) * scale) 75 + newHeadHeight := int(float64(headBounds.Dy()) * scale) 76 + 77 + // Create a new image for the scaled head 78 + scaledHead := image.NewRGBA(image.Rect(0, 0, newHeadWidth, newHeadHeight)) 79 + 80 + // Scale the head using bilinear interpolation 81 + xdraw.BiLinear.Scale(scaledHead, scaledHead.Bounds(), p.headImg, headBounds, draw.Over, nil) 82 + 83 + // Create output image (use body dimensions) 84 + output := image.NewRGBA(bodyBounds) 85 + 86 + // Draw body first 87 + draw.Draw(output, bodyBounds, p.bodyImg, image.Point{0, 0}, draw.Src) 88 + 89 + // Calculate position to center the head on top of the body 90 + // Place head in upper portion of the image 91 + headX := (bodyBounds.Dx() - newHeadWidth) / 2 92 + headY := bodyBounds.Dy()/8 - newHeadHeight/2 + 1900 // Position in upper area (adjusted down by 1500px) 93 + 94 + headPos := image.Rect(headX, headY, headX+newHeadWidth, headY+newHeadHeight) 95 + 96 + // Draw scaled head on top 97 + draw.Draw(output, headPos, scaledHead, image.Point{0, 0}, draw.Over) 98 + 99 + // Save to file 100 + filename := filepath.Join(p.outputDir, fmt.Sprintf("bighead_%03d.png", p.callCount)) 101 + outFile, err := os.Create(filename) 102 + if err != nil { 103 + return fmt.Errorf("failed to create output file: %w", err) 104 + } 105 + defer outFile.Close() 106 + 107 + if err := png.Encode(outFile, output); err != nil { 108 + return fmt.Errorf("failed to encode PNG: %w", err) 109 + } 110 + 111 + fmt.Printf("Saved to: %s\n", filename) 112 + return nil 113 + } 114 + 115 + func main() { 116 + pumpkin, err := NewPumpkinHead("base_images/pumpkin_body.png", "base_images/pumpkin_head.png", "bighead") 117 + if err != nil { 118 + fmt.Fprintf(os.Stderr, "Error initializing: %v\n", err) 119 + os.Exit(1) 120 + } 121 + 122 + fmt.Println("Pumpkin Head Grower!") 123 + fmt.Println("==================") 124 + 125 + // Call the method 5 times to demonstrate 126 + for i := 0; i < 5; i++ { 127 + if err := pumpkin.GrowHead(); err != nil { 128 + fmt.Fprintf(os.Stderr, "Error growing head: %v\n", err) 129 + os.Exit(1) 130 + } 131 + } 132 + 133 + fmt.Println("\nDone! Check the 'bighead' directory for results.") 134 + }