mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 02:38:53 +01:00
Add comments
This commit is contained in:
parent
4c611ed4d0
commit
dd9918d64e
@ -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
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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) {
|
||||
|
@ -18,6 +18,7 @@ import (
|
||||
"io"
|
||||
)
|
||||
|
||||
// ReadSeekCloser is io.ReadSeeker and io.Closer.
|
||||
type ReadSeekCloser interface {
|
||||
io.ReadSeeker
|
||||
io.Closer
|
||||
|
@ -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 {
|
||||
|
2
input.go
2
input.go
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user