Skip to main content

Pixel Generator

Project description

PixelGen

PixelGen is a Python library that simplifies pixel art creation, making it faster and more detailed. This library provides various tools to create, manipulate, and generate pixel art.

🚀 Features

  • Create pixel art canvas with customizable dimensions
  • Individual pixel manipulation
  • Area filling with colors
  • Color gradient generation
  • Pattern creation
  • Save results in image format

📦 Installation

pip install pixelgen

🎨 Basic Usage

Creating Simple Pixel Art

from pixelgen.core import PixelGenerator
from pixelgen.tools import create_gradient, create_pattern

# Initialize a 32x32 canvas
pixel_art = PixelGenerator(32, 32)

# Set individual pixels
pixel_art.set_pixel(0, 0, (255, 0, 0))  # Red
pixel_art.set_pixel(1, 1, (0, 255, 0))  # Green

# Fill area with color
pixel_art.fill_area(10, 10, 20, 20, (0, 0, 255))  # Blue area

# Save result
pixel_art.save_image("pixel_art_result.png")

Creating Gradients

# Create gradient from red to blue with 10 steps
gradient = create_gradient((255, 0, 0), (0, 0, 255), 10)

Creating Patterns

# Create 8x8 checkered pattern
pattern = create_pattern(8, (255, 0, 0), (0, 0, 255))

📚 API Reference

PixelGenerator

__init__(width: int, height: int)

Creates a new pixel art canvas with specified dimensions.

set_pixel(x: int, y: int, color: tuple)

Sets color for a specific pixel.

  • x, y: Pixel coordinates
  • color: RGB tuple (red, green, blue)

fill_area(x1: int, y1: int, x2: int, y2: int, color: tuple)

Fills a rectangular area with a specific color.

  • x1, y1: Top-left corner coordinates
  • x2, y2: Bottom-right corner coordinates
  • color: RGB tuple (red, green, blue)

save_image(filename: str)

Saves pixel art as an image file.

  • filename: Output filename

Tools

create_gradient(color1: tuple, color2: tuple, steps: int)

Creates a gradient between two colors.

  • color1: Starting color (RGB)
  • color2: Ending color (RGB)
  • steps: Number of gradient steps

create_pattern(pattern_size: int, color1: tuple, color2: tuple)

Creates a checkered pattern.

  • pattern_size: Pattern size
  • color1, color2: Colors for pattern (RGB)

🌟 Advanced Examples

Creating Complex Patterns

# Create a rainbow gradient
colors = [
    (255, 0, 0),    # Red
    (255, 127, 0),  # Orange
    (255, 255, 0),  # Yellow
    (0, 255, 0),    # Green
    (0, 0, 255),    # Blue
    (75, 0, 130),   # Indigo
    (148, 0, 211)   # Violet
]

# Apply gradient to canvas
for i, color in enumerate(colors):
    pixel_art.fill_area(i*4, 0, (i+1)*4, 32, color)

🔧 Requirements

  • Python >= 3.6
  • PIL >= 5.2.0
  • NumPy

🤝 Contributing

Contributions are always welcome! Please feel free to submit a Pull Request or create an Issue for any improvements or suggestions.

Development Setup

  1. Clone the repository
git clone https://github.com/rifqanzalbina/product-generator.git
  1. Install development dependencies
pip install -r requirements.txt
  1. Run tests
python -m pytest

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👤 Author

🔗 Links

🗺️ Roadmap

  • Add more pattern generation tools
  • Implement layer system
  • Add undo/redo functionality
  • Add AI-powered pixel art generation
  • Implement real-time preview
  • Add export to multiple formats

❓ FAQ

Q: Can I use this for commercial projects? A: Yes, PixelGen is released under the MIT license, which allows commercial use.

Q: What image formats are supported? A: Currently, PixelGen supports saving to common image formats like PNG, JPEG, and BMP.

Q: Is there a size limit for pixel art? A: The size is limited only by your system's memory capacity.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pixelgen-0.0.2.tar.gz (4.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pixelgen-0.0.2-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file pixelgen-0.0.2.tar.gz.

File metadata

  • Download URL: pixelgen-0.0.2.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for pixelgen-0.0.2.tar.gz
Algorithm Hash digest
SHA256 efef861b8b6a4cb4ee8aa766513f1661f36342e0392c8f35fb5aaa716376f63b
MD5 1e57c49a4d0daacfff0242a4e4fc0386
BLAKE2b-256 1ad000dea7614a32697da16cab1377c2c5f64fbaf52b5304edf01f8a5cde66eb

See more details on using hashes here.

File details

Details for the file pixelgen-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: pixelgen-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.6

File hashes

Hashes for pixelgen-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ad9a635deaa770c3ccf455c2683a9fa8c8c25e6e04f5c19bea722a2bb60c369
MD5 f1b2a708205e8161241238963ec291b0
BLAKE2b-256 9c8d455c85170383c4acbb4027e6ef00d0e24a573e3449cee720f26586c4ff9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page