Skip to content
Proyek

Tentang

A lightweight, Processing-like 2D animation and creative coding library for Go

Desain dan media

Cara angka ini diukur

Yang dapat Anda lakukan

  • Simple & Intuitive: Start animating with familiar Setup and Draw callbacks—no window or loop boilerplate.
  • Rich 2D Vector Drawing: Full 2D vector graphics (shapes, paths, text, images, colors, and transformations) powered by gg.
  • Interactive: Built-in mouse and keyboard handling for interactive sketches, simulations, and creative coding.
  • Easy Recording & Export: Built-in automated animated GIF recording (RecordGIF) and sequential PNG frame capture (SaveFrameSeq).

Pertumbuhan bintang terukur

dalam 24 jam
0
dalam 7 hari
0
dalam 15 hari
0
dalam 1 bulan
Mengumpulkan riwayat

Perubahan bersih pada periode yang tumpang tindih, bukan total harian. Pengukuran yang belum tersedia dibiarkan kosong. Bintang menunjukkan perhatian, bukan kualitas.

README.md

Asli

Canvas

CI Go Reference

canvas is a lightweight, Processing-like 2D animation and creative coding library for Go.

It combines the power and simplicity of fogleman/gg (2D vector drawing) with gopxl/pixel for window management and real-time graphics rendering.

Features

  • Simple & Intuitive: Start animating with familiar Setup and Draw callbacks—no window or loop boilerplate.
  • Rich 2D Vector Drawing: Full 2D vector graphics (shapes, paths, text, images, colors, and transformations) powered by gg.
  • Interactive: Built-in mouse and keyboard handling for interactive sketches, simulations, and creative coding.
  • Easy Recording & Export: Built-in automated animated GIF recording (RecordGIF) and sequential PNG frame capture (SaveFrameSeq).

Installation

go get github.com/h8gi/canvas

Quick Start

package main

import (
	"github.com/h8gi/canvas"
	"golang.org/x/image/colornames"
)

func main() {
	c := canvas.NewCanvas(&canvas.CanvasConfig{
		Width:     640,
		Height:    400,
		FrameRate: 60,
		Title:     "Hello Canvas!",
	})

	c.Setup(func(ctx *canvas.Context) {
		ctx.Background(colornames.White)
		ctx.SetColor(colornames.Green)
		ctx.SetLineWidth(5)
	})

	c.Draw(func(ctx *canvas.Context) {
		ctx.Push()
		if ctx.IsMouseDragged {
			ctx.SetColor(colornames.Red)
		}
		ctx.DrawLine(ctx.Mouse.X, ctx.Mouse.Y, ctx.PMouse.X, ctx.PMouse.Y)
		ctx.Stroke()
		ctx.Pop()

		if ctx.IsKeyPressed(canvas.KeyUp) {
			ctx.Background(colornames.White)
		}
	})
}

Showcase

Perlin Flow Field Boids Flocking Particle Fountain
Flow Field Boids Particles
Fractal Tree Noise Landscape Generative Grid
Fractal Tree Noise Landscape Static Art

Explore all complete, runnable programs in the examples directory.

Built With

  • gg - 2D graphics library
  • pixel - 2D OpenGL game engine

License

MIT License © 2019-2026 Hiroki Yagi (h8gi)

Jelajahi proyek terkait

Memuat…