doodlekit

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2024 License: BSD-2-Clause Imports: 6 Imported by: 11

README

doodlekit

Go Report Card Coverage

Welcome to doodlekit, an open-source Golang framework for creating animated doodles like old school demoscenes and crack intros.

Whether you're a nostalgic coder or a modern enthusiast, doodlekit allows you to craft captivating GIF animations with ease.

Check out the lucasepe/doodles repository for examples of stunning animations created with doodlekit!

Features

  • Simple API: easy-to-use functions to create stunning animations
  • Composable Scenes: you can compose one or more existing scenes with yours
  • Flexible Configuration: options to set frame rate, output directory, and more.
  • Open Source: contribute and expand the framework with your own scenes and animations.
  • GIF Output: generates GIFs for sharing and showcasing

Getting Started

Usage

Here's a basic example to get you started with doodlekit:

package main

import (
    "context"
    "github.com/lucasepe/doodlekit"
)

type MyScene struct{}

func (s *MyScene) Init(ctx context.Context) {
    // Initialize your scene
    // gc := doodlekit.Canvas(Ctx)
}

func (s *MyScene) Update(ctx context.Context, dt float64) {
    // Update scene logic
    // gc := doodlekit.Canvas(Ctx)
}

func (s *MyScene) Draw(ctx context.Context) {
    // Draw your scene
    // gc := doodlekit.Canvas(Ctx)
    // Use `gc` to draw your stuff
}

func main() {
    scenes := []doodlekit.Scene{
        // here you can add eventually 
        // one or more existing scenes
        &MyScene{},
    }

    loop := doodlekit.NewLoop("my-doodle", 
        doodlekit.FPS(24), 
        doodlekit.StopAfter(15))
    loop.Run(scenes)
}
Creating a Scene

To create your own scene, implement the doodlekit.Scene interface:

type Scene interface {
    Init(ctx context.Context)
    Update(ctx context.Context, dt float64)
    Draw(ctx context.Context)
}
  • Init: initialize your scene, load resources, etc.
  • Update: update the scene logic, animations, positions, etc.
  • Draw: render your scene, draw shapes, etc.

Acknowledgements

Special thanks to

License

This project is licensed under the BSD 2-Clause License. See the LICENSE file for details.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Canvas

func Canvas(ctx context.Context) *canvas.Canvas

Canvas return the drawing context pointer from the context.

func Rng

func Rng(ctx context.Context) rng.RNG

Rng return the pseudo random numbers generator from the context.

Types

type Loop

type Loop interface {
	Run(fx []Scene)
}

func NewLoop

func NewLoop(id string, opts ...Option) Loop

type Option

type Option func(l *demoLoop)

func FPS

func FPS(fps float64) Option

func OutDir

func OutDir(dir string) Option

func Resize added in v0.2.0

func Resize(sf int) Option

func StopAfter

func StopAfter(secs int) Option

type Scene

type Scene interface {
	Init(ctx context.Context)
	Update(ctx context.Context, dt float64)
	Draw(ctx context.Context)
}

Directories

Path Synopsis
internal
rng

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL