Skip to content

revisitors/gorevisit

Repository files navigation

gorevisit

A Story

Alt text

"I'm going to make cool glitches for revisit.link with golang!"

Alt text

"You're going to need to learn how to write web services first"

Alt text

"But.. I just want to play with pixels and make cool art..."

Alt text

"You need to know about encoding and decoding, and serialization and deserialization..."

Alt text

"But..I just want to glitch pictures of cats and stuff this is too much work..."

Alt text

rambling on and on about http headers and image type detection

Alt text

"computers are the worst..."

Alt text

"He doesn't even know about gorevisit"

Alt text

"Gorevisit let's you just concentrate on hackin dem pixels!"

Alt text

"computers are the BEST!"

Example

package main

import (
	revisit "github.com/revisitors/gorevisit"
	"image/color"
	"image/draw"
	"math/rand"
)

func noise(src draw.Image) {
	orig := src.Bounds()
	numToMod := (orig.Max.X * orig.Max.Y) / 2
	for i := 0; i < numToMod; i++ {
		x := rand.Intn(orig.Max.X)
		y := rand.Intn(orig.Max.Y)
		origColor := src.At(x, y).(color.RGBA)
		origColor.R += 30
		origColor.B += 30
		origColor.G += 30
		src.Set(x, y, origColor)
	}
}

func main() {
	// make a RevisitService instance and pass it our glitcher
	s := revisit.NewRevisitService(noise)

	// run it!
	s.Run(":8080")
}

Some Go Image manipulation libraries for your glitching

Docs

gorevisit

-- import "github.com/revisitors/gorevisit"

Usage

type AudioData

type AudioData struct {
	Data string `json:data"`
}

AudioData holds a reference to the data URI of sound data in a Revisit.link message See: https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs

type ImageData

type ImageData struct {
	Data string `json:"data"`
}

ImageData holds a reference the data URI of image data in a Revisit.link message See: https://developer.mozilla.org/en-US/docs/Web/HTTP/data_URIs

type MetaData

type MetaData struct {
	Audio AudioData `json:"audio"`
}

MetaData wraps the Audio data of a Revisit.link message as per the specification See: http://revisit.link/spec.html

type RevisitImage

type RevisitImage struct {
	Rgbas     []image.RGBA
	Palette   []color.Palette
	Delay     []int
	LoopCount int
	ImgType   string
}

RevisitImage can hold either a PNG, JPEG, or GIF

func NewRevisitImageFromMsg

func NewRevisitImageFromMsg(r *RevisitMsg) (*RevisitImage, error)

NewRevisitImageFromMsg constructs a RevisitImage from the contents of a RevisitMsg

func (*RevisitImage) RevisitMsg

func (ri *RevisitImage) RevisitMsg() (*RevisitMsg, error)

func (*RevisitImage) Transform

func (ri *RevisitImage) Transform(t func(src draw.Image))

type RevisitMsg

type RevisitMsg struct {
	Content ImageData `json:"content"`
	Meta    MetaData  `json:"meta"`
}

RevisitMsg holds a decoded Revisit.link message See: http://revisit.link/spec.html

func NewRevisitMsgFromFiles

func NewRevisitMsgFromFiles(mediaPath ...string) (*RevisitMsg, error)

NewRevisitMsgFromFiles given the path to an image file and optional path to an audio file, creates a JSON encoded Revisit.link message

func NewRevisitMsgFromReaders

func NewRevisitMsgFromReaders(readers ...io.Reader) (*RevisitMsg, error)

NewRevisitMsgFromReaders given an io.Reader containing an image file and optional io.Reader containing a sound file, returns a *RevisitMsg

func (*RevisitMsg) ImageByteReader

func (r *RevisitMsg) ImageByteReader() io.Reader

ImageByteReader returns an io.Reader for the image data in a Revisit message

func (*RevisitMsg) ImageType

func (r *RevisitMsg) ImageType() string

ImageType gets the type of image that is in the message

func (*RevisitMsg) IsValidSize

func (r *RevisitMsg) IsValidSize() bool

IsValidSize makes sure the size of the media in a RevisitMsg matches the spec

type RevisitService

type RevisitService struct {
}

RevisitService holds the necessary context for a Revisit.link service. Currently gorevisit only handles image data.

func NewRevisitService

func NewRevisitService(g func(draw.Image)) *RevisitService

NewRevisitService given an image transformation function, returns a new Revisit.link service. The image transformation service receives a draw.Image interface as an argument. Note that draw.Image also implements image.Image. For details see: * http://golang.org/pkg/image/draw/ * http://golang.org/pkg/image/#Image

func (*RevisitService) Run

func (rs *RevisitService) Run(port string)

Run starts the Revisit.link service

About

microframework for revisit.link services - http://revisit.link/

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages