From a7b47475c04f70a6d6d0026819ff3c2cfab0b60e Mon Sep 17 00:00:00 2001 From: faiface Date: Fri, 3 May 2019 23:55:33 +0200 Subject: add some documentation --- env.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'env.go') diff --git a/env.go b/env.go index c1800d6..85765e4 100644 --- a/env.go +++ b/env.go @@ -5,6 +5,26 @@ import ( "image/draw" ) +// Env is the most important thing in this package. It is an interactive graphical +// environment, such as a window. +// +// It has two channels: Events() and Draw(). +// +// The Events() channel produces events, like mouse and keyboard presses, while the +// Draw() channel receives drawing functions. A drawing function draws onto the +// supplied draw.Image, which is the drawing area of the Env and returns a rectangle +// covering the whole part of the image that got changed. +// +// The Events() channel must be unlimited in capacity. Use MakeEventsChan() to create +// a channel of events with an unlimited capacity. +// +// The Draw() channel may be synchronous. +// +// Drawing functions sent to the Draw() channel are not guaranteed to be executed. +// +// Closing the Draw() channel results in closing the Env. The Env will subsequently +// close the Events() channel. On the other hand, when the Events() channel gets closed +// the user of the Env should subsequently close the Draw() channel. type Env interface { Events() <-chan Event Draw() chan<- func(draw.Image) image.Rectangle -- cgit v1.2.3