craiyon logo

Anime girl with dark hair and bright green eyes, water droplets on her skin, against a blue and green background.

Anime girl with dark hair and bright green eyes, water droplets on her skin, against a blue and green background.

from PIL import Image, ImageDraw, ImageFont, ImageEnhance import random import os from dataclasses import dataclass from typing import Tuple, Optional, List @dataclass class FaceConfig: """Configuration class for face generation parameters""" width: int = 1280 height: int = 720 bg_color: Tuple[int, int, int] = (10, 10, 30) face_color: Tuple[int, int, int] = (245, 215, 175) outline_color: Tuple[int, int, int] = (20, 20, 20) blush_color: Tuple[int, int, int] = (255, 130, 150) mouth_color: Tuple[int, int, int] = (220, 50, 50) mouth_inner_color: Tuple[int, int, int] = (255, 90, 110) sweat_color: Tuple[int, int, int] = (220, 240, 255) sparkle_color: Tuple[int, int, int] = (255, 255, 180) # Positioning face_center_x: Optional[int] = None face_top: int = 40 face_height: int = 580 face_width: int = 600 def __post_init__(self): if self.face_center_x is None: self.face_center_x = self.width // 2 class AnimeFaceGenerator: """Main generator class for creating anime-style faces""" def __init__(self, config: FaceConfig = None): self.config = config or FaceConfig() self.img = None self.draw = None def create_background(self) -> None: """Create gradient background with vignette effect""" # Create base image self.img = Image.new('RGB', (self.config.width, self.config.height), color=self.config.bg_color) self.draw = ImageDraw.Draw(self.img) # Explosive gradient for y in range(self.config.height): progress = y / self.config.height r = 255 g = int(20 + progress * 235) b = int(0 + progress * 60) Mehr sehen