Google Mobile Animation

🌐 Google Mobile Animation


import pygame
import sys
import math

def google_dots_mobile():
    # Mobile screen size
    width, height = 360, 640
    pygame.init()
    screen = pygame.display.set_mode((width, height))
    pygame.display.set_caption("Google Mobile Animation")
    clock = pygame.time.Clock()

    # Google colors (Blue, Red, Yellow, Green)
    COLORS = [(66, 133, 244), (234, 67, 53), (251, 188, 5), (52, 168, 83)]

    # Dot positions and properties
    dot_radius = 14
    spacing = 30
    base_x = width // 2 - (spacing * 1.5)
    y_center = height // 2
    positions = [(base_x + i * spacing, y_center) for i in range(4)]
    angles = [0.0, 0.3, 0.6, 0.9]  # Staggered for wave effect

    # Animation control
    frame = 0
    show_text = False
    text_opacity = 0

    running = True
    while running:
        screen.fill((255, 255, 255))

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False

        # Animate bouncing dots
        for i in range(4):
            y_offset = math.sin(angles[i]) * 10
            x, y = positions[i]
            pygame.draw.circle(screen, COLORS[i], (int(x), int(y + y_offset)), dot_radius)
            angles[i] += 0.12

        if frame > 60:
            show_text = True

        if show_text:
            if text_opacity < 255:
                text_opacity += 5

            font = pygame.font.SysFont('Product Sans', 36, bold=False)
            text_surface = font.render("Google", True, (100, 100, 100))
            text_surface.set_alpha(text_opacity)
            text_rect = text_surface.get_rect(center=(width // 2, y_center + 70))
            screen.blit(text_surface, text_rect)

        pygame.display.flip()
        clock.tick(60)
        frame += 1

        if frame > 180:
            running = False

    pygame.quit()
    sys.exit()

google_dots_mobile()

🔍 Output Preview