🌐 Samsung Mobile Animation
import pygame
import sys
import math
import random
def samsung_galaxy_mobile():
# Screen size
width, height = 360, 640
pygame.init()
screen = pygame.display.set_mode((width, height))
pygame.display.set_caption("Samsung Mobile Animation")
clock = pygame.time.Clock()
# Colors
BLACK = (0, 0, 0)
BLUE = (0, 100, 255)
WHITE = (255, 255, 255)
# Stars data: x, y, size, base brightness
stars = []
for _ in range(100):
stars.append([
random.uniform(0, width),
random.uniform(0, height),
random.uniform(0.5, 2), # star radius
random.randint(150, 255) # base brightness
])
angle = 0
radius = 0
max_radius = 150
running = True
frame_count = 0
# Font for "SAMSUNG"
font = pygame.font.SysFont('Arial', 40, bold=True)
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
screen.fill(BLACK)
# Animate stars with twinkling & slight vertical movement
for star in stars:
# twinkle brightness oscillates sinusoidally
twinkle = star[3] + 50 * math.sin(frame_count * 0.1 + star[0])
twinkle = max(150, min(255, twinkle))
# slight vertical oscillation
star[1] += 0.05 * math.sin(frame_count * 0.05 + star[0])
if star[1] > height:
star[1] = 0
elif star[1] < 0:
star[1] = height
color = (int(twinkle), int(twinkle), int(twinkle))
pygame.draw.circle(screen, color, (int(star[0]), int(star[1])), int(star[2]))
# Grow the galaxy radius slowly
if radius < max_radius:
radius += 1.5 # slower growth for smoothness
angle += 0.03 # rotation speed
points = []
for i in range(0, 360, 10):
rad = math.radians(i + angle * 30)
# Elliptical spiral for galaxy shape
x = width // 2 + math.cos(rad) * radius * 0.85
y = height // 2 + math.sin(rad) * radius * 0.55
points.append((x, y))
# Draw multiple concentric glowing polygons for galaxy effect
for glow in range(3, 0, -1):
alpha = max(0, 50 * glow * (radius / max_radius)) # fading glow
glow_color = (0, 100, 255, int(alpha)) # semi-transparent blue
# Pygame doesn't support alpha directly on lines, so draw thicker lines with fading color
pygame.draw.polygon(screen, (0, 100, 255), points, width=glow)
# Text fade-in and pulse effect
pulse = (math.sin(frame_count * 0.1) + 1) / 2 # from 0 to 1
alpha = int(255 * min(1, radius / max_radius)) # fade in with radius growth
pulse_alpha = int(alpha * (0.7 + 0.3 * pulse)) # pulse between 70%-100% opacity
# Render text with pulse alpha on a separate surface
text_surface = font.render("SAMSUNG", True, WHITE)
text_surface.set_alpha(pulse_alpha)
text_rect = text_surface.get_rect(center=(width // 2, height // 2))
screen.blit(text_surface, text_rect)
pygame.display.flip()
clock.tick(60)
frame_count += 1
if radius >= max_radius and frame_count > 300:
running = False
pygame.quit()
sys.exit()
samsung_galaxy_mobile()