Skip to content

arran4/eightbyeight

Repository files navigation

EightByEight Pattern Generator

This project generates PNG images containing grids of 8x8 pixel patterns. It explores different permutations of patterns based on a modular arithmetic logic for colour dithering.

Description

The tool creates a grid where each cell contains a unique 8x8 pattern. It renders a title and labels for the grid. The patterns are generated using a "ColourSource" algorithm that determines the color of each pixel based on its coordinates and a mode index.

Usage

To run the project, you need Go installed.

go run ./cmd/eightbyeight all

You can also run specific examples using subcommands:

  • grid: Generates the standard 8x8 pattern grid variants.
  • floppy: Generates a stylized 90s aesthetic floppy disk to demonstrate drawing shapes.
  • all: Generates both grid and floppy outputs.

Running the all or grid command will generate four files in the current directory:

  • out_bw.png: Classic Black on White
  • out_terminal.png: Green on Black (Terminal style)
  • out_solarized.png: Solarized Light color scheme
  • out_mixing.png: CGA Color Mixing

Output

The output are PNG images with a title, a grid of patterns, and labels.

Usage with image/draw

You can use ColourSource as a source image in draw.Draw to fill shapes with patterns, like drawing a stylized 90s aesthetic floppy disk:

import (
	"image"
	"image/color"
	"image/draw"
	"github.com/arran4/eightbyeight"
)

// ...

// Create a new image to draw into
dst := image.NewRGBA(image.Rect(0, 0, 256, 256))

// Create a ColourSource pattern for the plastic shell
plasticPattern := eightbyeight.NewColourSource(110, color.RGBA{0, 255, 255, 255}, color.RGBA{255, 0, 255, 255})

// Fill the destination image using the pattern
draw.Draw(dst, image.Rect(32, 32, 224, 224), plasticPattern, image.Point{}, draw.Over)

Examples

Examples of generated patterns can be found in the exampledata/ directory.

Here are the generated outputs:

Classic - Black on White

Classic Output

Terminal - Green on Black

Terminal Output

Solarized Light

Solarized Output

CGA Color Mixing

CGA Mixing Output

Stylized Floppy Disk Example

Floppy Disk Output

Builder

The project includes a GridBuilder to programmatically configure and generate these pattern grids.

import "github.com/arran4/eightbyeight"

// ...

builder := eightbyeight.NewGridBuilder().
    WithTitle("My Custom Grid").
    WithDimensions(10, 5). // 10 rows, 5 columns
    WithColors([]color.Color{color.White, color.RGBA{255, 0, 0, 255}})

img := builder.Generate()
builder.Save("my_grid.bmp")

License

This project is licensed under the BSD 3-Clause License - see the LICENSE file for details.

About

golang based dithering experiments

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages