graphics: Add comments to At

This commit is contained in:
Hajime Hoshi 2018-05-01 18:07:52 +09:00
parent b60d549924
commit 4d3d407205
2 changed files with 7 additions and 0 deletions

View File

@ -46,6 +46,10 @@ type Sprite struct {
func (s *Sprite) In(x, y int) bool { func (s *Sprite) In(x, y int) bool {
// Check the actual color (alpha) value at the specified position // Check the actual color (alpha) value at the specified position
// so that the result of In becomes natural to users. // so that the result of In becomes natural to users.
//
// Note that this is not a good manner to use At for logic
// since color from At might include some errors on some machines.
// As this is not so important logic, it's ok to use it so far.
return s.image.At(x-s.x, y-s.y).(color.RGBA).A > 0 return s.image.At(x-s.x, y-s.y).(color.RGBA).A > 0
} }

View File

@ -246,6 +246,9 @@ func (i *Image) ColorModel() color.Model {
// //
// At always returns a transparent color if the image is disposed. // At always returns a transparent color if the image is disposed.
// //
// Note that important logic should not rely on At result since
// At might include a very slight error on some machines.
//
// At can't be called before the main loop (ebiten.Run) starts (as of version 1.4.0-alpha). // At can't be called before the main loop (ebiten.Run) starts (as of version 1.4.0-alpha).
func (i *Image) At(x, y int) color.Color { func (i *Image) At(x, y int) color.Color {
if i.isDisposed() { if i.isDisposed() {