Documentation
¶
Overview ¶
Package ogcard provides OpenGraph card image generation for ATCR.
Index ¶
- Constants
- Variables
- type Card
- func (c *Card) DrawAvatarOrPlaceholder(url string, x, y, size int, letter string)
- func (c *Card) DrawBadge(text string, x, y int, fontSize float64, bgColor, textColor color.Color) int
- func (c *Card) DrawBranding()
- func (c *Card) DrawCircularImage(img image.Image, x, y, diameter int)
- func (c *Card) DrawIcon(name string, x, y, size int, col color.Color)
- func (c *Card) DrawImage(img image.Image, x, y int)
- func (c *Card) DrawPlaceholderCircle(x, y, diameter int, bgColor, textColor color.Color, letter string)
- func (c *Card) DrawRect(x, y, w, h int, col color.Color)
- func (c *Card) DrawRoundedRect(x, y, w, h, radius int, col color.Color)
- func (c *Card) DrawStatWithIcon(icon string, text string, x, y int, iconColor, textColor color.Color) int
- func (c *Card) DrawText(text string, x, y float64, size float64, col color.Color, align int, bold bool)
- func (c *Card) DrawTextWrapped(text string, x, y float64, size float64, col color.Color, maxWidth int, ...) float64
- func (c *Card) EncodePNG(w io.Writer) error
- func (c *Card) FetchAndDrawCircularImage(url string, x, y, diameter int) error
- func (c *Card) Fill(col color.Color)
- func (c *Card) MeasureText(text string, size float64, bold bool) int
- type Layout
Constants ¶
const ( AlignLeft = iota AlignCenter AlignRight )
Text alignment constants
const ( // Card dimensions CardWidth = 1200 CardHeight = 630 // Padding and sizing Padding = 60 AvatarSize = 180 // Positioning offsets IconTopOffset = 50 // Y offset from padding for icon TextGapAfterIcon = 40 // X gap between icon and text TextTopOffset = 50 // Y offset from icon top for text baseline // Font sizes FontTitle = 48.0 FontDescription = 32.0 FontStats = 40.0 // Larger for visibility when scaled down FontBadge = 32.0 // Larger for visibility when scaled down FontBranding = 28.0 // Spacing LineSpacingLarge = 65 // Gap after title LineSpacingSmall = 60 // Gap between description lines StatsIconGap = 48 // Gap between stat icon and text StatsItemGap = 60 // Gap between stat items BadgeGap = 20 // Gap between badges )
Layout constants for OG cards
Variables ¶
var ( ColorBackground = color.RGBA{R: 22, G: 27, B: 34, A: 255} // #161b22 - GitHub dark elevated ColorText = color.RGBA{R: 230, G: 237, B: 243, A: 255} // #e6edf3 - Light text ColorMuted = color.RGBA{R: 125, G: 133, B: 144, A: 255} // #7d8590 - Muted text ColorAccent = color.RGBA{R: 47, G: 129, B: 247, A: 255} // #2f81f7 - Blue accent ColorStar = color.RGBA{R: 227, G: 179, B: 65, A: 255} // #e3b341 - Star yellow ColorBadgeBg = color.RGBA{R: 33, G: 38, B: 45, A: 255} // #21262d - Badge background ColorBadgeAccent = color.RGBA{R: 31, G: 111, B: 235, A: 255} // #1f6feb - Blue badge bg )
Common colors
Functions ¶
This section is empty.
Types ¶
type Card ¶
type Card struct {
// contains filtered or unexported fields
}
Card represents an OG image canvas
func NewCard ¶
func NewCard() *Card
NewCard creates a new OG card with the standard 1200x630 dimensions
func NewCardWithSize ¶
NewCardWithSize creates a new OG card with custom dimensions
func (*Card) DrawAvatarOrPlaceholder ¶
DrawAvatarOrPlaceholder draws a circular avatar from URL, falling back to placeholder
func (*Card) DrawBadge ¶
func (c *Card) DrawBadge(text string, x, y int, fontSize float64, bgColor, textColor color.Color) int
DrawBadge draws a pill-shaped badge with text
func (*Card) DrawBranding ¶
func (c *Card) DrawBranding()
DrawBranding draws "ATCR" in the bottom-right corner
func (*Card) DrawCircularImage ¶
DrawCircularImage draws an image cropped to a circle
func (*Card) DrawIcon ¶
DrawIcon draws a Lucide icon at the specified position with the given size and color.
func (*Card) DrawPlaceholderCircle ¶
func (c *Card) DrawPlaceholderCircle(x, y, diameter int, bgColor, textColor color.Color, letter string)
DrawPlaceholderCircle draws a colored circle with a letter
func (*Card) DrawRoundedRect ¶
DrawRoundedRect draws a filled rounded rectangle
func (*Card) DrawStatWithIcon ¶
func (c *Card) DrawStatWithIcon(icon string, text string, x, y int, iconColor, textColor color.Color) int
DrawStatWithIcon draws an icon + text stat and returns the next X position
func (*Card) DrawText ¶
func (c *Card) DrawText(text string, x, y float64, size float64, col color.Color, align int, bold bool)
DrawText draws text at the specified position.
func (*Card) DrawTextWrapped ¶
func (c *Card) DrawTextWrapped(text string, x, y float64, size float64, col color.Color, maxWidth int, bold bool) float64
DrawTextWrapped draws text with word wrapping within maxWidth Returns the Y position after the last line
func (*Card) FetchAndDrawCircularImage ¶
FetchAndDrawCircularImage fetches an image from URL and draws it as a circle
type Layout ¶
type Layout struct {
IconX int
IconY int
TextX float64
TextY float64
StatsY int
MaxWidth int // For text wrapping
}
Layout holds computed positions for a standard OG card layout
func StandardLayout ¶
func StandardLayout() Layout
StandardLayout returns the standard OG card layout with computed positions