Add comments

This commit is contained in:
Hajime Hoshi 2016-08-02 01:47:25 +09:00
parent 4c611ed4d0
commit dd9918d64e
6 changed files with 19 additions and 4 deletions

View File

@ -27,6 +27,7 @@ import (
"github.com/jfreymuth/go-vorbis/ogg/vorbis"
)
// Stream is a decoded audio stream.
type Stream struct {
buf *bytes.Reader
}
@ -60,14 +61,17 @@ func newStream(v *vorbis.Vorbis) (*Stream, error) {
return s, nil
}
// Read is implementation of io.Reader's Read.
func (s *Stream) Read(p []byte) (int, error) {
return s.buf.Read(p)
}
// Seek is implementation of io.Seeker's Seek.
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
return s.buf.Seek(offset, whence)
}
// Read is implementation of io.Closer's Close.
func (s *Stream) Close() error {
s.buf = nil
return nil

View File

@ -23,16 +23,19 @@ import (
"github.com/hajimehoshi/ebiten/audio"
)
// Stream is a decoded audio stream.
type Stream struct {
src audio.ReadSeekCloser
headerSize int64
dataSize int64
}
// Read is implementation of io.Reader's Read.
func (s *Stream) Read(p []byte) (int, error) {
return s.src.Read(p)
}
// Seek is implementation of io.Seeker's Seek.
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
if whence == 0 {
offset += s.headerSize
@ -40,6 +43,7 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
return s.src.Seek(offset, whence)
}
// Read is implementation of io.Closer's Close.
func (s *Stream) Close() error {
return s.src.Close()
}

View File

@ -59,8 +59,9 @@ type debugPrintState struct {
var defaultDebugPrintState = &debugPrintState{}
func DebugPrint(r *ebiten.Image, str string) error {
return defaultDebugPrintState.DebugPrint(r, str)
// DebugPrint draws the string str on the image.
func DebugPrint(image *ebiten.Image, str string) error {
return defaultDebugPrintState.DebugPrint(image, str)
}
func (d *debugPrintState) drawText(rt *ebiten.Image, str string, x, y int, c color.Color) {

View File

@ -18,6 +18,7 @@ import (
"io"
)
// ReadSeekCloser is io.ReadSeeker and io.Closer.
type ReadSeekCloser interface {
io.ReadSeeker
io.Closer

View File

@ -22,8 +22,11 @@ import (
type Filter int
const (
FilterNearest Filter = iota // nearest (crisp-edged) filter
FilterLinear // linear filter
// FilterNearest represents nearest (crisp-edged) filter
FilterNearest Filter = iota
// FilterLinear represents linear filter
FilterLinear
)
func glFilter(filter Filter) opengl.Filter {

View File

@ -82,11 +82,13 @@ func IsGamepadButtonPressed(id int, button GamepadButton) bool {
return ui.CurrentInput().IsGamepadButtonPressed(id, ui.GamepadButton(button))
}
// Touch represents a pointer state.
type Touch interface {
ID() int
Position() (x, y int)
}
// Touches returns the current touch states.
func Touches() []Touch {
t := ui.CurrentInput().Touches()
tt := make([]Touch, len(t))