From 713a8060d40775b416b0a22c5d9e842ccfa254b1 Mon Sep 17 00:00:00 2001 From: Deepakraghavan01 <57013229+Deepakraghavan01@users.noreply.github.com> Date: Fri, 31 Oct 2025 02:10:13 +0530 Subject: [PATCH 1/2] Add random art collage generator script This script generates random abstract art using shapes and text. --- .../random_art_collage.py | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 Random_Art_Collage_Generator_#1693/random_art_collage.py diff --git a/Random_Art_Collage_Generator_#1693/random_art_collage.py b/Random_Art_Collage_Generator_#1693/random_art_collage.py new file mode 100644 index 0000000..ffdf951 --- /dev/null +++ b/Random_Art_Collage_Generator_#1693/random_art_collage.py @@ -0,0 +1,108 @@ +""" +random_art_collage.py + +A Python program that automatically generates random abstract art +by drawing random shapes, colors, and text onto a canvas. + +Each run produces a unique collage-like pattern with: +- Random circles, rectangles, and lines +- Random colors and transparencies +- Random text placements and sizes +""" + +import pygame, random, sys + +# --- Configuration --- +WIDTH, HEIGHT = 900, 600 +SHAPE_COUNT = 100 # total number of random shapes +TEXT_COUNT = 8 # random text phrases count +BG_COLOR = (20, 20, 30) +FONT_NAMES = ["arial", "verdana", "timesnewroman", "couriernew"] + +# Some random text phrases for artistic feel +WORDS = [ + "dream", "code", "flow", "energy", "pulse", + "random", "vibe", "create", "art", "infinity" +] + +def random_color(alpha=False): + """Generate a random RGB or RGBA color.""" + color = [random.randint(0, 255) for _ in range(3)] + if alpha: + color.append(random.randint(50, 255)) # transparency + return tuple(color) + +def draw_random_shape(surface): + """Draw a random shape (circle, rectangle, or line).""" + shape_type = random.choice(["circle", "rect", "line"]) + color = random_color() + if shape_type == "circle": + pos = (random.randint(0, WIDTH), random.randint(0, HEIGHT)) + radius = random.randint(10, 100) + pygame.draw.circle(surface, color, pos, radius, random.randint(1, 8)) + elif shape_type == "rect": + rect = pygame.Rect( + random.randint(0, WIDTH), + random.randint(0, HEIGHT), + random.randint(30, 200), + random.randint(30, 200), + ) + pygame.draw.rect(surface, color, rect, random.randint(0, 5)) + else: # line + start = (random.randint(0, WIDTH), random.randint(0, HEIGHT)) + end = (random.randint(0, WIDTH), random.randint(0, HEIGHT)) + pygame.draw.line(surface, color, start, end, random.randint(1, 6)) + +def draw_random_text(surface): + """Draw random text at a random position and size.""" + text = random.choice(WORDS) + font_name = random.choice(FONT_NAMES) + size = random.randint(20, 100) + font = pygame.font.SysFont(font_name, size, bold=random.choice([True, False])) + color = random_color() + rendered = font.render(text, True, color) + x = random.randint(0, WIDTH - rendered.get_width()) + y = random.randint(0, HEIGHT - rendered.get_height()) + surface.blit(rendered, (x, y)) + +def generate_random_art(): + """Generate the abstract art collage and display it.""" + pygame.init() + screen = pygame.display.set_mode((WIDTH, HEIGHT)) + pygame.display.set_caption("Random Art Collage Generator") + clock = pygame.time.Clock() + + # Create a semi-transparent surface for layered look + surface = pygame.Surface((WIDTH, HEIGHT), pygame.SRCALPHA) + surface.fill(BG_COLOR) + + # Draw random shapes + for _ in range(SHAPE_COUNT): + draw_random_shape(surface) + + # Draw random text + for _ in range(TEXT_COUNT): + draw_random_text(surface) + + # Display final art + screen.blit(surface, (0, 0)) + pygame.display.flip() + + print("Random art generated! Press any key or close window to exit.") + running = True + while running: + for event in pygame.event.get(): + if event.type == pygame.QUIT or event.type == pygame.KEYDOWN: + running = False + clock.tick(30) + + # Optionally save the artwork + filename = f"random_art_{random.randint(1000,9999)}.png" + pygame.image.save(screen, filename) + print(f"Artwork saved as {filename}") + + pygame.quit() + sys.exit() + +if __name__ == "__main__": + generate_random_art() From 53cd44adf263b7f88316819952f287056ac81dbd Mon Sep 17 00:00:00 2001 From: Deepakraghavan01 <57013229+Deepakraghavan01@users.noreply.github.com> Date: Fri, 31 Oct 2025 02:11:11 +0530 Subject: [PATCH 2/2] Create README.md for Random Art Collage Generator Added README.md with project description, features, and requirements. --- Random_Art_Collage_Generator_#1693/README.md | 25 ++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Random_Art_Collage_Generator_#1693/README.md diff --git a/Random_Art_Collage_Generator_#1693/README.md b/Random_Art_Collage_Generator_#1693/README.md new file mode 100644 index 0000000..622a6ca --- /dev/null +++ b/Random_Art_Collage_Generator_#1693/README.md @@ -0,0 +1,25 @@ +# Random Art Collage Generator + +A Python program that automatically generates **abstract digital art** by combining **random shapes, colors, and text** onto a canvas. + +Each time you run the program, it produces a **unique artwork** — no two pieces are ever the same. +It’s a fun creative coding experiment that blends randomness with generative art. + +--- + +## Features + +- Random circles, rectangles, and lines with varying sizes and colors +- Random words rendered at random positions, fonts, and styles +- Transparent layers for a smooth overlapping collage look +- Automatically saves the generated artwork as a PNG file +- Fully customizable: number of shapes, colors, and text count + +--- + +## Requirements + +Make sure you have Python and `pygame` installed. + +```bash +pip install pygame