_id stringlengths 2 7 | title stringlengths 1 118 | partition stringclasses 3
values | text stringlengths 52 85.5k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q30700 | SetFillStyle | train | func (dc *Context) SetFillStyle(pattern Pattern) {
// if pattern is SolidPattern, also change dc.color(for dc.Clear, dc.drawString)
if fillStyle, ok := pattern.(*solidPattern); ok {
dc.color = fillStyle.color
}
dc.fillPattern = pattern
} | go | {
"resource": ""
} |
q30701 | SetRGBA255 | train | func (dc *Context) SetRGBA255(r, g, b, a int) {
dc.color = color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)}
dc.setFillAndStrokeColor(dc.color)
} | go | {
"resource": ""
} |
q30702 | SetRGBA | train | func (dc *Context) SetRGBA(r, g, b, a float64) {
dc.color = color.NRGBA{
uint8(r * 255),
uint8(g * 255),
uint8(b * 255),
uint8(a * 255),
}
dc.setFillAndStrokeColor(dc.color)
} | go | {
"resource": ""
} |
q30703 | MoveTo | train | func (dc *Context) MoveTo(x, y float64) {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
x, y = dc.TransformPoint(x, y)
p := Point{x, y}
dc.strokePath.Start(p.Fixed())
dc.fillPath.Start(p.Fixed())
dc.start = p
dc.current = p
dc.hasCurrent = true
} | go | {
"resource": ""
} |
q30704 | ClosePath | train | func (dc *Context) ClosePath() {
if dc.hasCurrent {
dc.strokePath.Add1(dc.start.Fixed())
dc.fillPath.Add1(dc.start.Fixed())
dc.current = dc.start
}
} | go | {
"resource": ""
} |
q30705 | ClearPath | train | func (dc *Context) ClearPath() {
dc.strokePath.Clear()
dc.fillPath.Clear()
dc.hasCurrent = false
} | go | {
"resource": ""
} |
q30706 | NewSubPath | train | func (dc *Context) NewSubPath() {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
dc.hasCurrent = false
} | go | {
"resource": ""
} |
q30707 | StrokePreserve | train | func (dc *Context) StrokePreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.strokePattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter... | go | {
"resource": ""
} |
q30708 | FillPreserve | train | func (dc *Context) FillPreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.fillPattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter(dc.... | go | {
"resource": ""
} |
q30709 | InvertMask | train | func (dc *Context) InvertMask() {
if dc.mask == nil {
dc.mask = image.NewAlpha(dc.im.Bounds())
} else {
for i, a := range dc.mask.Pix {
dc.mask.Pix[i] = 255 - a
}
}
} | go | {
"resource": ""
} |
q30710 | Clear | train | func (dc *Context) Clear() {
src := image.NewUniform(dc.color)
draw.Draw(dc.im, dc.im.Bounds(), src, image.ZP, draw.Src)
} | go | {
"resource": ""
} |
q30711 | SetPixel | train | func (dc *Context) SetPixel(x, y int) {
dc.im.Set(x, y, dc.color)
} | go | {
"resource": ""
} |
q30712 | DrawPoint | train | func (dc *Context) DrawPoint(x, y, r float64) {
dc.Push()
tx, ty := dc.TransformPoint(x, y)
dc.Identity()
dc.DrawCircle(tx, ty, r)
dc.Pop()
} | go | {
"resource": ""
} |
q30713 | DrawImage | train | func (dc *Context) DrawImage(im image.Image, x, y int) {
dc.DrawImageAnchored(im, x, y, 0, 0)
} | go | {
"resource": ""
} |
q30714 | DrawString | train | func (dc *Context) DrawString(s string, x, y float64) {
dc.DrawStringAnchored(s, x, y, 0, 0)
} | go | {
"resource": ""
} |
q30715 | DrawStringWrapped | train | func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) {
lines := dc.WordWrap(s, width)
// sync h formula with MeasureMultilineString
h := float64(len(lines)) * dc.fontHeight * lineSpacing
h -= (lineSpacing - 1) * dc.fontHeight
x -= ax * width
y -= ay * h
switch a... | go | {
"resource": ""
} |
q30716 | MeasureString | train | func (dc *Context) MeasureString(s string) (w, h float64) {
d := &font.Drawer{
Face: dc.fontFace,
}
a := d.MeasureString(s)
return float64(a >> 6), dc.fontHeight
} | go | {
"resource": ""
} |
q30717 | WordWrap | train | func (dc *Context) WordWrap(s string, w float64) []string {
return wordWrap(dc, s, w)
} | go | {
"resource": ""
} |
q30718 | Translate | train | func (dc *Context) Translate(x, y float64) {
dc.matrix = dc.matrix.Translate(x, y)
} | go | {
"resource": ""
} |
q30719 | Scale | train | func (dc *Context) Scale(x, y float64) {
dc.matrix = dc.matrix.Scale(x, y)
} | go | {
"resource": ""
} |
q30720 | ScaleAbout | train | func (dc *Context) ScaleAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Scale(sx, sy)
dc.Translate(-x, -y)
} | go | {
"resource": ""
} |
q30721 | Rotate | train | func (dc *Context) Rotate(angle float64) {
dc.matrix = dc.matrix.Rotate(angle)
} | go | {
"resource": ""
} |
q30722 | RotateAbout | train | func (dc *Context) RotateAbout(angle, x, y float64) {
dc.Translate(x, y)
dc.Rotate(angle)
dc.Translate(-x, -y)
} | go | {
"resource": ""
} |
q30723 | Shear | train | func (dc *Context) Shear(x, y float64) {
dc.matrix = dc.matrix.Shear(x, y)
} | go | {
"resource": ""
} |
q30724 | ShearAbout | train | func (dc *Context) ShearAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Shear(sx, sy)
dc.Translate(-x, -y)
} | go | {
"resource": ""
} |
q30725 | TransformPoint | train | func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
return dc.matrix.TransformPoint(x, y)
} | go | {
"resource": ""
} |
q30726 | InvertY | train | func (dc *Context) InvertY() {
dc.Translate(0, float64(dc.height))
dc.Scale(1, -1)
} | go | {
"resource": ""
} |
q30727 | Push | train | func (dc *Context) Push() {
x := *dc
dc.stack = append(dc.stack, &x)
} | go | {
"resource": ""
} |
q30728 | Pop | train | func (dc *Context) Pop() {
before := *dc
s := dc.stack
x, s := s[len(s)-1], s[:len(s)-1]
*dc = *x
dc.mask = before.mask
dc.strokePath = before.strokePath
dc.fillPath = before.fillPath
dc.start = before.start
dc.current = before.current
dc.hasCurrent = before.hasCurrent
} | go | {
"resource": ""
} |
q30729 | New | train | func New(pic pixel.Picture) *IMDraw {
tri := &pixel.TrianglesData{}
im := &IMDraw{
tri: tri,
batch: pixel.NewBatch(tri, pic),
}
im.SetMatrix(pixel.IM)
im.SetColorMask(pixel.Alpha(1))
im.Reset()
return im
} | go | {
"resource": ""
} |
q30730 | Reset | train | func (imd *IMDraw) Reset() {
imd.points = imd.points[:0]
imd.Color = pixel.Alpha(1)
imd.Picture = pixel.ZV
imd.Intensity = 0
imd.Precision = 64
imd.EndShape = NoEndShape
} | go | {
"resource": ""
} |
q30731 | Draw | train | func (imd *IMDraw) Draw(t pixel.Target) {
imd.batch.Draw(t)
} | go | {
"resource": ""
} |
q30732 | Push | train | func (imd *IMDraw) Push(pts ...pixel.Vec) {
if _, ok := imd.Color.(pixel.RGBA); !ok {
imd.Color = pixel.ToRGBA(imd.Color)
}
opts := point{
col: imd.Color.(pixel.RGBA),
pic: imd.Picture,
in: imd.Intensity,
precision: imd.Precision,
endshape: imd.EndShape,
}
for _, pt := range pts {
... | go | {
"resource": ""
} |
q30733 | SetMatrix | train | func (imd *IMDraw) SetMatrix(m pixel.Matrix) {
imd.matrix = m
imd.batch.SetMatrix(imd.matrix)
} | go | {
"resource": ""
} |
q30734 | SetColorMask | train | func (imd *IMDraw) SetColorMask(color color.Color) {
imd.mask = pixel.ToRGBA(color)
imd.batch.SetColorMask(imd.mask)
} | go | {
"resource": ""
} |
q30735 | MakeTriangles | train | func (imd *IMDraw) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return imd.batch.MakeTriangles(t)
} | go | {
"resource": ""
} |
q30736 | MakePicture | train | func (imd *IMDraw) MakePicture(p pixel.Picture) pixel.TargetPicture {
return imd.batch.MakePicture(p)
} | go | {
"resource": ""
} |
q30737 | Rectangle | train | func (imd *IMDraw) Rectangle(thickness float64) {
if thickness == 0 {
imd.fillRectangle()
} else {
imd.outlineRectangle(thickness)
}
} | go | {
"resource": ""
} |
q30738 | Polygon | train | func (imd *IMDraw) Polygon(thickness float64) {
if thickness == 0 {
imd.fillPolygon()
} else {
imd.polyline(thickness, true)
}
} | go | {
"resource": ""
} |
q30739 | Circle | train | func (imd *IMDraw) Circle(radius, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi, thickness, false)
}
} | go | {
"resource": ""
} |
q30740 | Ellipse | train | func (imd *IMDraw) Ellipse(radius pixel.Vec, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(radius, 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(radius, 0, 2*math.Pi, thickness, false)
}
} | go | {
"resource": ""
} |
q30741 | Pressed | train | func (w *Window) Pressed(button Button) bool {
return w.currInp.buttons[button]
} | go | {
"resource": ""
} |
q30742 | JustPressed | train | func (w *Window) JustPressed(button Button) bool {
return w.currInp.buttons[button] && !w.prevInp.buttons[button]
} | go | {
"resource": ""
} |
q30743 | Repeated | train | func (w *Window) Repeated(button Button) bool {
return w.currInp.repeat[button]
} | go | {
"resource": ""
} |
q30744 | SetMousePosition | train | func (w *Window) SetMousePosition(v pixel.Vec) {
mainthread.Call(func() {
if (v.X >= 0 && v.X <= w.bounds.W()) &&
(v.Y >= 0 && v.Y <= w.bounds.H()) {
w.window.SetCursorPos(
v.X+w.bounds.Min.X,
(w.bounds.H()-v.Y)+w.bounds.Min.Y,
)
w.prevInp.mouse = v
w.currInp.mouse = v
w.tempInp.mouse = v
... | go | {
"resource": ""
} |
q30745 | String | train | func (b Button) String() string {
name, ok := buttonNames[b]
if !ok {
return "Invalid"
}
return name
} | go | {
"resource": ""
} |
q30746 | UpdateInput | train | func (w *Window) UpdateInput() {
mainthread.Call(func() {
glfw.PollEvents()
})
w.prevInp = w.currInp
w.currInp = w.tempInp
w.tempInp.repeat = [KeyLast + 1]bool{}
w.tempInp.scroll = pixel.ZV
w.tempInp.typed = ""
w.updateJoystickInput()
} | go | {
"resource": ""
} |
q30747 | update | train | func (gs *glShader) update() {
gs.uf = nil
for _, u := range gs.uniforms {
gs.uf = append(gs.uf, glhf.Attr{
Name: u.Name,
Type: u.Type,
})
}
var shader *glhf.Shader
mainthread.Call(func() {
var err error
shader, err = glhf.NewShader(
gs.vf,
gs.uf,
gs.vs,
gs.fs,
)
if err != nil {
pa... | go | {
"resource": ""
} |
q30748 | getUniform | train | func (gs *glShader) getUniform(Name string) int {
for i, u := range gs.uniforms {
if u.Name == Name {
return i
}
}
return -1
} | go | {
"resource": ""
} |
q30749 | baseShader | train | func baseShader(c *Canvas) {
gs := &glShader{
vf: defaultCanvasVertexFormat,
vs: baseCanvasVertexShader,
fs: baseCanvasFragmentShader,
}
gs.setUniform("uTransform", &gs.uniformDefaults.transform)
gs.setUniform("uColorMask", &gs.uniformDefaults.colormask)
gs.setUniform("uBounds", &gs.uniformDefaults.bounds)
... | go | {
"resource": ""
} |
q30750 | Value | train | func (gu *gsUniformAttr) Value() interface{} {
if !gu.ispointer {
return gu.value
}
switch gu.Type {
case glhf.Vec2:
return *gu.value.(*mgl32.Vec2)
case glhf.Vec3:
return *gu.value.(*mgl32.Vec3)
case glhf.Vec4:
return *gu.value.(*mgl32.Vec4)
case glhf.Mat2:
return *gu.value.(*mgl32.Mat2)
case glhf.Mat... | go | {
"resource": ""
} |
q30751 | Update | train | func (w *Window) Update() {
mainthread.Call(func() {
_, _, oldW, oldH := intBounds(w.bounds)
newW, newH := w.window.GetSize()
w.bounds = w.bounds.ResizedMin(w.bounds.Size().Add(pixel.V(
float64(newW-oldW),
float64(newH-oldH),
)))
})
w.canvas.SetBounds(w.bounds)
mainthread.Call(func() {
w.begin()
... | go | {
"resource": ""
} |
q30752 | SetClosed | train | func (w *Window) SetClosed(closed bool) {
mainthread.Call(func() {
w.window.SetShouldClose(closed)
})
} | go | {
"resource": ""
} |
q30753 | Closed | train | func (w *Window) Closed() bool {
var closed bool
mainthread.Call(func() {
closed = w.window.ShouldClose()
})
return closed
} | go | {
"resource": ""
} |
q30754 | SetTitle | train | func (w *Window) SetTitle(title string) {
mainthread.Call(func() {
w.window.SetTitle(title)
})
} | go | {
"resource": ""
} |
q30755 | SetBounds | train | func (w *Window) SetBounds(bounds pixel.Rect) {
w.bounds = bounds
mainthread.Call(func() {
_, _, width, height := intBounds(bounds)
w.window.SetSize(width, height)
})
} | go | {
"resource": ""
} |
q30756 | SetPos | train | func (w *Window) SetPos(pos pixel.Vec) {
mainthread.Call(func() {
left, top := int(pos.X), int(pos.Y)
w.window.SetPos(left, top)
})
} | go | {
"resource": ""
} |
q30757 | GetPos | train | func (w *Window) GetPos() pixel.Vec {
var v pixel.Vec
mainthread.Call(func() {
x, y := w.window.GetPos()
v = pixel.V(float64(x), float64(y))
})
return v
} | go | {
"resource": ""
} |
q30758 | SetMonitor | train | func (w *Window) SetMonitor(monitor *Monitor) {
if w.Monitor() != monitor {
if monitor != nil {
w.setFullscreen(monitor)
} else {
w.setWindowed()
}
}
} | go | {
"resource": ""
} |
q30759 | Monitor | train | func (w *Window) Monitor() *Monitor {
var monitor *glfw.Monitor
mainthread.Call(func() {
monitor = w.window.GetMonitor()
})
if monitor == nil {
return nil
}
return &Monitor{
monitor: monitor,
}
} | go | {
"resource": ""
} |
q30760 | Focused | train | func (w *Window) Focused() bool {
var focused bool
mainthread.Call(func() {
focused = w.window.GetAttrib(glfw.Focused) == glfw.True
})
return focused
} | go | {
"resource": ""
} |
q30761 | SetCursorVisible | train | func (w *Window) SetCursorVisible(visible bool) {
w.cursorVisible = visible
mainthread.Call(func() {
if visible {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
})
} | go | {
"resource": ""
} |
q30762 | MakeTriangles | train | func (w *Window) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return w.canvas.MakeTriangles(t)
} | go | {
"resource": ""
} |
q30763 | MakePicture | train | func (w *Window) MakePicture(p pixel.Picture) pixel.TargetPicture {
return w.canvas.MakePicture(p)
} | go | {
"resource": ""
} |
q30764 | SetColorMask | train | func (w *Window) SetColorMask(c color.Color) {
w.canvas.SetColorMask(c)
} | go | {
"resource": ""
} |
q30765 | SetComposeMethod | train | func (w *Window) SetComposeMethod(cmp pixel.ComposeMethod) {
w.canvas.SetComposeMethod(cmp)
} | go | {
"resource": ""
} |
q30766 | Clear | train | func (w *Window) Clear(c color.Color) {
w.canvas.Clear(c)
} | go | {
"resource": ""
} |
q30767 | Color | train | func (w *Window) Color(at pixel.Vec) pixel.RGBA {
return w.canvas.Color(at)
} | go | {
"resource": ""
} |
q30768 | Contains | train | func (a *Atlas) Contains(r rune) bool {
_, ok := a.mapping[r]
return ok
} | go | {
"resource": ""
} |
q30769 | Kern | train | func (a *Atlas) Kern(r0, r1 rune) float64 {
return i2f(a.face.Kern(r0, r1))
} | go | {
"resource": ""
} |
q30770 | DrawRune | train | func (a *Atlas) DrawRune(prevR, r rune, dot pixel.Vec) (rect, frame, bounds pixel.Rect, newDot pixel.Vec) {
if !a.Contains(r) {
r = unicode.ReplacementChar
}
if !a.Contains(unicode.ReplacementChar) {
return pixel.Rect{}, pixel.Rect{}, pixel.Rect{}, dot
}
if !a.Contains(prevR) {
prevR = unicode.ReplacementCha... | go | {
"resource": ""
} |
q30771 | makeSquareMapping | train | func makeSquareMapping(face font.Face, runes []rune, padding fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
width := sort.Search(int(fixed.I(1024*1024)), func(i int) bool {
width := fixed.Int26_6(i)
_, bounds := makeMapping(face, runes, padding, width)
return bounds.Max.X-bounds.Min.X >= bounds.Max.... | go | {
"resource": ""
} |
q30772 | makeMapping | train | func makeMapping(face font.Face, runes []rune, padding, width fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
mapping := make(map[rune]fixedGlyph)
bounds := fixed.Rectangle26_6{}
dot := fixed.P(0, 0)
for _, r := range runes {
b, advance, ok := face.GlyphBounds(r)
if !ok {
fmt.Println(r)
cont... | go | {
"resource": ""
} |
q30773 | NewCanvas | train | func NewCanvas(bounds pixel.Rect) *Canvas {
c := &Canvas{
gf: NewGLFrame(bounds),
mat: mgl32.Ident3(),
col: mgl32.Vec4{1, 1, 1, 1},
}
baseShader(c)
c.SetBounds(bounds)
c.shader.update()
return c
} | go | {
"resource": ""
} |
q30774 | SetUniform | train | func (c *Canvas) SetUniform(name string, value interface{}) {
c.shader.setUniform(name, value)
} | go | {
"resource": ""
} |
q30775 | SetFragmentShader | train | func (c *Canvas) SetFragmentShader(src string) {
c.shader.fs = src
c.shader.update()
} | go | {
"resource": ""
} |
q30776 | MakeTriangles | train | func (c *Canvas) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return &canvasTriangles{
GLTriangles: NewGLTriangles(c.shader.s, t),
dst: c,
}
} | go | {
"resource": ""
} |
q30777 | MakePicture | train | func (c *Canvas) MakePicture(p pixel.Picture) pixel.TargetPicture {
if cp, ok := p.(*canvasPicture); ok {
return &canvasPicture{
GLPicture: cp.GLPicture,
dst: c,
}
}
if gp, ok := p.(GLPicture); ok {
return &canvasPicture{
GLPicture: gp,
dst: c,
}
}
return &canvasPicture{
GLPicture... | go | {
"resource": ""
} |
q30778 | SetColorMask | train | func (c *Canvas) SetColorMask(col color.Color) {
rgba := pixel.Alpha(1)
if col != nil {
rgba = pixel.ToRGBA(col)
}
c.col = mgl32.Vec4{
float32(rgba.R),
float32(rgba.G),
float32(rgba.B),
float32(rgba.A),
}
} | go | {
"resource": ""
} |
q30779 | SetBounds | train | func (c *Canvas) SetBounds(bounds pixel.Rect) {
c.gf.SetBounds(bounds)
if c.sprite == nil {
c.sprite = pixel.NewSprite(nil, pixel.Rect{})
}
c.sprite.Set(c, c.Bounds())
//c.sprite.SetMatrix(pixel.IM.Moved(c.Bounds().Center()))
} | go | {
"resource": ""
} |
q30780 | Clear | train | func (c *Canvas) Clear(color color.Color) {
c.gf.Dirty()
rgba := pixel.ToRGBA(color)
// color masking
rgba = rgba.Mul(pixel.RGBA{
R: float64(c.col[0]),
G: float64(c.col[1]),
B: float64(c.col[2]),
A: float64(c.col[3]),
})
mainthread.CallNonBlock(func() {
c.setGlhfBounds()
c.gf.Frame().Begin()
glhf... | go | {
"resource": ""
} |
q30781 | Color | train | func (c *Canvas) Color(at pixel.Vec) pixel.RGBA {
return c.gf.Color(at)
} | go | {
"resource": ""
} |
q30782 | Pixels | train | func (c *Canvas) Pixels() []uint8 {
var pixels []uint8
mainthread.Call(func() {
tex := c.Texture()
tex.Begin()
pixels = tex.Pixels(0, 0, tex.Width(), tex.Height())
tex.End()
})
return pixels
} | go | {
"resource": ""
} |
q30783 | Draw | train | func (c *Canvas) Draw(t pixel.Target, matrix pixel.Matrix) {
c.sprite.Draw(t, matrix)
} | go | {
"resource": ""
} |
q30784 | DrawColorMask | train | func (c *Canvas) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color) {
c.sprite.DrawColorMask(t, matrix, mask)
} | go | {
"resource": ""
} |
q30785 | JoystickPresent | train | func (w *Window) JoystickPresent(js Joystick) bool {
return w.currJoy.connected[js]
} | go | {
"resource": ""
} |
q30786 | JoystickName | train | func (w *Window) JoystickName(js Joystick) string {
return w.currJoy.name[js]
} | go | {
"resource": ""
} |
q30787 | JoystickButtonCount | train | func (w *Window) JoystickButtonCount(js Joystick) int {
return len(w.currJoy.buttons[js])
} | go | {
"resource": ""
} |
q30788 | JoystickAxisCount | train | func (w *Window) JoystickAxisCount(js Joystick) int {
return len(w.currJoy.axis[js])
} | go | {
"resource": ""
} |
q30789 | JoystickPressed | train | func (w *Window) JoystickPressed(js Joystick, button int) bool {
return w.currJoy.getButton(js, button)
} | go | {
"resource": ""
} |
q30790 | JoystickJustPressed | train | func (w *Window) JoystickJustPressed(js Joystick, button int) bool {
return w.currJoy.getButton(js, button) && !w.prevJoy.getButton(js, button)
} | go | {
"resource": ""
} |
q30791 | JoystickAxis | train | func (w *Window) JoystickAxis(js Joystick, axis int) float64 {
return w.currJoy.getAxis(js, axis)
} | go | {
"resource": ""
} |
q30792 | updateJoystickInput | train | func (w *Window) updateJoystickInput() {
for js := Joystick1; js <= JoystickLast; js++ {
// Determine and store if the joystick was connected
joystickPresent := glfw.JoystickPresent(glfw.Joystick(js))
w.tempJoy.connected[js] = joystickPresent
if joystickPresent {
w.tempJoy.buttons[js] = glfw.GetJoystickBut... | go | {
"resource": ""
} |
q30793 | getButton | train | func (js *joystickState) getButton(joystick Joystick, button int) bool {
// Check that the joystick and button is valid, return false by default
if js.buttons[joystick] == nil || button >= len(js.buttons[joystick]) || button < 0 {
return false
}
return js.buttons[joystick][byte(button)] == 1
} | go | {
"resource": ""
} |
q30794 | getAxis | train | func (js *joystickState) getAxis(joystick Joystick, axis int) float64 {
// Check that the joystick and axis is valid, return 0 by default.
if js.axis[joystick] == nil || axis >= len(js.axis[joystick]) || axis < 0 {
return 0
}
return float64(js.axis[joystick][axis])
} | go | {
"resource": ""
} |
q30795 | NewSprite | train | func NewSprite(pic Picture, frame Rect) *Sprite {
tri := MakeTrianglesData(6)
s := &Sprite{
tri: tri,
d: Drawer{Triangles: tri},
}
s.matrix = IM
s.mask = Alpha(1)
s.Set(pic, frame)
return s
} | go | {
"resource": ""
} |
q30796 | Set | train | func (s *Sprite) Set(pic Picture, frame Rect) {
s.d.Picture = pic
if frame != s.frame {
s.frame = frame
s.calcData()
}
} | go | {
"resource": ""
} |
q30797 | Draw | train | func (s *Sprite) Draw(t Target, matrix Matrix) {
s.DrawColorMask(t, matrix, nil)
} | go | {
"resource": ""
} |
q30798 | DrawColorMask | train | func (s *Sprite) DrawColorMask(t Target, matrix Matrix, mask color.Color) {
dirty := false
if matrix != s.matrix {
s.matrix = matrix
dirty = true
}
if mask == nil {
mask = Alpha(1)
}
rgba := ToRGBA(mask)
if rgba != s.mask {
s.mask = rgba
dirty = true
}
if dirty {
s.calcData()
}
s.d.Draw(t)
} | go | {
"resource": ""
} |
q30799 | Compose | train | func (cm ComposeMethod) Compose(a, b RGBA) RGBA {
var fa, fb float64
switch cm {
case ComposeOver:
fa, fb = 1, 1-a.A
case ComposeIn:
fa, fb = b.A, 0
case ComposeOut:
fa, fb = 1-b.A, 0
case ComposeAtop:
fa, fb = b.A, 1-a.A
case ComposeRover:
fa, fb = 1-b.A, 1
case ComposeRin:
fa, fb = 0, a.A
case C... | go | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.