package main import ( "fmt" "os" "github.com/landaiqing/freezelib" ) func main() { fmt.Println("šŸŽØ Theme Showcase Examples") fmt.Println("===========================") // Create output directory os.MkdirAll("output", 0755) // Run theme examples popularThemesExample() lightVsDarkExample() themeComparisonExample() customThemeExample() fmt.Println("\nāœ… Theme examples completed!") fmt.Println("šŸ“ Check the 'output' directory for generated files.") fmt.Println("šŸŽØ Compare different themes and their visual styles.") } // Popular themes showcase func popularThemesExample() { fmt.Println("\n🌟 Popular Themes Showcase") fmt.Println("--------------------------") code := `class DataProcessor: def __init__(self, data_source): self.data_source = data_source self.processed_data = [] def process(self): """Process the data with validation and transformation.""" try: raw_data = self.load_data() validated_data = self.validate(raw_data) self.processed_data = self.transform(validated_data) return True except Exception as e: print(f"Processing failed: {e}") return False def validate(self, data): # Remove null values and duplicates clean_data = [item for item in data if item is not None] return list(set(clean_data)) def transform(self, data): # Apply business logic transformations return [item.upper() if isinstance(item, str) else item for item in data]` // Popular themes to showcase themes := []struct { name string description string }{ {"github", "GitHub light theme - clean and professional"}, {"github-dark", "GitHub dark theme - modern and sleek"}, {"dracula", "Dracula theme - purple and pink accents"}, {"monokai", "Monokai theme - classic dark with vibrant colors"}, {"solarized-dark", "Solarized dark - easy on the eyes"}, {"solarized-light", "Solarized light - warm and readable"}, {"nord", "Nord theme - arctic, north-bluish color palette"}, {"one-dark", "One Dark theme - Atom's signature theme"}, {"material", "Material theme - Google's material design"}, {"vim", "Vim theme - classic terminal colors"}, } for _, theme := range themes { fmt.Printf("šŸŽØ Generating %s theme...\n", theme.name) freeze := freezelib.New(). WithTheme(theme.name). WithFont("JetBrains Mono", 14). WithWindow(true). WithLineNumbers(true). WithShadow(15, 0, 8). WithPadding(20) svgData, err := freeze.GenerateFromCode(code, "python") if err != nil { fmt.Printf("āŒ Error with theme %s: %v\n", theme.name, err) continue } filename := fmt.Sprintf("output/theme_%s.svg", theme.name) err = os.WriteFile(filename, svgData, 0644) if err != nil { fmt.Printf("āŒ Error saving %s: %v\n", filename, err) continue } fmt.Printf("āœ… Generated: %s - %s\n", filename, theme.description) } } // Light vs Dark theme comparison func lightVsDarkExample() { fmt.Println("\nā˜€ļøšŸŒ™ Light vs Dark Comparison") fmt.Println("------------------------------") code := ` Modern Web App

Welcome to Our App

Features

This is a modern web application with responsive design.

` // Light and dark theme pairs themePairs := []struct { light string dark string name string }{ {"github", "github-dark", "GitHub"}, {"solarized-light", "solarized-dark", "Solarized"}, {"material", "one-dark", "Material vs One Dark"}, } for _, pair := range themePairs { fmt.Printf("šŸ”„ Comparing %s themes...\n", pair.name) // Light theme lightFreeze := freezelib.New(). WithTheme(pair.light). WithFont("SF Mono", 13). WithWindow(true). WithLineNumbers(true). WithShadow(10, 0, 5). WithPadding(25) lightData, err := lightFreeze.GenerateFromCode(code, "html") if err != nil { fmt.Printf("āŒ Error with light theme: %v\n", err) continue } // Dark theme darkFreeze := freezelib.New(). WithTheme(pair.dark). WithFont("SF Mono", 13). WithWindow(true). WithLineNumbers(true). WithShadow(15, 0, 10). WithPadding(25) darkData, err := darkFreeze.GenerateFromCode(code, "html") if err != nil { fmt.Printf("āŒ Error with dark theme: %v\n", err) continue } // Save files lightFile := fmt.Sprintf("output/comparison_%s_light.svg", sanitizeFilename(pair.name)) darkFile := fmt.Sprintf("output/comparison_%s_dark.svg", sanitizeFilename(pair.name)) os.WriteFile(lightFile, lightData, 0644) os.WriteFile(darkFile, darkData, 0644) fmt.Printf("āœ… Generated: %s (light)\n", lightFile) fmt.Printf("āœ… Generated: %s (dark)\n", darkFile) } } // Theme comparison grid func themeComparisonExample() { fmt.Println("\nšŸ“Š Theme Comparison Grid") fmt.Println("------------------------") // Short code snippet for comparison code := `fn main() { let numbers = vec![1, 2, 3, 4, 5]; let doubled: Vec = numbers .iter() .map(|x| x * 2) .collect(); println!("Original: {:?}", numbers); println!("Doubled: {:?}", doubled); // Pattern matching match doubled.len() { 0 => println!("Empty vector"), 1..=5 => println!("Small vector"), _ => println!("Large vector"), } }` // Themes for comparison comparisonThemes := []string{ "github", "github-dark", "dracula", "monokai", "nord", "one-dark", "material", "vim", } for i, theme := range comparisonThemes { fmt.Printf("šŸŽÆ Creating comparison sample %d: %s\n", i+1, theme) freeze := freezelib.New(). WithTheme(theme). WithFont("Fira Code", 12). WithWindow(false). // No window for cleaner comparison WithLineNumbers(false). WithPadding(15). WithDimensions(600, 400) // Consistent size svgData, err := freeze.GenerateFromCode(code, "rust") if err != nil { fmt.Printf("āŒ Error: %v\n", err) continue } filename := fmt.Sprintf("output/comparison_grid_%02d_%s.svg", i+1, theme) err = os.WriteFile(filename, svgData, 0644) if err != nil { fmt.Printf("āŒ Error saving: %v\n", err) continue } fmt.Printf("āœ… Generated: %s\n", filename) } } // Custom theme example func customThemeExample() { fmt.Println("\nšŸŽØ Custom Theme Example") fmt.Println("------------------------") code := `package main import ( "encoding/json" "fmt" "net/http" ) type Response struct { Message string 'json:"message"' Data map[string]interface{} 'json:"data"' Status int 'json:"status"' } func apiHandler(w http.ResponseWriter, r *http.Request) { response := Response{ Message: "API is working!", Data: map[string]interface{}{ "timestamp": "2024-01-15T10:30:00Z", "version": "1.0.0", "healthy": true, }, Status: 200, } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(response) } func main() { http.HandleFunc("/api/status", apiHandler) fmt.Println("API server starting on :8080") http.ListenAndServe(":8080", nil) }` // Create custom-styled versions customStyles := []struct { name string config func() *freezelib.Freeze desc string }{ { "corporate", func() *freezelib.Freeze { return freezelib.New(). WithTheme("github"). WithFont("Arial", 14). WithBackground("#f8f9fa"). WithWindow(true). WithLineNumbers(true). WithShadow(5, 2, 3). WithBorder(1, 4, "#dee2e6"). WithPadding(30) }, "Corporate style - clean and professional", }, { "cyberpunk", func() *freezelib.Freeze { return freezelib.New(). WithTheme("dracula"). WithFont("Courier New", 13). WithBackground("#0d1117"). WithWindow(true). WithLineNumbers(true). WithShadow(20, 0, 15). WithBorder(2, 0, "#ff79c6"). WithPadding(25) }, "Cyberpunk style - neon and futuristic", }, { "minimal", func() *freezelib.Freeze { return freezelib.New(). WithTheme("github"). WithFont("system-ui", 13). WithBackground("#ffffff"). WithWindow(false). WithLineNumbers(false). WithShadow(0, 0, 0). WithPadding(20) }, "Minimal style - clean and distraction-free", }, } for _, style := range customStyles { fmt.Printf("✨ Creating %s style...\n", style.name) freeze := style.config() svgData, err := freeze.GenerateFromCode(code, "go") if err != nil { fmt.Printf("āŒ Error: %v\n", err) continue } filename := fmt.Sprintf("output/custom_%s.svg", style.name) err = os.WriteFile(filename, svgData, 0644) if err != nil { fmt.Printf("āŒ Error saving: %v\n", err) continue } fmt.Printf("āœ… Generated: %s - %s\n", filename, style.desc) } } // Helper function to sanitize filenames func sanitizeFilename(name string) string { // Replace spaces and special characters with underscores result := "" for _, char := range name { if (char >= 'a' && char <= 'z') || (char >= 'A' && char <= 'Z') || (char >= '0' && char <= '9') { result += string(char) } else { result += "_" } } return result }