_id
stringlengths
2
7
title
stringlengths
1
118
partition
stringclasses
3 values
text
stringlengths
52
85.5k
language
stringclasses
1 value
meta_information
dict
q169700
IsTouchJustReleased
validation
func IsTouchJustReleased(id int) bool { theInputState.m.RLock() r := theInputState.touchDurations[id] == 0 && theInputState.prevTouchDurations[id] > 0 theInputState.m.RUnlock() return r }
go
{ "resource": "" }
q169701
TouchPressDuration
validation
func TouchPressDuration(id int) int { theInputState.m.RLock() s := theInputState.touchDurations[id] theInputState.m.RUnlock() return s }
go
{ "resource": "" }
q169702
viewportSize
validation
func (i *Image) viewportSize() (int, int) { if i.screen { return i.width, i.height } return graphics.InternalImageSize(i.width), graphics.InternalImageSize(i.height) }
go
{ "resource": "" }
q169703
Loop
validation
func Loop(ch <-chan error) error { atomic.StoreInt32(&started, 1) for { select { case f := <-funcs: f() case err := <-ch: // ch returns a value not only when an error occur but also it is closed. return err } } }
go
{ "resource": "" }
q169704
Run
validation
func Run(f func() error) error { if atomic.LoadInt32(&started) == 0 { // TODO: This can reach from other goroutine before Loop is called (#809). // panic("mainthread: the mainthread loop is not started yet") } ch := make(chan struct{}) var err error funcs <- func() { err = f() close(ch) } <-ch return e...
go
{ "resource": "" }
q169705
InternalImageSize
validation
func InternalImageSize(x int) int { if x <= 0 { panic("graphics: x must be positive") } if x < minInternalImageSize { return minInternalImageSize } r := 1 for r < x { r <<= 1 } return r }
go
{ "resource": "" }
q169706
square
validation
func square(out []int16, volume float64, freq float64, sequence float64) { if freq == 0 { for i := 0; i < len(out); i++ { out[i] = 0 } return } length := int(float64(sampleRate) / freq) if length == 0 { panic("invalid freq") } for i := 0; i < len(out); i++ { a := int16(volume * math.MaxInt16) if i%...
go
{ "resource": "" }
q169707
playNote
validation
func playNote(scoreIndex int) rune { note := score[scoreIndex] // If the note is 'rest', play nothing. if note == 'R' { return rune(note) } freqs := []float64{freqC, freqD, freqE, freqF, freqG, freqA * 2, freqB * 2} freq := 0.0 switch { case 'A' <= note && note <= 'B': freq = freqs[int(note)+len(freqs)-in...
go
{ "resource": "" }
q169708
pianoAt
validation
func pianoAt(i int, freq float64) float64 { // Create piano-like waves with multiple sin waves. amp := []float64{1.0, 0.8, 0.6, 0.4, 0.2} x := []float64{4.0, 2.0, 1.0, 0.5, 0.25} v := 0.0 for j := 0; j < len(amp); j++ { // Decay a := amp[j] * math.Exp(-5*float64(i)*freq/baseFreq/(x[j]*sampleRate)) v += a * m...
go
{ "resource": "" }
q169709
playNote
validation
func playNote(freq float64) { f := int(freq) p, _ := audio.NewPlayerFromBytes(audioContext, pianoNoteSamples[f]) p.Play() }
go
{ "resource": "" }
q169710
Draw
validation
func (p *Path) Draw(target *ebiten.Image, op *DrawPathOptions) { if op == nil { return } // TODO: Implement filling if op.StrokeColor != nil { vs, is := p.strokeVertices(op.LineWidth, op.StrokeColor) op := &ebiten.DrawTrianglesOptions{} op.Address = ebiten.AddressRepeat target.DrawTriangles(vs, is, empty...
go
{ "resource": "" }
q169711
String
validation
func (g *GeoM) String() string { return fmt.Sprintf("[[%f, %f, %f], [%f, %f, %f]]", g.a_1+1, g.b, g.tx, g.c, g.d_1+1, g.ty) }
go
{ "resource": "" }
q169712
Reset
validation
func (g *GeoM) Reset() { g.a_1 = 0 g.b = 0 g.c = 0 g.d_1 = 0 g.tx = 0 g.ty = 0 }
go
{ "resource": "" }
q169713
Concat
validation
func (g *GeoM) Concat(other GeoM) { a := (other.a_1+1)*(g.a_1+1) + other.b*g.c b := (other.a_1+1)*g.b + other.b*(g.d_1+1) tx := (other.a_1+1)*g.tx + other.b*g.ty + other.tx c := other.c*(g.a_1+1) + (other.d_1+1)*g.c d := other.c*g.b + (other.d_1+1)*(g.d_1+1) ty := other.c*g.tx + (other.d_1+1)*g.ty + other.ty g....
go
{ "resource": "" }
q169714
Rotate
validation
func (g *GeoM) Rotate(theta float64) { if theta == 0 { return } sin64, cos64 := math.Sincos(theta) sin, cos := float32(sin64), float32(cos64) a := cos*(g.a_1+1) - sin*g.c b := cos*g.b - sin*(g.d_1+1) tx := cos*g.tx - sin*g.ty c := sin*(g.a_1+1) + cos*g.c d := sin*g.b + cos*(g.d_1+1) ty := sin*g.tx + cos*g...
go
{ "resource": "" }
q169715
Invert
validation
func (g *GeoM) Invert() { det := g.det() if det == 0 { panic("ebiten: g is not invertible") } a := (g.d_1 + 1) / det b := -g.b / det c := -g.c / det d := (g.a_1 + 1) / det tx := (-(g.d_1+1)*g.tx + g.b*g.ty) / det ty := (g.c*g.tx + -(g.a_1+1)*g.ty) / det g.a_1 = a - 1 g.b = b g.c = c g.d_1 = d - 1 g.tx...
go
{ "resource": "" }
q169716
ScaleGeo
validation
func ScaleGeo(x, y float64) GeoM { g := GeoM{} g.Scale(x, y) return g }
go
{ "resource": "" }
q169717
TranslateGeo
validation
func TranslateGeo(tx, ty float64) GeoM { g := GeoM{} g.Translate(tx, ty) return g }
go
{ "resource": "" }
q169718
RotateGeo
validation
func RotateGeo(theta float64) GeoM { g := GeoM{} g.Rotate(theta) return g }
go
{ "resource": "" }
q169719
newFramebufferFromTexture
validation
func newFramebufferFromTexture(context *context, texture textureNative, width, height int) (*framebuffer, error) { native, err := context.newFramebuffer(texture) if err != nil { return nil, err } return &framebuffer{ native: native, width: width, height: height, }, nil }
go
{ "resource": "" }
q169720
newScreenFramebuffer
validation
func newScreenFramebuffer(context *context, width, height int) *framebuffer { return &framebuffer{ native: context.getScreenFramebuffer(), width: width, height: height, } }
go
{ "resource": "" }
q169721
opaque
validation
func opaque(m image.Image) bool { if o, ok := m.(opaquer); ok { return o.Opaque() } b := m.Bounds() for y := b.Min.Y; y < b.Max.Y; y++ { for x := b.Min.X; x < b.Max.X; x++ { _, _, _, a := m.At(x, y).RGBA() if a != 0xffff { return false } } } return true }
go
{ "resource": "" }
q169722
writeIDATs
validation
func (e *encoder) writeIDATs() { if e.err != nil { return } if e.bw == nil { e.bw = bufio.NewWriterSize(e, 1<<15) } else { e.bw.Reset(e) } e.err = e.writeImage(e.bw, e.m, e.cb, levelToZlib(e.enc.CompressionLevel)) if e.err != nil { return } e.err = e.bw.Flush() }
go
{ "resource": "" }
q169723
levelToZlib
validation
func levelToZlib(l CompressionLevel) int { switch l { case DefaultCompression: return zlib.DefaultCompression case NoCompression: return zlib.NoCompression case BestSpeed: return zlib.BestSpeed case BestCompression: return zlib.BestCompression default: return zlib.DefaultCompression } }
go
{ "resource": "" }
q169724
Encode
validation
func Encode(w io.Writer, m image.Image) error { var e Encoder return e.Encode(w, m) }
go
{ "resource": "" }
q169725
Encode
validation
func (enc *Encoder) Encode(w io.Writer, m image.Image) error { // Obviously, negative widths and heights are invalid. Furthermore, the PNG // spec section 11.2.2 says that zero is invalid. Excessively large images are // also rejected. mw, mh := int64(m.Bounds().Dx()), int64(m.Bounds().Dy()) if mw <= 0 || mh <= 0 ...
go
{ "resource": "" }
q169726
NewImage
validation
func NewImage(width, height int) *Image { i := &Image{ image: graphicscommand.NewImage(width, height), } i.clear() theImages.add(i) return i }
go
{ "resource": "" }
q169727
NewScreenFramebufferImage
validation
func NewScreenFramebufferImage(width, height int) *Image { i := &Image{ image: graphicscommand.NewScreenFramebufferImage(width, height), screen: true, } i.clear() theImages.add(i) return i }
go
{ "resource": "" }
q169728
internalSize
validation
func (i *Image) internalSize() (int, int) { if i.w2 == 0 || i.h2 == 0 { w, h := i.image.Size() i.w2 = graphics.InternalImageSize(w) i.h2 = graphics.InternalImageSize(h) } return i.w2, i.h2 }
go
{ "resource": "" }
q169729
makeStale
validation
func (i *Image) makeStale() { i.basePixels = nil i.drawTrianglesHistory = nil i.stale = true // Don't have to call makeStale recursively here. // Restoring is done after topological sorting is done. // If an image depends on another stale image, this means that // the former image can be restored from the lates...
go
{ "resource": "" }
q169730
ReplacePixels
validation
func (i *Image) ReplacePixels(pixels []byte, x, y, width, height int) { w, h := i.image.Size() if width <= 0 || height <= 0 { panic("restorable: width/height must be positive") } if x < 0 || y < 0 || w <= x || h <= y || x+width <= 0 || y+height <= 0 || w < x+width || h < y+height { panic(fmt.Sprintf("restorable...
go
{ "resource": "" }
q169731
DrawTriangles
validation
func (i *Image) DrawTriangles(img *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, address graphics.Address) { if i.priority { panic("restorable: DrawTriangles cannot be called on a priority image") } if len(vertices) == 0 { return } theI...
go
{ "resource": "" }
q169732
appendDrawTrianglesHistory
validation
func (i *Image) appendDrawTrianglesHistory(image *Image, vertices []float32, indices []uint16, colorm *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, address graphics.Address) { if i.stale || i.volatile || i.screen { return } // TODO: Would it be possible to merge draw image history items? co...
go
{ "resource": "" }
q169733
makeStaleIfDependingOn
validation
func (i *Image) makeStaleIfDependingOn(target *Image) { if i.stale { return } if i.dependsOn(target) { i.makeStale() } }
go
{ "resource": "" }
q169734
readPixelsFromGPU
validation
func (i *Image) readPixelsFromGPU() { pix := i.image.Pixels() i.basePixels = &Pixels{ pixels: pix, length: len(pix), } i.drawTrianglesHistory = nil i.stale = false }
go
{ "resource": "" }
q169735
resolveStale
validation
func (i *Image) resolveStale() { if !IsRestoringEnabled() { return } if i.volatile { return } if i.screen { return } if !i.stale { return } i.readPixelsFromGPU() }
go
{ "resource": "" }
q169736
dependsOn
validation
func (i *Image) dependsOn(target *Image) bool { for _, c := range i.drawTrianglesHistory { if c.image == target { return true } } return false }
go
{ "resource": "" }
q169737
dependingImages
validation
func (i *Image) dependingImages() map[*Image]struct{} { r := map[*Image]struct{}{} for _, c := range i.drawTrianglesHistory { r[c.image] = struct{}{} } return r }
go
{ "resource": "" }
q169738
hasDependency
validation
func (i *Image) hasDependency() bool { if i.stale { return false } return len(i.drawTrianglesHistory) > 0 }
go
{ "resource": "" }
q169739
Dispose
validation
func (i *Image) Dispose() { theImages.remove(i) i.image.Dispose() i.image = nil i.basePixels = nil i.drawTrianglesHistory = nil i.stale = false }
go
{ "resource": "" }
q169740
IsInvalidated
validation
func (i *Image) IsInvalidated() (bool, error) { // FlushCommands is required because c.offscreen.impl might not have an actual texture. graphicscommand.FlushCommands() if !IsRestoringEnabled() { return false, nil } return i.image.IsInvalidated(), nil }
go
{ "resource": "" }
q169741
NewImage
validation
func NewImage(width, height int) *Image { i := &Image{ width: width, height: height, } c := &newImageCommand{ result: i, width: width, height: height, } theCommandQueue.Enqueue(c) return i }
go
{ "resource": "" }
q169742
Pixels
validation
func (i *Image) Pixels() []byte { c := &pixelsCommand{ result: nil, img: i, } theCommandQueue.Enqueue(c) theCommandQueue.Flush() return c.result }
go
{ "resource": "" }
q169743
CopyPixels
validation
func (i *Image) CopyPixels(src *Image) { if i.lastCommand == lastCommandDrawTriangles { if i.width != src.width || i.height != src.height { panic("graphicscommand: Copy for a part after DrawTriangles is forbidden") } } c := &copyPixelsCommand{ dst: i, src: src, } theCommandQueue.Enqueue(c) // The exe...
go
{ "resource": "" }
q169744
Pos
validation
func (t *Tile) Pos() (int, int) { return t.current.x, t.current.y }
go
{ "resource": "" }
q169745
NextPos
validation
func (t *Tile) NextPos() (int, int) { return t.next.x, t.next.y }
go
{ "resource": "" }
q169746
NewTile
validation
func NewTile(value int, x, y int) *Tile { return &Tile{ current: TileData{ value: value, x: x, y: y, }, startPoppingCount: maxPoppingCount, } }
go
{ "resource": "" }
q169747
MoveTiles
validation
func MoveTiles(tiles map[*Tile]struct{}, size int, dir Dir) bool { vx, vy := dir.Vector() tx := []int{} ty := []int{} for i := 0; i < size; i++ { tx = append(tx, i) ty = append(ty, i) } if vx > 0 { sort.Sort(sort.Reverse(sort.IntSlice(tx))) } if vy > 0 { sort.Sort(sort.Reverse(sort.IntSlice(ty))) } m...
go
{ "resource": "" }
q169748
Update
validation
func (t *Tile) Update() error { switch { case 0 < t.movingCount: t.movingCount-- if t.movingCount == 0 { if t.current.value != t.next.value && 0 < t.next.value { t.poppingCount = maxPoppingCount } t.current = t.next t.next = TileData{} } case 0 < t.startPoppingCount: t.startPoppingCount-- ca...
go
{ "resource": "" }
q169749
String
validation
func (c *ColorM) String() string { b, t := c.impl.UnsafeElements() return fmt.Sprintf("[[%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f], [%f, %f, %f, %f, %f]]", b[0], b[4], b[8], b[12], t[0], b[1], b[5], b[9], b[13], t[1], b[2], b[6], b[10], b[14], t[2], b[3], b[7], b[11], b[15], t[3]) }
go
{ "resource": "" }
q169750
ScaleColor
validation
func ScaleColor(r, g, b, a float64) ColorM { c := ColorM{} c.Scale(r, g, b, a) return c }
go
{ "resource": "" }
q169751
TranslateColor
validation
func TranslateColor(r, g, b, a float64) ColorM { c := ColorM{} c.Translate(r, g, b, a) return c }
go
{ "resource": "" }
q169752
RotateHue
validation
func RotateHue(theta float64) ColorM { c := ColorM{} c.RotateHue(theta) return c }
go
{ "resource": "" }
q169753
availableFilename
validation
func availableFilename(prefix, postfix string) (string, error) { const datetimeFormat = "20060102030405" now := time.Now() name := fmt.Sprintf("%s%s%s", prefix, now.Format(datetimeFormat), postfix) for i := 1; ; i++ { if _, err := os.Stat(name); err != nil { if os.IsNotExist(err) { break } if !os.Is...
go
{ "resource": "" }
q169754
appMain
validation
func (u *UserInterface) appMain(a app.App) { var glctx gl.Context touches := map[touch.Sequence]*Touch{} for e := range a.Events() { switch e := a.Filter(e).(type) { case lifecycle.Event: switch e.Crosses(lifecycle.StageVisible) { case lifecycle.CrossOn: glctx, _ = e.DrawContext.(gl.Context) // Ass...
go
{ "resource": "" }
q169755
repeatingKeyPressed
validation
func repeatingKeyPressed(key ebiten.Key) bool { const ( delay = 30 interval = 3 ) d := inpututil.KeyPressDuration(key) if d == 1 { return true } if d >= delay && (d-delay)%interval == 0 { return true } return false }
go
{ "resource": "" }
q169756
totalBytes
validation
func (a *arrayBufferLayout) totalBytes() int { if a.total != 0 { return a.total } t := 0 for _, p := range a.parts { t += float.SizeInBytes() * p.num } a.total = t return a.total }
go
{ "resource": "" }
q169757
newArrayBuffer
validation
func (a *arrayBufferLayout) newArrayBuffer(context *context) buffer { return context.newArrayBuffer(a.totalBytes() * graphics.IndicesNum) }
go
{ "resource": "" }
q169758
enable
validation
func (a *arrayBufferLayout) enable(context *context, program program) { for i := range a.parts { context.enableVertexAttribArray(program, i) } total := a.totalBytes() offset := 0 for i, p := range a.parts { context.vertexAttribPointer(program, i, p.num, float, total, offset) offset += float.SizeInBytes() * p...
go
{ "resource": "" }
q169759
disable
validation
func (a *arrayBufferLayout) disable(context *context, program program) { // TODO: Disabling should be done in reversed order? for i := range a.parts { context.disableVertexAttribArray(program, i) } }
go
{ "resource": "" }
q169760
reset
validation
func (s *openGLState) reset(context *context) error { if err := context.reset(); err != nil { return err } s.lastProgram = zeroProgram s.lastViewportWidth = 0 s.lastViewportHeight = 0 s.lastColorMatrix = nil s.lastColorMatrixTranslation = nil s.lastSourceWidth = 0 s.lastSourceHeight = 0 s.lastFilter = nil ...
go
{ "resource": "" }
q169761
areSameFloat32Array
validation
func areSameFloat32Array(a, b []float32) bool { if len(a) != len(b) { return false } for i := 0; i < len(a); i++ { if a[i] != b[i] { return false } } return true }
go
{ "resource": "" }
q169762
NewInfiniteLoopWithIntro
validation
func NewInfiniteLoopWithIntro(src ReadSeekCloser, introLength int64, loopLength int64) *InfiniteLoop { return &InfiniteLoop{ src: src, lstart: introLength, llength: loopLength, pos: -1, } }
go
{ "resource": "" }
q169763
Read
validation
func (i *InfiniteLoop) Read(b []byte) (int, error) { if err := i.ensurePos(); err != nil { return 0, err } if i.pos+int64(len(b)) > i.length() { b = b[:i.length()-i.pos] } n, err := i.src.Read(b) i.pos += int64(n) if i.pos > i.length() { panic(fmt.Sprintf("audio: position must be <= length but not at (*I...
go
{ "resource": "" }
q169764
Seek
validation
func (i *InfiniteLoop) Seek(offset int64, whence int) (int64, error) { if err := i.ensurePos(); err != nil { return 0, err } next := int64(0) switch whence { case io.SeekStart: next = offset case io.SeekCurrent: next = i.pos + offset case io.SeekEnd: return 0, fmt.Errorf("audio: whence must be io.SeekSt...
go
{ "resource": "" }
q169765
remove
validation
func (i *images) remove(img *Image) { i.makeStaleIfDependingOnImpl(img) delete(i.images, img) }
go
{ "resource": "" }
q169766
resolveStaleImages
validation
func (i *images) resolveStaleImages() { i.lastTarget = nil for img := range i.images { img.resolveStale() } }
go
{ "resource": "" }
q169767
MoveForward
validation
func (p *player) MoveForward() { w, h := gophersImage.Size() mx := w * 16 my := h * 16 s, c := math.Sincos(float64(p.angle) * 2 * math.Pi / maxAngle) p.x16 += int(round(16*c) * 2) p.y16 += int(round(16*s) * 2) for mx <= p.x16 { p.x16 -= mx } for my <= p.y16 { p.y16 -= my } for p.x16 < 0 { p.x16 += mx ...
go
{ "resource": "" }
q169768
RotateRight
validation
func (p *player) RotateRight() { p.angle++ if maxAngle <= p.angle { p.angle -= maxAngle } p.lean++ if maxLean < p.lean { p.lean = maxLean } }
go
{ "resource": "" }
q169769
RotateLeft
validation
func (p *player) RotateLeft() { p.angle-- if p.angle < 0 { p.angle += maxAngle } p.lean-- if p.lean < -maxLean { p.lean = -maxLean } }
go
{ "resource": "" }
q169770
updateGroundImage
validation
func updateGroundImage(ground *ebiten.Image) { ground.Clear() x16, y16 := thePlayer.Position() a := thePlayer.Angle() gw, gh := ground.Size() w, h := gophersImage.Size() op := &ebiten.DrawImageOptions{} op.GeoM.Translate(float64(-x16)/16, float64(-y16)/16) op.GeoM.Translate(float64(-w*2), float64(-h*2)) op.Ge...
go
{ "resource": "" }
q169771
drawGroundImage
validation
func drawGroundImage(screen *ebiten.Image, ground *ebiten.Image) { perspectiveGroundImage.Clear() gw, _ := ground.Size() pw, ph := perspectiveGroundImage.Size() for j := 0; j < ph; j++ { // z is in [2, -1] rate := float64(j) / float64(ph) z := (1-rate)*2 + rate*-1 if z <= 0 { break } op := &ebiten.Dr...
go
{ "resource": "" }
q169772
String
validation
func (d Dir) String() string { switch d { case DirUp: return "Up" case DirRight: return "Right" case DirDown: return "Down" case DirLeft: return "Left" } panic("not reach") }
go
{ "resource": "" }
q169773
Update
validation
func (i *Input) Update() { switch i.mouseState { case mouseStateNone: if ebiten.IsMouseButtonPressed(ebiten.MouseButtonLeft) { x, y := ebiten.CursorPosition() i.mouseInitPosX = x i.mouseInitPosY = y i.mouseState = mouseStatePressing } case mouseStatePressing: if !ebiten.IsMouseButtonPressed(ebiten....
go
{ "resource": "" }
q169774
Dir
validation
func (i *Input) Dir() (Dir, bool) { if inpututil.IsKeyJustPressed(ebiten.KeyUp) { return DirUp, true } if inpututil.IsKeyJustPressed(ebiten.KeyLeft) { return DirLeft, true } if inpututil.IsKeyJustPressed(ebiten.KeyRight) { return DirRight, true } if inpututil.IsKeyJustPressed(ebiten.KeyDown) { return Dir...
go
{ "resource": "" }
q169775
Read
validation
func (s *stream) Read(buf []byte) (int, error) { if len(s.remaining) > 0 { n := copy(buf, s.remaining) s.remaining = s.remaining[n:] return n, nil } var origBuf []byte if len(buf)%4 > 0 { origBuf = buf buf = make([]byte, len(origBuf)+4-len(origBuf)%4) } const length = int64(sampleRate / frequency) p ...
go
{ "resource": "" }
q169776
Size
validation
func (i *Image) Size() (width, height int) { s := i.Bounds().Size() return s.X, s.Y }
go
{ "resource": "" }
q169777
Fill
validation
func (i *Image) Fill(clr color.Color) error { i.copyCheck() if i.isDisposed() { return nil } // TODO: Implement this. if i.isSubImage() { panic("ebiten: render to a subimage is not implemented (Fill)") } i.resolvePendingPixels(false) r16, g16, b16, a16 := clr.RGBA() r, g, b, a := uint8(r16>>8), uint8(g1...
go
{ "resource": "" }
q169778
Bounds
validation
func (i *Image) Bounds() image.Rectangle { if !i.isSubImage() { w, h := i.mipmap.original().Size() return image.Rect(0, 0, w, h) } return i.bounds }
go
{ "resource": "" }
q169779
Dispose
validation
func (i *Image) Dispose() error { i.copyCheck() if i.isDisposed() { return nil } if i.isSubImage() { return nil } i.mipmap.dispose() i.resolvePendingPixels(false) return nil }
go
{ "resource": "" }
q169780
NewImage
validation
func NewImage(width, height int, filter Filter) (*Image, error) { s := shareable.NewImage(width, height) i := &Image{ mipmap: newMipmap(s), filter: filter, } i.addr = i return i, nil }
go
{ "resource": "" }
q169781
makeVolatile
validation
func (i *Image) makeVolatile() { if i.isDisposed() { return } i.mipmap.orig.MakeVolatile() i.disposeMipmaps() }
go
{ "resource": "" }
q169782
isFullscreen
validation
func (u *UserInterface) isFullscreen() bool { if !u.isRunning() { panic("ui: the game must be running at isFullscreen") } return u.window.GetMonitor() != nil }
go
{ "resource": "" }
q169783
glfwSize
validation
func (u *UserInterface) glfwSize() (int, int) { w := int(float64(u.windowWidth) * u.getScale() * u.glfwScale()) h := int(float64(u.height) * u.getScale() * u.glfwScale()) return w, h }
go
{ "resource": "" }
q169784
getScale
validation
func (u *UserInterface) getScale() float64 { if !u.isFullscreen() { return u.scale } if u.fullscreenScale == 0 { v := u.window.GetMonitor().GetVideoMode() sw := float64(v.Width) / u.glfwScale() / float64(u.width) sh := float64(v.Height) / u.glfwScale() / float64(u.height) s := sw if s > sh { s = sh ...
go
{ "resource": "" }
q169785
actualScreenScale
validation
func (u *UserInterface) actualScreenScale() float64 { // Avoid calling monitor.GetPos if we have the monitor position cached already. if cm, ok := getCachedMonitor(u.window.GetPos()); ok { return u.getScale() * devicescale.GetAt(cm.x, cm.y) } return u.getScale() * devicescale.GetAt(u.currentMonitor().GetPos()) }
go
{ "resource": "" }
q169786
setScreenSize
validation
func (u *UserInterface) setScreenSize(width, height int, scale float64, fullscreen bool, vsync bool) bool { if u.width == width && u.height == height && u.scale == scale && u.isFullscreen() == fullscreen && u.vsync == vsync { return false } u.forceSetScreenSize(width, height, scale, fullscreen, vsync) return true...
go
{ "resource": "" }
q169787
currentMonitor
validation
func (u *UserInterface) currentMonitor() *glfw.Monitor { w := u.window if m := w.GetMonitor(); m != nil { return m } // Get the monitor which the current window belongs to. This requires OS API. return u.currentMonitorFromPosition() }
go
{ "resource": "" }
q169788
CopyImage
validation
func CopyImage(img image.Image) []byte { size := img.Bounds().Size() w, h := size.X, size.Y bs := make([]byte, 4*w*h) switch img := img.(type) { case *image.Paletted: b := img.Bounds() x0 := b.Min.X y0 := b.Min.Y x1 := b.Max.X y1 := b.Max.Y palette := make([]uint8, len(img.Palette)*4) for i, c := r...
go
{ "resource": "" }
q169789
appendVertices
validation
func (q *commandQueue) appendVertices(vertices []float32) { if len(q.vertices) < q.nvertices+len(vertices) { n := q.nvertices + len(vertices) - len(q.vertices) q.vertices = append(q.vertices, make([]float32, n)...) } copy(q.vertices[q.nvertices:], vertices) q.nvertices += len(vertices) }
go
{ "resource": "" }
q169790
EnqueueDrawTrianglesCommand
validation
func (q *commandQueue) EnqueueDrawTrianglesCommand(dst, src *Image, vertices []float32, indices []uint16, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, address graphics.Address) { if len(indices) > graphics.IndicesNum { panic(fmt.Sprintf("graphicscommand: len(indices) must be <= graphics...
go
{ "resource": "" }
q169791
Enqueue
validation
func (q *commandQueue) Enqueue(command command) { // TODO: If dst is the screen, reorder the command to be the last. q.commands = append(q.commands, command) }
go
{ "resource": "" }
q169792
Flush
validation
func (q *commandQueue) Flush() { if q.err != nil { return } es := q.indices vs := q.vertices if recordLog() { fmt.Println("--") } theGraphicsDriver.Begin() for len(q.commands) > 0 { nv := 0 ne := 0 nc := 0 for _, c := range q.commands { if c.NumIndices() > graphics.IndicesNum { panic(fmt.Sp...
go
{ "resource": "" }
q169793
Exec
validation
func (c *drawTrianglesCommand) Exec(indexOffset int) error { // TODO: Is it ok not to bind any framebuffer here? if c.nindices == 0 { return nil } c.dst.image.SetAsDestination() c.src.image.SetAsSource() if err := theGraphicsDriver.Draw(c.nindices, indexOffset, c.mode, c.color, c.filter, c.address); err != nil...
go
{ "resource": "" }
q169794
CanMerge
validation
func (c *drawTrianglesCommand) CanMerge(dst, src *Image, color *affine.ColorM, mode graphics.CompositeMode, filter graphics.Filter, address graphics.Address) bool { if c.dst != dst { return false } if c.src != src { return false } if !c.color.Equals(color) { return false } if c.mode != mode { return fals...
go
{ "resource": "" }
q169795
Exec
validation
func (c *replacePixelsCommand) Exec(indexOffset int) error { c.dst.image.ReplacePixels(c.pixels, c.x, c.y, c.width, c.height) return nil }
go
{ "resource": "" }
q169796
Exec
validation
func (c *pixelsCommand) Exec(indexOffset int) error { p, err := c.img.image.Pixels() if err != nil { return err } c.result = p return nil }
go
{ "resource": "" }
q169797
Exec
validation
func (c *disposeCommand) Exec(indexOffset int) error { c.target.image.Dispose() return nil }
go
{ "resource": "" }
q169798
Exec
validation
func (c *newImageCommand) Exec(indexOffset int) error { i, err := theGraphicsDriver.NewImage(c.width, c.height) if err != nil { return err } c.result.image = i return nil }
go
{ "resource": "" }
q169799
Exec
validation
func (c *newScreenFramebufferImageCommand) Exec(indexOffset int) error { var err error c.result.image, err = theGraphicsDriver.NewScreenFramebufferImage(c.width, c.height) return err }
go
{ "resource": "" }