mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +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"
|
"github.com/jfreymuth/go-vorbis/ogg/vorbis"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Stream is a decoded audio stream.
|
||||||
type Stream struct {
|
type Stream struct {
|
||||||
buf *bytes.Reader
|
buf *bytes.Reader
|
||||||
}
|
}
|
||||||
@ -60,14 +61,17 @@ func newStream(v *vorbis.Vorbis) (*Stream, error) {
|
|||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read is implementation of io.Reader's Read.
|
||||||
func (s *Stream) Read(p []byte) (int, error) {
|
func (s *Stream) Read(p []byte) (int, error) {
|
||||||
return s.buf.Read(p)
|
return s.buf.Read(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seek is implementation of io.Seeker's Seek.
|
||||||
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
||||||
return s.buf.Seek(offset, whence)
|
return s.buf.Seek(offset, whence)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read is implementation of io.Closer's Close.
|
||||||
func (s *Stream) Close() error {
|
func (s *Stream) Close() error {
|
||||||
s.buf = nil
|
s.buf = nil
|
||||||
return nil
|
return nil
|
||||||
|
@ -23,16 +23,19 @@ import (
|
|||||||
"github.com/hajimehoshi/ebiten/audio"
|
"github.com/hajimehoshi/ebiten/audio"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Stream is a decoded audio stream.
|
||||||
type Stream struct {
|
type Stream struct {
|
||||||
src audio.ReadSeekCloser
|
src audio.ReadSeekCloser
|
||||||
headerSize int64
|
headerSize int64
|
||||||
dataSize int64
|
dataSize int64
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read is implementation of io.Reader's Read.
|
||||||
func (s *Stream) Read(p []byte) (int, error) {
|
func (s *Stream) Read(p []byte) (int, error) {
|
||||||
return s.src.Read(p)
|
return s.src.Read(p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Seek is implementation of io.Seeker's Seek.
|
||||||
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
||||||
if whence == 0 {
|
if whence == 0 {
|
||||||
offset += s.headerSize
|
offset += s.headerSize
|
||||||
@ -40,6 +43,7 @@ func (s *Stream) Seek(offset int64, whence int) (int64, error) {
|
|||||||
return s.src.Seek(offset, whence)
|
return s.src.Seek(offset, whence)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Read is implementation of io.Closer's Close.
|
||||||
func (s *Stream) Close() error {
|
func (s *Stream) Close() error {
|
||||||
return s.src.Close()
|
return s.src.Close()
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,9 @@ type debugPrintState struct {
|
|||||||
|
|
||||||
var defaultDebugPrintState = &debugPrintState{}
|
var defaultDebugPrintState = &debugPrintState{}
|
||||||
|
|
||||||
func DebugPrint(r *ebiten.Image, str string) error {
|
// DebugPrint draws the string str on the image.
|
||||||
return defaultDebugPrintState.DebugPrint(r, str)
|
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) {
|
func (d *debugPrintState) drawText(rt *ebiten.Image, str string, x, y int, c color.Color) {
|
||||||
|
@ -18,6 +18,7 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ReadSeekCloser is io.ReadSeeker and io.Closer.
|
||||||
type ReadSeekCloser interface {
|
type ReadSeekCloser interface {
|
||||||
io.ReadSeeker
|
io.ReadSeeker
|
||||||
io.Closer
|
io.Closer
|
||||||
|
@ -22,8 +22,11 @@ import (
|
|||||||
type Filter int
|
type Filter int
|
||||||
|
|
||||||
const (
|
const (
|
||||||
FilterNearest Filter = iota // nearest (crisp-edged) filter
|
// FilterNearest represents nearest (crisp-edged) filter
|
||||||
FilterLinear // linear filter
|
FilterNearest Filter = iota
|
||||||
|
|
||||||
|
// FilterLinear represents linear filter
|
||||||
|
FilterLinear
|
||||||
)
|
)
|
||||||
|
|
||||||
func glFilter(filter Filter) opengl.Filter {
|
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))
|
return ui.CurrentInput().IsGamepadButtonPressed(id, ui.GamepadButton(button))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Touch represents a pointer state.
|
||||||
type Touch interface {
|
type Touch interface {
|
||||||
ID() int
|
ID() int
|
||||||
Position() (x, y int)
|
Position() (x, y int)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Touches returns the current touch states.
|
||||||
func Touches() []Touch {
|
func Touches() []Touch {
|
||||||
t := ui.CurrentInput().Touches()
|
t := ui.CurrentInput().Touches()
|
||||||
tt := make([]Touch, len(t))
|
tt := make([]Touch, len(t))
|
||||||
|
Loading…
Reference in New Issue
Block a user