Skip to content

This project creates an evolving digital canvas where geometric shapes (lines and rectangles) are randomly generated with varying properties such as position, size, color, and stroke width. The result is a continuously developing abstract composition that's unique every time.

Notifications You must be signed in to change notification settings

chipsxp/Digital-Generative-Art-Visualizer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Digital Generative Art

A dynamic, interactive web application that creates procedurally generated art in real-time using HTML5 Canvas and JavaScript.

Overview

This project creates an evolving digital canvas where geometric shapes (lines and rectangles) are randomly generated with varying properties such as position, size, color, and stroke width. The result is a continuously developing abstract composition that's unique every time.

Features

Dynamic Art Generation

  • Procedural Generation: Shapes are created with randomized properties
  • Mixed Geometry: Alternates between lines and rectangles
  • Color Variety: Each shape has random fill and stroke colors
  • Size Variation: Shapes are generated with varying dimensions and line weights

Interactive Controls

  • Start/Stop: Toggle the generation process on and off
  • Snapshot: Capture the current state of the canvas as a PNG image
  • Responsive UI: Control buttons adapt to different screen sizes
    • Right-aligned on desktop/wide screens
    • Centered on mobile/smaller screens

Technical Implementation

Core Components

Canvas Setup (script.js)

The application initializes an HTML5 Canvas element as the drawing surface:

const canvas = document.getElementById('artboard');
const ctx = canvas.getContext('2d');
canvas.width = 620;
canvas.height = 540;

Shape Generation

Two primary shape classes handle the creation of random elements:

  1. Line Class

    • Generates lines with random start/end points and line widths
    • Each line has a unique position and appearance
  2. Rectangle Class

    • Creates rectangles with random position, size, fill color, stroke color, and line width
    • Combines filled rectangles with outlined strokes for visual interest

Generation Control

The drawing process can be controlled through:

function startDrawing() {
  if (!isDrawing) {
    isDrawing = true;
    drawingInterval = setInterval(() => {
      // Random shape generation logic
    }, 1000);
  }
}

function stopDrawing() {
  if (isDrawing) {
    isDrawing = false;
    clearInterval(drawingInterval);
  }
}

Snapshot Functionality (snapshot.js)

The application includes the ability to save the current canvas state:

function captureSnapshot(canvas) {
  const dataURL = canvas.toDataURL('image/png');
  const link = document.createElement('a');
  link.href = dataURL;
  
  // Generate a filename with timestamp
  const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
  link.download = `generative-art-${timestamp}.png`;
  
  document.body.appendChild(link);
  link.click();
  document.body.removeChild(link);
}

User Interface

The UI features a control panel with three buttons:

  • Start Button (Green): Begins the generation process
  • Stop Button (Red): Pauses the generation process
  • Snapshot Button (Blue): Captures and downloads the current canvas state

The control panel is styled with CSS to be visually appealing and responsive:

.controls-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    /* Additional styling */
}

/* Media query for smaller screens */
@media (max-width: 768px) {
    .controls-container {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
        justify-content: center;
    }
}

Usage

  1. Open the application in a web browser
  2. The generation process starts automatically
  3. Use the Stop button to pause generation
  4. Use the Start button to resume generation
  5. Click the Take Snapshot button to save the current artwork as a PNG file

Project Structure

/
├── index.html              # Main HTML document
├── README.md               # This documentation file
└── artlab/
    ├── script.js           # Main application logic
    ├── snapshot.js         # Image capture functionality
    └── style.css           # Styling for the application

Future Enhancements

Potential improvements for future versions:

  • Additional shape types (circles, triangles, polygons)
  • User-configurable generation parameters (speed, density, color palette)
  • Animation effects for shapes
  • Gallery of saved snapshots
  • Social sharing capabilities

License

MIT License

Acknowledgments

This project explores the intersection of programming and visual art, demonstrating how simple algorithms can create complex and aesthetically pleasing results.

About

This project creates an evolving digital canvas where geometric shapes (lines and rectangles) are randomly generated with varying properties such as position, size, color, and stroke width. The result is a continuously developing abstract composition that's unique every time.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published