id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens listlengths 21 1.41k | docstring stringlengths 6 2.61k | docstring_tokens listlengths 3 215 | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
30,800 | faiface/pixel | batch.go | NewBatch | func NewBatch(container Triangles, pic Picture) *Batch {
b := &Batch{cont: Drawer{Triangles: container, Picture: pic}}
b.SetMatrix(IM)
b.SetColorMask(Alpha(1))
return b
} | go | func NewBatch(container Triangles, pic Picture) *Batch {
b := &Batch{cont: Drawer{Triangles: container, Picture: pic}}
b.SetMatrix(IM)
b.SetColorMask(Alpha(1))
return b
} | [
"func",
"NewBatch",
"(",
"container",
"Triangles",
",",
"pic",
"Picture",
")",
"*",
"Batch",
"{",
"b",
":=",
"&",
"Batch",
"{",
"cont",
":",
"Drawer",
"{",
"Triangles",
":",
"container",
",",
"Picture",
":",
"pic",
"}",
"}",
"\n",
"b",
".",
"SetMatri... | // NewBatch creates an empty Batch with the specified Picture and container.
//
// The container is where objects get accumulated. Batch will support precisely those Triangles
// properties, that the supplied container supports. If you retain access to the container and
// change it, call Dirty to notify Batch about th... | [
"NewBatch",
"creates",
"an",
"empty",
"Batch",
"with",
"the",
"specified",
"Picture",
"and",
"container",
".",
"The",
"container",
"is",
"where",
"objects",
"get",
"accumulated",
".",
"Batch",
"will",
"support",
"precisely",
"those",
"Triangles",
"properties",
"... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/batch.go#L28-L33 |
30,801 | faiface/pixel | batch.go | Clear | func (b *Batch) Clear() {
b.cont.Triangles.SetLen(0)
b.cont.Dirty()
} | go | func (b *Batch) Clear() {
b.cont.Triangles.SetLen(0)
b.cont.Dirty()
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"Clear",
"(",
")",
"{",
"b",
".",
"cont",
".",
"Triangles",
".",
"SetLen",
"(",
"0",
")",
"\n",
"b",
".",
"cont",
".",
"Dirty",
"(",
")",
"\n",
"}"
] | // Clear removes all objects from the Batch. | [
"Clear",
"removes",
"all",
"objects",
"from",
"the",
"Batch",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/batch.go#L47-L50 |
30,802 | faiface/pixel | batch.go | SetColorMask | func (b *Batch) SetColorMask(c color.Color) {
if c == nil {
b.col = Alpha(1)
return
}
b.col = ToRGBA(c)
} | go | func (b *Batch) SetColorMask(c color.Color) {
if c == nil {
b.col = Alpha(1)
return
}
b.col = ToRGBA(c)
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"SetColorMask",
"(",
"c",
"color",
".",
"Color",
")",
"{",
"if",
"c",
"==",
"nil",
"{",
"b",
".",
"col",
"=",
"Alpha",
"(",
"1",
")",
"\n",
"return",
"\n",
"}",
"\n",
"b",
".",
"col",
"=",
"ToRGBA",
"(",
... | // SetColorMask sets a mask color used in the following draws onto the Batch. | [
"SetColorMask",
"sets",
"a",
"mask",
"color",
"used",
"in",
"the",
"following",
"draws",
"onto",
"the",
"Batch",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/batch.go#L63-L69 |
30,803 | faiface/pixel | batch.go | MakeTriangles | func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
bt := &batchTriangles{
tri: t.Copy(),
tmp: MakeTrianglesData(t.Len()),
dst: b,
}
return bt
} | go | func (b *Batch) MakeTriangles(t Triangles) TargetTriangles {
bt := &batchTriangles{
tri: t.Copy(),
tmp: MakeTrianglesData(t.Len()),
dst: b,
}
return bt
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"MakeTriangles",
"(",
"t",
"Triangles",
")",
"TargetTriangles",
"{",
"bt",
":=",
"&",
"batchTriangles",
"{",
"tri",
":",
"t",
".",
"Copy",
"(",
")",
",",
"tmp",
":",
"MakeTrianglesData",
"(",
"t",
".",
"Len",
"(",... | // MakeTriangles returns a specialized copy of the provided Triangles that draws onto this Batch. | [
"MakeTriangles",
"returns",
"a",
"specialized",
"copy",
"of",
"the",
"provided",
"Triangles",
"that",
"draws",
"onto",
"this",
"Batch",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/batch.go#L72-L79 |
30,804 | faiface/pixel | batch.go | MakePicture | func (b *Batch) MakePicture(p Picture) TargetPicture {
if p != b.cont.Picture {
panic(fmt.Errorf("(%T).MakePicture: Picture is not the Batch's Picture", b))
}
bp := &batchPicture{
pic: p,
dst: b,
}
return bp
} | go | func (b *Batch) MakePicture(p Picture) TargetPicture {
if p != b.cont.Picture {
panic(fmt.Errorf("(%T).MakePicture: Picture is not the Batch's Picture", b))
}
bp := &batchPicture{
pic: p,
dst: b,
}
return bp
} | [
"func",
"(",
"b",
"*",
"Batch",
")",
"MakePicture",
"(",
"p",
"Picture",
")",
"TargetPicture",
"{",
"if",
"p",
"!=",
"b",
".",
"cont",
".",
"Picture",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"b",
")",
")",
"\n",
"}",
"\n"... | // MakePicture returns a specialized copy of the provided Picture that draws onto this Batch. | [
"MakePicture",
"returns",
"a",
"specialized",
"copy",
"of",
"the",
"provided",
"Picture",
"that",
"draws",
"onto",
"this",
"Batch",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/batch.go#L82-L91 |
30,805 | faiface/pixel | drawer.go | Dirty | func (d *Drawer) Dirty() {
d.lazyInit()
for _, t := range d.targets {
t.clean = false
}
} | go | func (d *Drawer) Dirty() {
d.lazyInit()
for _, t := range d.targets {
t.clean = false
}
} | [
"func",
"(",
"d",
"*",
"Drawer",
")",
"Dirty",
"(",
")",
"{",
"d",
".",
"lazyInit",
"(",
")",
"\n\n",
"for",
"_",
",",
"t",
":=",
"range",
"d",
".",
"targets",
"{",
"t",
".",
"clean",
"=",
"false",
"\n",
"}",
"\n",
"}"
] | // Dirty marks the Triangles of this Drawer as changed. If not called, changes will not be visible
// when drawing. | [
"Dirty",
"marks",
"the",
"Triangles",
"of",
"this",
"Drawer",
"as",
"changed",
".",
"If",
"not",
"called",
"changes",
"will",
"not",
"be",
"visible",
"when",
"drawing",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/drawer.go#L46-L52 |
30,806 | faiface/pixel | drawer.go | Draw | func (d *Drawer) Draw(t Target) {
d.lazyInit()
if d.Triangles == nil {
return
}
dt := d.targets[t]
if dt == nil {
dt = &drawerTarget{
pics: make(map[Picture]TargetPicture),
}
d.targets[t] = dt
}
if dt.tris == nil {
dt.tris = t.MakeTriangles(d.Triangles)
dt.clean = true
}
if !dt.clean {
dt.... | go | func (d *Drawer) Draw(t Target) {
d.lazyInit()
if d.Triangles == nil {
return
}
dt := d.targets[t]
if dt == nil {
dt = &drawerTarget{
pics: make(map[Picture]TargetPicture),
}
d.targets[t] = dt
}
if dt.tris == nil {
dt.tris = t.MakeTriangles(d.Triangles)
dt.clean = true
}
if !dt.clean {
dt.... | [
"func",
"(",
"d",
"*",
"Drawer",
")",
"Draw",
"(",
"t",
"Target",
")",
"{",
"d",
".",
"lazyInit",
"(",
")",
"\n\n",
"if",
"d",
".",
"Triangles",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n\n",
"dt",
":=",
"d",
".",
"targets",
"[",
"t",
"]",
"\... | // Draw efficiently draws Triangles with Picture onto the provided Target.
//
// If Triangles is nil, nothing will be drawn. If Picture is nil, Triangles will be drawn without a
// Picture. | [
"Draw",
"efficiently",
"draws",
"Triangles",
"with",
"Picture",
"onto",
"the",
"provided",
"Target",
".",
"If",
"Triangles",
"is",
"nil",
"nothing",
"will",
"be",
"drawn",
".",
"If",
"Picture",
"is",
"nil",
"Triangles",
"will",
"be",
"drawn",
"without",
"a",... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/drawer.go#L58-L96 |
30,807 | faiface/pixel | pixelgl/glframe.go | NewGLFrame | func NewGLFrame(bounds pixel.Rect) *GLFrame {
gf := new(GLFrame)
gf.SetBounds(bounds)
return gf
} | go | func NewGLFrame(bounds pixel.Rect) *GLFrame {
gf := new(GLFrame)
gf.SetBounds(bounds)
return gf
} | [
"func",
"NewGLFrame",
"(",
"bounds",
"pixel",
".",
"Rect",
")",
"*",
"GLFrame",
"{",
"gf",
":=",
"new",
"(",
"GLFrame",
")",
"\n",
"gf",
".",
"SetBounds",
"(",
"bounds",
")",
"\n",
"return",
"gf",
"\n",
"}"
] | // NewGLFrame creates a new GLFrame with the given bounds. | [
"NewGLFrame",
"creates",
"a",
"new",
"GLFrame",
"with",
"the",
"given",
"bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glframe.go#L19-L23 |
30,808 | faiface/pixel | pixelgl/glframe.go | SetBounds | func (gf *GLFrame) SetBounds(bounds pixel.Rect) {
if bounds == gf.Bounds() {
return
}
mainthread.Call(func() {
oldF := gf.frame
_, _, w, h := intBounds(bounds)
if w <= 0 {
w = 1
}
if h <= 0 {
h = 1
}
gf.frame = glhf.NewFrame(w, h, false)
// preserve old content
if oldF != nil {
ox, oy... | go | func (gf *GLFrame) SetBounds(bounds pixel.Rect) {
if bounds == gf.Bounds() {
return
}
mainthread.Call(func() {
oldF := gf.frame
_, _, w, h := intBounds(bounds)
if w <= 0 {
w = 1
}
if h <= 0 {
h = 1
}
gf.frame = glhf.NewFrame(w, h, false)
// preserve old content
if oldF != nil {
ox, oy... | [
"func",
"(",
"gf",
"*",
"GLFrame",
")",
"SetBounds",
"(",
"bounds",
"pixel",
".",
"Rect",
")",
"{",
"if",
"bounds",
"==",
"gf",
".",
"Bounds",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"old... | // SetBounds resizes the GLFrame to the new bounds. | [
"SetBounds",
"resizes",
"the",
"GLFrame",
"to",
"the",
"new",
"bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glframe.go#L26-L57 |
30,809 | faiface/pixel | pixelgl/glframe.go | Color | func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA {
if gf.dirty {
mainthread.Call(func() {
tex := gf.frame.Texture()
tex.Begin()
gf.pixels = tex.Pixels(0, 0, tex.Width(), tex.Height())
tex.End()
})
gf.dirty = false
}
if !gf.bounds.Contains(at) {
return pixel.Alpha(0)
}
bx, by, bw, _ := intBound... | go | func (gf *GLFrame) Color(at pixel.Vec) pixel.RGBA {
if gf.dirty {
mainthread.Call(func() {
tex := gf.frame.Texture()
tex.Begin()
gf.pixels = tex.Pixels(0, 0, tex.Width(), tex.Height())
tex.End()
})
gf.dirty = false
}
if !gf.bounds.Contains(at) {
return pixel.Alpha(0)
}
bx, by, bw, _ := intBound... | [
"func",
"(",
"gf",
"*",
"GLFrame",
")",
"Color",
"(",
"at",
"pixel",
".",
"Vec",
")",
"pixel",
".",
"RGBA",
"{",
"if",
"gf",
".",
"dirty",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"tex",
":=",
"gf",
".",
"frame",
".",
"Textur... | // Color returns the color of the pixel under the specified position. | [
"Color",
"returns",
"the",
"color",
"of",
"the",
"pixel",
"under",
"the",
"specified",
"position",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glframe.go#L65-L87 |
30,810 | faiface/pixel | pixelgl/gltriangles.go | NewGLTriangles | func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles {
var gt *GLTriangles
mainthread.Call(func() {
gt = &GLTriangles{
vs: glhf.MakeVertexSlice(shader, 0, t.Len()),
shader: shader,
}
})
gt.SetLen(t.Len())
gt.Update(t)
return gt
} | go | func NewGLTriangles(shader *glhf.Shader, t pixel.Triangles) *GLTriangles {
var gt *GLTriangles
mainthread.Call(func() {
gt = &GLTriangles{
vs: glhf.MakeVertexSlice(shader, 0, t.Len()),
shader: shader,
}
})
gt.SetLen(t.Len())
gt.Update(t)
return gt
} | [
"func",
"NewGLTriangles",
"(",
"shader",
"*",
"glhf",
".",
"Shader",
",",
"t",
"pixel",
".",
"Triangles",
")",
"*",
"GLTriangles",
"{",
"var",
"gt",
"*",
"GLTriangles",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"gt",
"=",
"&",
"GLT... | // NewGLTriangles returns GLTriangles initialized with the data from the supplied Triangles.
//
// Only draw the Triangles using the provided Shader. | [
"NewGLTriangles",
"returns",
"GLTriangles",
"initialized",
"with",
"the",
"data",
"from",
"the",
"supplied",
"Triangles",
".",
"Only",
"draw",
"the",
"Triangles",
"using",
"the",
"provided",
"Shader",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L30-L41 |
30,811 | faiface/pixel | pixelgl/gltriangles.go | Len | func (gt *GLTriangles) Len() int {
return len(gt.data) / gt.vs.Stride()
} | go | func (gt *GLTriangles) Len() int {
return len(gt.data) / gt.vs.Stride()
} | [
"func",
"(",
"gt",
"*",
"GLTriangles",
")",
"Len",
"(",
")",
"int",
"{",
"return",
"len",
"(",
"gt",
".",
"data",
")",
"/",
"gt",
".",
"vs",
".",
"Stride",
"(",
")",
"\n",
"}"
] | // Len returns the number of vertices. | [
"Len",
"returns",
"the",
"number",
"of",
"vertices",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L56-L58 |
30,812 | faiface/pixel | pixelgl/gltriangles.go | Slice | func (gt *GLTriangles) Slice(i, j int) pixel.Triangles {
return &GLTriangles{
vs: gt.vs.Slice(i, j),
data: gt.data[i*gt.vs.Stride() : j*gt.vs.Stride()],
shader: gt.shader,
}
} | go | func (gt *GLTriangles) Slice(i, j int) pixel.Triangles {
return &GLTriangles{
vs: gt.vs.Slice(i, j),
data: gt.data[i*gt.vs.Stride() : j*gt.vs.Stride()],
shader: gt.shader,
}
} | [
"func",
"(",
"gt",
"*",
"GLTriangles",
")",
"Slice",
"(",
"i",
",",
"j",
"int",
")",
"pixel",
".",
"Triangles",
"{",
"return",
"&",
"GLTriangles",
"{",
"vs",
":",
"gt",
".",
"vs",
".",
"Slice",
"(",
"i",
",",
"j",
")",
",",
"data",
":",
"gt",
... | // Slice returns a sub-Triangles of this GLTriangles in range [i, j). | [
"Slice",
"returns",
"a",
"sub",
"-",
"Triangles",
"of",
"this",
"GLTriangles",
"in",
"range",
"[",
"i",
"j",
")",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L88-L94 |
30,813 | faiface/pixel | pixelgl/gltriangles.go | Position | func (gt *GLTriangles) Position(i int) pixel.Vec {
px := gt.data[i*gt.vs.Stride()+0]
py := gt.data[i*gt.vs.Stride()+1]
return pixel.V(float64(px), float64(py))
} | go | func (gt *GLTriangles) Position(i int) pixel.Vec {
px := gt.data[i*gt.vs.Stride()+0]
py := gt.data[i*gt.vs.Stride()+1]
return pixel.V(float64(px), float64(py))
} | [
"func",
"(",
"gt",
"*",
"GLTriangles",
")",
"Position",
"(",
"i",
"int",
")",
"pixel",
".",
"Vec",
"{",
"px",
":=",
"gt",
".",
"data",
"[",
"i",
"*",
"gt",
".",
"vs",
".",
"Stride",
"(",
")",
"+",
"0",
"]",
"\n",
"py",
":=",
"gt",
".",
"dat... | // Position returns the Position property of the i-th vertex. | [
"Position",
"returns",
"the",
"Position",
"property",
"of",
"the",
"i",
"-",
"th",
"vertex",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L189-L193 |
30,814 | faiface/pixel | pixelgl/gltriangles.go | Color | func (gt *GLTriangles) Color(i int) pixel.RGBA {
r := gt.data[i*gt.vs.Stride()+2]
g := gt.data[i*gt.vs.Stride()+3]
b := gt.data[i*gt.vs.Stride()+4]
a := gt.data[i*gt.vs.Stride()+5]
return pixel.RGBA{
R: float64(r),
G: float64(g),
B: float64(b),
A: float64(a),
}
} | go | func (gt *GLTriangles) Color(i int) pixel.RGBA {
r := gt.data[i*gt.vs.Stride()+2]
g := gt.data[i*gt.vs.Stride()+3]
b := gt.data[i*gt.vs.Stride()+4]
a := gt.data[i*gt.vs.Stride()+5]
return pixel.RGBA{
R: float64(r),
G: float64(g),
B: float64(b),
A: float64(a),
}
} | [
"func",
"(",
"gt",
"*",
"GLTriangles",
")",
"Color",
"(",
"i",
"int",
")",
"pixel",
".",
"RGBA",
"{",
"r",
":=",
"gt",
".",
"data",
"[",
"i",
"*",
"gt",
".",
"vs",
".",
"Stride",
"(",
")",
"+",
"2",
"]",
"\n",
"g",
":=",
"gt",
".",
"data",
... | // Color returns the Color property of the i-th vertex. | [
"Color",
"returns",
"the",
"Color",
"property",
"of",
"the",
"i",
"-",
"th",
"vertex",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L196-L207 |
30,815 | faiface/pixel | pixelgl/gltriangles.go | Picture | func (gt *GLTriangles) Picture(i int) (pic pixel.Vec, intensity float64) {
tx := gt.data[i*gt.vs.Stride()+6]
ty := gt.data[i*gt.vs.Stride()+7]
intensity = float64(gt.data[i*gt.vs.Stride()+8])
return pixel.V(float64(tx), float64(ty)), intensity
} | go | func (gt *GLTriangles) Picture(i int) (pic pixel.Vec, intensity float64) {
tx := gt.data[i*gt.vs.Stride()+6]
ty := gt.data[i*gt.vs.Stride()+7]
intensity = float64(gt.data[i*gt.vs.Stride()+8])
return pixel.V(float64(tx), float64(ty)), intensity
} | [
"func",
"(",
"gt",
"*",
"GLTriangles",
")",
"Picture",
"(",
"i",
"int",
")",
"(",
"pic",
"pixel",
".",
"Vec",
",",
"intensity",
"float64",
")",
"{",
"tx",
":=",
"gt",
".",
"data",
"[",
"i",
"*",
"gt",
".",
"vs",
".",
"Stride",
"(",
")",
"+",
... | // Picture returns the Picture property of the i-th vertex. | [
"Picture",
"returns",
"the",
"Picture",
"property",
"of",
"the",
"i",
"-",
"th",
"vertex",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/gltriangles.go#L210-L215 |
30,816 | faiface/pixel | color.go | RGB | func RGB(r, g, b float64) RGBA {
return RGBA{r, g, b, 1}
} | go | func RGB(r, g, b float64) RGBA {
return RGBA{r, g, b, 1}
} | [
"func",
"RGB",
"(",
"r",
",",
"g",
",",
"b",
"float64",
")",
"RGBA",
"{",
"return",
"RGBA",
"{",
"r",
",",
"g",
",",
"b",
",",
"1",
"}",
"\n",
"}"
] | // RGB returns a fully opaque RGBA color with the given RGB values.
//
// A common way to construct a transparent color is to create one with RGB constructor, then
// multiply it by a color obtained from the Alpha constructor. | [
"RGB",
"returns",
"a",
"fully",
"opaque",
"RGBA",
"color",
"with",
"the",
"given",
"RGB",
"values",
".",
"A",
"common",
"way",
"to",
"construct",
"a",
"transparent",
"color",
"is",
"to",
"create",
"one",
"with",
"RGB",
"constructor",
"then",
"multiply",
"i... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/color.go#L16-L18 |
30,817 | faiface/pixel | color.go | RGBA | func (c RGBA) RGBA() (r, g, b, a uint32) {
r = uint32(0xffff * c.R)
g = uint32(0xffff * c.G)
b = uint32(0xffff * c.B)
a = uint32(0xffff * c.A)
return
} | go | func (c RGBA) RGBA() (r, g, b, a uint32) {
r = uint32(0xffff * c.R)
g = uint32(0xffff * c.G)
b = uint32(0xffff * c.B)
a = uint32(0xffff * c.A)
return
} | [
"func",
"(",
"c",
"RGBA",
")",
"RGBA",
"(",
")",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"uint32",
")",
"{",
"r",
"=",
"uint32",
"(",
"0xffff",
"*",
"c",
".",
"R",
")",
"\n",
"g",
"=",
"uint32",
"(",
"0xffff",
"*",
"c",
".",
"G",
")",
"... | // RGBA returns alpha-premultiplied red, green, blue and alpha components of the RGBA color. | [
"RGBA",
"returns",
"alpha",
"-",
"premultiplied",
"red",
"green",
"blue",
"and",
"alpha",
"components",
"of",
"the",
"RGBA",
"color",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/color.go#L69-L75 |
30,818 | faiface/pixel | pixelgl/monitor.go | Monitors | func Monitors() []*Monitor {
var monitors []*Monitor
mainthread.Call(func() {
for _, monitor := range glfw.GetMonitors() {
monitors = append(monitors, &Monitor{monitor: monitor})
}
})
return monitors
} | go | func Monitors() []*Monitor {
var monitors []*Monitor
mainthread.Call(func() {
for _, monitor := range glfw.GetMonitors() {
monitors = append(monitors, &Monitor{monitor: monitor})
}
})
return monitors
} | [
"func",
"Monitors",
"(",
")",
"[",
"]",
"*",
"Monitor",
"{",
"var",
"monitors",
"[",
"]",
"*",
"Monitor",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"for",
"_",
",",
"monitor",
":=",
"range",
"glfw",
".",
"GetMonitors",
"(",
")",
... | // Monitors returns a slice of all currently available monitors. | [
"Monitors",
"returns",
"a",
"slice",
"of",
"all",
"currently",
"available",
"monitors",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L36-L44 |
30,819 | faiface/pixel | pixelgl/monitor.go | Name | func (m *Monitor) Name() string {
var name string
mainthread.Call(func() {
name = m.monitor.GetName()
})
return name
} | go | func (m *Monitor) Name() string {
var name string
mainthread.Call(func() {
name = m.monitor.GetName()
})
return name
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Name",
"(",
")",
"string",
"{",
"var",
"name",
"string",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"name",
"=",
"m",
".",
"monitor",
".",
"GetName",
"(",
")",
"\n",
"}",
")",
"\n",
"ret... | // Name returns a human-readable name of the Monitor. | [
"Name",
"returns",
"a",
"human",
"-",
"readable",
"name",
"of",
"the",
"Monitor",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L47-L53 |
30,820 | faiface/pixel | pixelgl/monitor.go | PhysicalSize | func (m *Monitor) PhysicalSize() (width, height float64) {
var wi, hi int
mainthread.Call(func() {
wi, hi = m.monitor.GetPhysicalSize()
})
width = float64(wi)
height = float64(hi)
return
} | go | func (m *Monitor) PhysicalSize() (width, height float64) {
var wi, hi int
mainthread.Call(func() {
wi, hi = m.monitor.GetPhysicalSize()
})
width = float64(wi)
height = float64(hi)
return
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"PhysicalSize",
"(",
")",
"(",
"width",
",",
"height",
"float64",
")",
"{",
"var",
"wi",
",",
"hi",
"int",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"wi",
",",
"hi",
"=",
"m",
".",
"moni... | // PhysicalSize returns the size of the display area of the Monitor in millimeters. | [
"PhysicalSize",
"returns",
"the",
"size",
"of",
"the",
"display",
"area",
"of",
"the",
"Monitor",
"in",
"millimeters",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L56-L64 |
30,821 | faiface/pixel | pixelgl/monitor.go | Position | func (m *Monitor) Position() (x, y float64) {
var xi, yi int
mainthread.Call(func() {
xi, yi = m.monitor.GetPos()
})
x = float64(xi)
y = float64(yi)
return
} | go | func (m *Monitor) Position() (x, y float64) {
var xi, yi int
mainthread.Call(func() {
xi, yi = m.monitor.GetPos()
})
x = float64(xi)
y = float64(yi)
return
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Position",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"var",
"xi",
",",
"yi",
"int",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"xi",
",",
"yi",
"=",
"m",
".",
"monitor",
".",
... | // Position returns the position of the upper-left corner of the Monitor in screen coordinates. | [
"Position",
"returns",
"the",
"position",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"Monitor",
"in",
"screen",
"coordinates",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L67-L75 |
30,822 | faiface/pixel | pixelgl/monitor.go | Size | func (m *Monitor) Size() (width, height float64) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
width = float64(mode.Width)
height = float64(mode.Height)
return
} | go | func (m *Monitor) Size() (width, height float64) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
width = float64(mode.Width)
height = float64(mode.Height)
return
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"Size",
"(",
")",
"(",
"width",
",",
"height",
"float64",
")",
"{",
"var",
"mode",
"*",
"glfw",
".",
"VidMode",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"mode",
"=",
"m",
".",
"monitor",
... | // Size returns the resolution of the Monitor in pixels. | [
"Size",
"returns",
"the",
"resolution",
"of",
"the",
"Monitor",
"in",
"pixels",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L78-L86 |
30,823 | faiface/pixel | pixelgl/monitor.go | BitDepth | func (m *Monitor) BitDepth() (red, green, blue int) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
red = mode.RedBits
green = mode.GreenBits
blue = mode.BlueBits
return
} | go | func (m *Monitor) BitDepth() (red, green, blue int) {
var mode *glfw.VidMode
mainthread.Call(func() {
mode = m.monitor.GetVideoMode()
})
red = mode.RedBits
green = mode.GreenBits
blue = mode.BlueBits
return
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"BitDepth",
"(",
")",
"(",
"red",
",",
"green",
",",
"blue",
"int",
")",
"{",
"var",
"mode",
"*",
"glfw",
".",
"VidMode",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"mode",
"=",
"m",
".",... | // BitDepth returns the number of bits per color of the Monitor. | [
"BitDepth",
"returns",
"the",
"number",
"of",
"bits",
"per",
"color",
"of",
"the",
"Monitor",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L89-L98 |
30,824 | faiface/pixel | pixelgl/monitor.go | VideoModes | func (m *Monitor) VideoModes() (vmodes []VideoMode) {
var modes []*glfw.VidMode
mainthread.Call(func() {
modes = m.monitor.GetVideoModes()
})
for _, mode := range modes {
vmodes = append(vmodes, VideoMode{
Width: mode.Width,
Height: mode.Height,
RefreshRate: mode.RefreshRate,
})
}
return... | go | func (m *Monitor) VideoModes() (vmodes []VideoMode) {
var modes []*glfw.VidMode
mainthread.Call(func() {
modes = m.monitor.GetVideoModes()
})
for _, mode := range modes {
vmodes = append(vmodes, VideoMode{
Width: mode.Width,
Height: mode.Height,
RefreshRate: mode.RefreshRate,
})
}
return... | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"VideoModes",
"(",
")",
"(",
"vmodes",
"[",
"]",
"VideoMode",
")",
"{",
"var",
"modes",
"[",
"]",
"*",
"glfw",
".",
"VidMode",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"modes",
"=",
"m",
... | // VideoModes returns all available video modes for the monitor. | [
"VideoModes",
"returns",
"all",
"available",
"video",
"modes",
"for",
"the",
"monitor",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/monitor.go#L111-L124 |
30,825 | faiface/pixel | geometry.go | nearlyEqual | func nearlyEqual(a, b float64) bool {
epsilon := 0.000001
if a == b {
return true
}
diff := math.Abs(a - b)
if a == 0.0 || b == 0.0 || diff < math.SmallestNonzeroFloat64 {
return diff < (epsilon * math.SmallestNonzeroFloat64)
}
absA := math.Abs(a)
absB := math.Abs(b)
return diff/math.Min(absA+absB, ma... | go | func nearlyEqual(a, b float64) bool {
epsilon := 0.000001
if a == b {
return true
}
diff := math.Abs(a - b)
if a == 0.0 || b == 0.0 || diff < math.SmallestNonzeroFloat64 {
return diff < (epsilon * math.SmallestNonzeroFloat64)
}
absA := math.Abs(a)
absB := math.Abs(b)
return diff/math.Min(absA+absB, ma... | [
"func",
"nearlyEqual",
"(",
"a",
",",
"b",
"float64",
")",
"bool",
"{",
"epsilon",
":=",
"0.000001",
"\n\n",
"if",
"a",
"==",
"b",
"{",
"return",
"true",
"\n",
"}",
"\n\n",
"diff",
":=",
"math",
".",
"Abs",
"(",
"a",
"-",
"b",
")",
"\n\n",
"if",
... | // nearlyEqual compares two float64s and returns whether they are equal, accounting for rounding errors.At worst, the
// result is correct to 7 significant digits. | [
"nearlyEqual",
"compares",
"two",
"float64s",
"and",
"returns",
"whether",
"they",
"are",
"equal",
"accounting",
"for",
"rounding",
"errors",
".",
"At",
"worst",
"the",
"result",
"is",
"correct",
"to",
"7",
"significant",
"digits",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L54-L71 |
30,826 | faiface/pixel | geometry.go | Eq | func (u Vec) Eq(v Vec) bool {
return nearlyEqual(u.X, v.X) && nearlyEqual(u.Y, v.Y)
} | go | func (u Vec) Eq(v Vec) bool {
return nearlyEqual(u.X, v.X) && nearlyEqual(u.Y, v.Y)
} | [
"func",
"(",
"u",
"Vec",
")",
"Eq",
"(",
"v",
"Vec",
")",
"bool",
"{",
"return",
"nearlyEqual",
"(",
"u",
".",
"X",
",",
"v",
".",
"X",
")",
"&&",
"nearlyEqual",
"(",
"u",
".",
"Y",
",",
"v",
".",
"Y",
")",
"\n",
"}"
] | // Eq will compare two vectors and return whether they are equal accounting for rounding errors. At worst, the result
// is correct to 7 significant digits. | [
"Eq",
"will",
"compare",
"two",
"vectors",
"and",
"return",
"whether",
"they",
"are",
"equal",
"accounting",
"for",
"rounding",
"errors",
".",
"At",
"worst",
"the",
"result",
"is",
"correct",
"to",
"7",
"significant",
"digits",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L75-L77 |
30,827 | faiface/pixel | geometry.go | XY | func (u Vec) XY() (x, y float64) {
return u.X, u.Y
} | go | func (u Vec) XY() (x, y float64) {
return u.X, u.Y
} | [
"func",
"(",
"u",
"Vec",
")",
"XY",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"return",
"u",
".",
"X",
",",
"u",
".",
"Y",
"\n",
"}"
] | // XY returns the components of the vector in two return values. | [
"XY",
"returns",
"the",
"components",
"of",
"the",
"vector",
"in",
"two",
"return",
"values",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L94-L96 |
30,828 | faiface/pixel | geometry.go | Add | func (u Vec) Add(v Vec) Vec {
return Vec{
u.X + v.X,
u.Y + v.Y,
}
} | go | func (u Vec) Add(v Vec) Vec {
return Vec{
u.X + v.X,
u.Y + v.Y,
}
} | [
"func",
"(",
"u",
"Vec",
")",
"Add",
"(",
"v",
"Vec",
")",
"Vec",
"{",
"return",
"Vec",
"{",
"u",
".",
"X",
"+",
"v",
".",
"X",
",",
"u",
".",
"Y",
"+",
"v",
".",
"Y",
",",
"}",
"\n",
"}"
] | // Add returns the sum of vectors u and v. | [
"Add",
"returns",
"the",
"sum",
"of",
"vectors",
"u",
"and",
"v",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L99-L104 |
30,829 | faiface/pixel | geometry.go | Sub | func (u Vec) Sub(v Vec) Vec {
return Vec{
u.X - v.X,
u.Y - v.Y,
}
} | go | func (u Vec) Sub(v Vec) Vec {
return Vec{
u.X - v.X,
u.Y - v.Y,
}
} | [
"func",
"(",
"u",
"Vec",
")",
"Sub",
"(",
"v",
"Vec",
")",
"Vec",
"{",
"return",
"Vec",
"{",
"u",
".",
"X",
"-",
"v",
".",
"X",
",",
"u",
".",
"Y",
"-",
"v",
".",
"Y",
",",
"}",
"\n",
"}"
] | // Sub returns the difference betweeen vectors u and v. | [
"Sub",
"returns",
"the",
"difference",
"betweeen",
"vectors",
"u",
"and",
"v",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L107-L112 |
30,830 | faiface/pixel | geometry.go | Floor | func (u Vec) Floor() Vec {
return Vec{
math.Floor(u.X),
math.Floor(u.Y),
}
} | go | func (u Vec) Floor() Vec {
return Vec{
math.Floor(u.X),
math.Floor(u.Y),
}
} | [
"func",
"(",
"u",
"Vec",
")",
"Floor",
"(",
")",
"Vec",
"{",
"return",
"Vec",
"{",
"math",
".",
"Floor",
"(",
"u",
".",
"X",
")",
",",
"math",
".",
"Floor",
"(",
"u",
".",
"Y",
")",
",",
"}",
"\n",
"}"
] | // Floor converts x and y to their integer equivalents. | [
"Floor",
"converts",
"x",
"and",
"y",
"to",
"their",
"integer",
"equivalents",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L115-L120 |
30,831 | faiface/pixel | geometry.go | Scaled | func (u Vec) Scaled(c float64) Vec {
return Vec{u.X * c, u.Y * c}
} | go | func (u Vec) Scaled(c float64) Vec {
return Vec{u.X * c, u.Y * c}
} | [
"func",
"(",
"u",
"Vec",
")",
"Scaled",
"(",
"c",
"float64",
")",
"Vec",
"{",
"return",
"Vec",
"{",
"u",
".",
"X",
"*",
"c",
",",
"u",
".",
"Y",
"*",
"c",
"}",
"\n",
"}"
] | // Scaled returns the vector u multiplied by c. | [
"Scaled",
"returns",
"the",
"vector",
"u",
"multiplied",
"by",
"c",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L131-L133 |
30,832 | faiface/pixel | geometry.go | ScaledXY | func (u Vec) ScaledXY(v Vec) Vec {
return Vec{u.X * v.X, u.Y * v.Y}
} | go | func (u Vec) ScaledXY(v Vec) Vec {
return Vec{u.X * v.X, u.Y * v.Y}
} | [
"func",
"(",
"u",
"Vec",
")",
"ScaledXY",
"(",
"v",
"Vec",
")",
"Vec",
"{",
"return",
"Vec",
"{",
"u",
".",
"X",
"*",
"v",
".",
"X",
",",
"u",
".",
"Y",
"*",
"v",
".",
"Y",
"}",
"\n",
"}"
] | // ScaledXY returns the vector u multiplied by the vector v component-wise. | [
"ScaledXY",
"returns",
"the",
"vector",
"u",
"multiplied",
"by",
"the",
"vector",
"v",
"component",
"-",
"wise",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L136-L138 |
30,833 | faiface/pixel | geometry.go | Len | func (u Vec) Len() float64 {
return math.Hypot(u.X, u.Y)
} | go | func (u Vec) Len() float64 {
return math.Hypot(u.X, u.Y)
} | [
"func",
"(",
"u",
"Vec",
")",
"Len",
"(",
")",
"float64",
"{",
"return",
"math",
".",
"Hypot",
"(",
"u",
".",
"X",
",",
"u",
".",
"Y",
")",
"\n",
"}"
] | // Len returns the length of the vector u. | [
"Len",
"returns",
"the",
"length",
"of",
"the",
"vector",
"u",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L141-L143 |
30,834 | faiface/pixel | geometry.go | Rotated | func (u Vec) Rotated(angle float64) Vec {
sin, cos := math.Sincos(angle)
return Vec{
u.X*cos - u.Y*sin,
u.X*sin + u.Y*cos,
}
} | go | func (u Vec) Rotated(angle float64) Vec {
sin, cos := math.Sincos(angle)
return Vec{
u.X*cos - u.Y*sin,
u.X*sin + u.Y*cos,
}
} | [
"func",
"(",
"u",
"Vec",
")",
"Rotated",
"(",
"angle",
"float64",
")",
"Vec",
"{",
"sin",
",",
"cos",
":=",
"math",
".",
"Sincos",
"(",
"angle",
")",
"\n",
"return",
"Vec",
"{",
"u",
".",
"X",
"*",
"cos",
"-",
"u",
".",
"Y",
"*",
"sin",
",",
... | // Rotated returns the vector u rotated by the given angle in radians. | [
"Rotated",
"returns",
"the",
"vector",
"u",
"rotated",
"by",
"the",
"given",
"angle",
"in",
"radians",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L159-L165 |
30,835 | faiface/pixel | geometry.go | Dot | func (u Vec) Dot(v Vec) float64 {
return u.X*v.X + u.Y*v.Y
} | go | func (u Vec) Dot(v Vec) float64 {
return u.X*v.X + u.Y*v.Y
} | [
"func",
"(",
"u",
"Vec",
")",
"Dot",
"(",
"v",
"Vec",
")",
"float64",
"{",
"return",
"u",
".",
"X",
"*",
"v",
".",
"X",
"+",
"u",
".",
"Y",
"*",
"v",
".",
"Y",
"\n",
"}"
] | // Dot returns the dot product of vectors u and v. | [
"Dot",
"returns",
"the",
"dot",
"product",
"of",
"vectors",
"u",
"and",
"v",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L173-L175 |
30,836 | faiface/pixel | geometry.go | Cross | func (u Vec) Cross(v Vec) float64 {
return u.X*v.Y - v.X*u.Y
} | go | func (u Vec) Cross(v Vec) float64 {
return u.X*v.Y - v.X*u.Y
} | [
"func",
"(",
"u",
"Vec",
")",
"Cross",
"(",
"v",
"Vec",
")",
"float64",
"{",
"return",
"u",
".",
"X",
"*",
"v",
".",
"Y",
"-",
"v",
".",
"X",
"*",
"u",
".",
"Y",
"\n",
"}"
] | // Cross return the cross product of vectors u and v. | [
"Cross",
"return",
"the",
"cross",
"product",
"of",
"vectors",
"u",
"and",
"v",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L178-L180 |
30,837 | faiface/pixel | geometry.go | Lerp | func Lerp(a, b Vec, t float64) Vec {
return a.Scaled(1 - t).Add(b.Scaled(t))
} | go | func Lerp(a, b Vec, t float64) Vec {
return a.Scaled(1 - t).Add(b.Scaled(t))
} | [
"func",
"Lerp",
"(",
"a",
",",
"b",
"Vec",
",",
"t",
"float64",
")",
"Vec",
"{",
"return",
"a",
".",
"Scaled",
"(",
"1",
"-",
"t",
")",
".",
"Add",
"(",
"b",
".",
"Scaled",
"(",
"t",
")",
")",
"\n",
"}"
] | // Lerp returns a linear interpolation between vectors a and b.
//
// This function basically returns a point along the line between a and b and t chooses which one.
// If t is 0, then a will be returned, if t is 1, b will be returned. Anything between 0 and 1 will
// return the appropriate point between a and b and so... | [
"Lerp",
"returns",
"a",
"linear",
"interpolation",
"between",
"vectors",
"a",
"and",
"b",
".",
"This",
"function",
"basically",
"returns",
"a",
"point",
"along",
"the",
"line",
"between",
"a",
"and",
"b",
"and",
"t",
"chooses",
"which",
"one",
".",
"If",
... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L207-L209 |
30,838 | faiface/pixel | geometry.go | L | func L(from, to Vec) Line {
return Line{
A: from,
B: to,
}
} | go | func L(from, to Vec) Line {
return Line{
A: from,
B: to,
}
} | [
"func",
"L",
"(",
"from",
",",
"to",
"Vec",
")",
"Line",
"{",
"return",
"Line",
"{",
"A",
":",
"from",
",",
"B",
":",
"to",
",",
"}",
"\n",
"}"
] | // L creates and returns a new Line. | [
"L",
"creates",
"and",
"returns",
"a",
"new",
"Line",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L217-L222 |
30,839 | faiface/pixel | geometry.go | Bounds | func (l Line) Bounds() Rect {
return R(l.A.X, l.A.Y, l.B.X, l.B.Y).Norm()
} | go | func (l Line) Bounds() Rect {
return R(l.A.X, l.A.Y, l.B.X, l.B.Y).Norm()
} | [
"func",
"(",
"l",
"Line",
")",
"Bounds",
"(",
")",
"Rect",
"{",
"return",
"R",
"(",
"l",
".",
"A",
".",
"X",
",",
"l",
".",
"A",
".",
"Y",
",",
"l",
".",
"B",
".",
"X",
",",
"l",
".",
"B",
".",
"Y",
")",
".",
"Norm",
"(",
")",
"\n",
... | // Bounds returns the lines bounding box. This is in the form of a normalized Rect. | [
"Bounds",
"returns",
"the",
"lines",
"bounding",
"box",
".",
"This",
"is",
"in",
"the",
"form",
"of",
"a",
"normalized",
"Rect",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L225-L227 |
30,840 | faiface/pixel | geometry.go | Center | func (l Line) Center() Vec {
return l.A.Add(l.A.To(l.B).Scaled(0.5))
} | go | func (l Line) Center() Vec {
return l.A.Add(l.A.To(l.B).Scaled(0.5))
} | [
"func",
"(",
"l",
"Line",
")",
"Center",
"(",
")",
"Vec",
"{",
"return",
"l",
".",
"A",
".",
"Add",
"(",
"l",
".",
"A",
".",
"To",
"(",
"l",
".",
"B",
")",
".",
"Scaled",
"(",
"0.5",
")",
")",
"\n",
"}"
] | // Center will return the point at center of the line; that is, the point equidistant from either end. | [
"Center",
"will",
"return",
"the",
"point",
"at",
"center",
"of",
"the",
"line",
";",
"that",
"is",
"the",
"point",
"equidistant",
"from",
"either",
"end",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L230-L232 |
30,841 | faiface/pixel | geometry.go | Closest | func (l Line) Closest(v Vec) Vec {
// between is a helper function which determines whether x is greater than min(a, b) and less than max(a, b)
between := func(a, b, x float64) bool {
min := math.Min(a, b)
max := math.Max(a, b)
return min < x && x < max
}
// Closest point will be on a line which perpendicula... | go | func (l Line) Closest(v Vec) Vec {
// between is a helper function which determines whether x is greater than min(a, b) and less than max(a, b)
between := func(a, b, x float64) bool {
min := math.Min(a, b)
max := math.Max(a, b)
return min < x && x < max
}
// Closest point will be on a line which perpendicula... | [
"func",
"(",
"l",
"Line",
")",
"Closest",
"(",
"v",
"Vec",
")",
"Vec",
"{",
"// between is a helper function which determines whether x is greater than min(a, b) and less than max(a, b)",
"between",
":=",
"func",
"(",
"a",
",",
"b",
",",
"x",
"float64",
")",
"bool",
... | // Closest will return the point on the line which is closest to the Vec provided. | [
"Closest",
"will",
"return",
"the",
"point",
"on",
"the",
"line",
"which",
"is",
"closest",
"to",
"the",
"Vec",
"provided",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L235-L301 |
30,842 | faiface/pixel | geometry.go | Contains | func (l Line) Contains(v Vec) bool {
return l.Closest(v).Eq(v)
} | go | func (l Line) Contains(v Vec) bool {
return l.Closest(v).Eq(v)
} | [
"func",
"(",
"l",
"Line",
")",
"Contains",
"(",
"v",
"Vec",
")",
"bool",
"{",
"return",
"l",
".",
"Closest",
"(",
"v",
")",
".",
"Eq",
"(",
"v",
")",
"\n",
"}"
] | // Contains returns whether the provided Vec lies on the line. | [
"Contains",
"returns",
"whether",
"the",
"provided",
"Vec",
"lies",
"on",
"the",
"line",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L304-L306 |
30,843 | faiface/pixel | geometry.go | Intersect | func (l Line) Intersect(k Line) (Vec, bool) {
// Check if the lines are parallel
lDir := l.A.To(l.B)
kDir := k.A.To(k.B)
if lDir.X == kDir.X && lDir.Y == kDir.Y {
return ZV, false
}
// The lines intersect - but potentially not within the line segments.
// Get the intersection point for the lines if they were ... | go | func (l Line) Intersect(k Line) (Vec, bool) {
// Check if the lines are parallel
lDir := l.A.To(l.B)
kDir := k.A.To(k.B)
if lDir.X == kDir.X && lDir.Y == kDir.Y {
return ZV, false
}
// The lines intersect - but potentially not within the line segments.
// Get the intersection point for the lines if they were ... | [
"func",
"(",
"l",
"Line",
")",
"Intersect",
"(",
"k",
"Line",
")",
"(",
"Vec",
",",
"bool",
")",
"{",
"// Check if the lines are parallel",
"lDir",
":=",
"l",
".",
"A",
".",
"To",
"(",
"l",
".",
"B",
")",
"\n",
"kDir",
":=",
"k",
".",
"A",
".",
... | // Intersect will return the point of intersection for the two line segments. If the line segments do not intersect,
// this function will return the zero-vector and false. | [
"Intersect",
"will",
"return",
"the",
"point",
"of",
"intersection",
"for",
"the",
"two",
"line",
"segments",
".",
"If",
"the",
"line",
"segments",
"do",
"not",
"intersect",
"this",
"function",
"will",
"return",
"the",
"zero",
"-",
"vector",
"and",
"false",
... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L324-L372 |
30,844 | faiface/pixel | geometry.go | IntersectCircle | func (l Line) IntersectCircle(c Circle) Vec {
// Get the point on the line closest to the center of the circle.
closest := l.Closest(c.Center)
cirToClosest := c.Center.To(closest)
if cirToClosest.Len() >= c.Radius {
return ZV
}
return cirToClosest.Scaled(cirToClosest.Len() - c.Radius)
} | go | func (l Line) IntersectCircle(c Circle) Vec {
// Get the point on the line closest to the center of the circle.
closest := l.Closest(c.Center)
cirToClosest := c.Center.To(closest)
if cirToClosest.Len() >= c.Radius {
return ZV
}
return cirToClosest.Scaled(cirToClosest.Len() - c.Radius)
} | [
"func",
"(",
"l",
"Line",
")",
"IntersectCircle",
"(",
"c",
"Circle",
")",
"Vec",
"{",
"// Get the point on the line closest to the center of the circle.",
"closest",
":=",
"l",
".",
"Closest",
"(",
"c",
".",
"Center",
")",
"\n",
"cirToClosest",
":=",
"c",
".",
... | // IntersectCircle will return the shortest Vec such that moving the Line by that Vec will cause the Line and Circle
// to no longer intesect. If they do not intersect at all, this function will return a zero-vector. | [
"IntersectCircle",
"will",
"return",
"the",
"shortest",
"Vec",
"such",
"that",
"moving",
"the",
"Line",
"by",
"that",
"Vec",
"will",
"cause",
"the",
"Line",
"and",
"Circle",
"to",
"no",
"longer",
"intesect",
".",
"If",
"they",
"do",
"not",
"intersect",
"at... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L376-L386 |
30,845 | faiface/pixel | geometry.go | IntersectRect | func (l Line) IntersectRect(r Rect) Vec {
// Check if either end of the line segment are within the rectangle
if r.Contains(l.A) || r.Contains(l.B) {
// Use the Rect.Intersect to get minimal return value
rIntersect := l.Bounds().Intersect(r)
if rIntersect.H() > rIntersect.W() {
// Go vertical
return V(0, ... | go | func (l Line) IntersectRect(r Rect) Vec {
// Check if either end of the line segment are within the rectangle
if r.Contains(l.A) || r.Contains(l.B) {
// Use the Rect.Intersect to get minimal return value
rIntersect := l.Bounds().Intersect(r)
if rIntersect.H() > rIntersect.W() {
// Go vertical
return V(0, ... | [
"func",
"(",
"l",
"Line",
")",
"IntersectRect",
"(",
"r",
"Rect",
")",
"Vec",
"{",
"// Check if either end of the line segment are within the rectangle",
"if",
"r",
".",
"Contains",
"(",
"l",
".",
"A",
")",
"||",
"r",
".",
"Contains",
"(",
"l",
".",
"B",
"... | // IntersectRect will return the shortest Vec such that moving the Line by that Vec will cause the Line and Rect to
// no longer intesect. If they do not intersect at all, this function will return a zero-vector. | [
"IntersectRect",
"will",
"return",
"the",
"shortest",
"Vec",
"such",
"that",
"moving",
"the",
"Line",
"by",
"that",
"Vec",
"will",
"cause",
"the",
"Line",
"and",
"Rect",
"to",
"no",
"longer",
"intesect",
".",
"If",
"they",
"do",
"not",
"intersect",
"at",
... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L390-L425 |
30,846 | faiface/pixel | geometry.go | Len | func (l Line) Len() float64 {
return l.A.To(l.B).Len()
} | go | func (l Line) Len() float64 {
return l.A.To(l.B).Len()
} | [
"func",
"(",
"l",
"Line",
")",
"Len",
"(",
")",
"float64",
"{",
"return",
"l",
".",
"A",
".",
"To",
"(",
"l",
".",
"B",
")",
".",
"Len",
"(",
")",
"\n",
"}"
] | // Len returns the length of the line segment. | [
"Len",
"returns",
"the",
"length",
"of",
"the",
"line",
"segment",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L428-L430 |
30,847 | faiface/pixel | geometry.go | Moved | func (l Line) Moved(delta Vec) Line {
return Line{
A: l.A.Add(delta),
B: l.B.Add(delta),
}
} | go | func (l Line) Moved(delta Vec) Line {
return Line{
A: l.A.Add(delta),
B: l.B.Add(delta),
}
} | [
"func",
"(",
"l",
"Line",
")",
"Moved",
"(",
"delta",
"Vec",
")",
"Line",
"{",
"return",
"Line",
"{",
"A",
":",
"l",
".",
"A",
".",
"Add",
"(",
"delta",
")",
",",
"B",
":",
"l",
".",
"B",
".",
"Add",
"(",
"delta",
")",
",",
"}",
"\n",
"}"... | // Moved will return a line moved by the delta Vec provided. | [
"Moved",
"will",
"return",
"a",
"line",
"moved",
"by",
"the",
"delta",
"Vec",
"provided",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L433-L438 |
30,848 | faiface/pixel | geometry.go | Rotated | func (l Line) Rotated(around Vec, angle float64) Line {
// Move the line so we can use `Vec.Rotated`
lineShifted := l.Moved(around.Scaled(-1))
lineRotated := Line{
A: lineShifted.A.Rotated(angle),
B: lineShifted.B.Rotated(angle),
}
return lineRotated.Moved(around)
} | go | func (l Line) Rotated(around Vec, angle float64) Line {
// Move the line so we can use `Vec.Rotated`
lineShifted := l.Moved(around.Scaled(-1))
lineRotated := Line{
A: lineShifted.A.Rotated(angle),
B: lineShifted.B.Rotated(angle),
}
return lineRotated.Moved(around)
} | [
"func",
"(",
"l",
"Line",
")",
"Rotated",
"(",
"around",
"Vec",
",",
"angle",
"float64",
")",
"Line",
"{",
"// Move the line so we can use `Vec.Rotated`",
"lineShifted",
":=",
"l",
".",
"Moved",
"(",
"around",
".",
"Scaled",
"(",
"-",
"1",
")",
")",
"\n\n"... | // Rotated will rotate the line around the provided Vec. | [
"Rotated",
"will",
"rotate",
"the",
"line",
"around",
"the",
"provided",
"Vec",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L441-L451 |
30,849 | faiface/pixel | geometry.go | Scaled | func (l Line) Scaled(scale float64) Line {
return l.ScaledXY(l.Center(), scale)
} | go | func (l Line) Scaled(scale float64) Line {
return l.ScaledXY(l.Center(), scale)
} | [
"func",
"(",
"l",
"Line",
")",
"Scaled",
"(",
"scale",
"float64",
")",
"Line",
"{",
"return",
"l",
".",
"ScaledXY",
"(",
"l",
".",
"Center",
"(",
")",
",",
"scale",
")",
"\n",
"}"
] | // Scaled will return the line scaled around the center point. | [
"Scaled",
"will",
"return",
"the",
"line",
"scaled",
"around",
"the",
"center",
"point",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L454-L456 |
30,850 | faiface/pixel | geometry.go | ScaledXY | func (l Line) ScaledXY(around Vec, scale float64) Line {
toA := around.To(l.A).Scaled(scale)
toB := around.To(l.B).Scaled(scale)
return Line{
A: around.Add(toA),
B: around.Add(toB),
}
} | go | func (l Line) ScaledXY(around Vec, scale float64) Line {
toA := around.To(l.A).Scaled(scale)
toB := around.To(l.B).Scaled(scale)
return Line{
A: around.Add(toA),
B: around.Add(toB),
}
} | [
"func",
"(",
"l",
"Line",
")",
"ScaledXY",
"(",
"around",
"Vec",
",",
"scale",
"float64",
")",
"Line",
"{",
"toA",
":=",
"around",
".",
"To",
"(",
"l",
".",
"A",
")",
".",
"Scaled",
"(",
"scale",
")",
"\n",
"toB",
":=",
"around",
".",
"To",
"("... | // ScaledXY will return the line scaled around the Vec provided. | [
"ScaledXY",
"will",
"return",
"the",
"line",
"scaled",
"around",
"the",
"Vec",
"provided",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L459-L467 |
30,851 | faiface/pixel | geometry.go | R | func R(minX, minY, maxX, maxY float64) Rect {
return Rect{
Min: Vec{minX, minY},
Max: Vec{maxX, maxY},
}
} | go | func R(minX, minY, maxX, maxY float64) Rect {
return Rect{
Min: Vec{minX, minY},
Max: Vec{maxX, maxY},
}
} | [
"func",
"R",
"(",
"minX",
",",
"minY",
",",
"maxX",
",",
"maxY",
"float64",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"Min",
":",
"Vec",
"{",
"minX",
",",
"minY",
"}",
",",
"Max",
":",
"Vec",
"{",
"maxX",
",",
"maxY",
"}",
",",
"}",
"\n",
"}"
... | // R returns a new Rect with given the Min and Max coordinates.
//
// Note that the returned rectangle is not automatically normalized. | [
"R",
"returns",
"a",
"new",
"Rect",
"with",
"given",
"the",
"Min",
"and",
"Max",
"coordinates",
".",
"Note",
"that",
"the",
"returned",
"rectangle",
"is",
"not",
"automatically",
"normalized",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L485-L490 |
30,852 | faiface/pixel | geometry.go | Norm | func (r Rect) Norm() Rect {
return Rect{
Min: Vec{
math.Min(r.Min.X, r.Max.X),
math.Min(r.Min.Y, r.Max.Y),
},
Max: Vec{
math.Max(r.Min.X, r.Max.X),
math.Max(r.Min.Y, r.Max.Y),
},
}
} | go | func (r Rect) Norm() Rect {
return Rect{
Min: Vec{
math.Min(r.Min.X, r.Max.X),
math.Min(r.Min.Y, r.Max.Y),
},
Max: Vec{
math.Max(r.Min.X, r.Max.X),
math.Max(r.Min.Y, r.Max.Y),
},
}
} | [
"func",
"(",
"r",
"Rect",
")",
"Norm",
"(",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"Min",
":",
"Vec",
"{",
"math",
".",
"Min",
"(",
"r",
".",
"Min",
".",
"X",
",",
"r",
".",
"Max",
".",
"X",
")",
",",
"math",
".",
"Min",
"(",
"r",
".",
... | // Norm returns the Rect in normal form, such that Max is component-wise greater or equal than Min. | [
"Norm",
"returns",
"the",
"Rect",
"in",
"normal",
"form",
"such",
"that",
"Max",
"is",
"component",
"-",
"wise",
"greater",
"or",
"equal",
"than",
"Min",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L502-L513 |
30,853 | faiface/pixel | geometry.go | W | func (r Rect) W() float64 {
return r.Max.X - r.Min.X
} | go | func (r Rect) W() float64 {
return r.Max.X - r.Min.X
} | [
"func",
"(",
"r",
"Rect",
")",
"W",
"(",
")",
"float64",
"{",
"return",
"r",
".",
"Max",
".",
"X",
"-",
"r",
".",
"Min",
".",
"X",
"\n",
"}"
] | // W returns the width of the Rect. | [
"W",
"returns",
"the",
"width",
"of",
"the",
"Rect",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L516-L518 |
30,854 | faiface/pixel | geometry.go | H | func (r Rect) H() float64 {
return r.Max.Y - r.Min.Y
} | go | func (r Rect) H() float64 {
return r.Max.Y - r.Min.Y
} | [
"func",
"(",
"r",
"Rect",
")",
"H",
"(",
")",
"float64",
"{",
"return",
"r",
".",
"Max",
".",
"Y",
"-",
"r",
".",
"Min",
".",
"Y",
"\n",
"}"
] | // H returns the height of the Rect. | [
"H",
"returns",
"the",
"height",
"of",
"the",
"Rect",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L521-L523 |
30,855 | faiface/pixel | geometry.go | Edges | func (r Rect) Edges() [4]Line {
corners := r.Vertices()
return [4]Line{
{A: corners[0], B: corners[1]},
{A: corners[1], B: corners[2]},
{A: corners[2], B: corners[3]},
{A: corners[3], B: corners[0]},
}
} | go | func (r Rect) Edges() [4]Line {
corners := r.Vertices()
return [4]Line{
{A: corners[0], B: corners[1]},
{A: corners[1], B: corners[2]},
{A: corners[2], B: corners[3]},
{A: corners[3], B: corners[0]},
}
} | [
"func",
"(",
"r",
"Rect",
")",
"Edges",
"(",
")",
"[",
"4",
"]",
"Line",
"{",
"corners",
":=",
"r",
".",
"Vertices",
"(",
")",
"\n\n",
"return",
"[",
"4",
"]",
"Line",
"{",
"{",
"A",
":",
"corners",
"[",
"0",
"]",
",",
"B",
":",
"corners",
... | // Edges will return the four lines which make up the edges of the rectangle. | [
"Edges",
"will",
"return",
"the",
"four",
"lines",
"which",
"make",
"up",
"the",
"edges",
"of",
"the",
"rectangle",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L536-L545 |
30,856 | faiface/pixel | geometry.go | ResizedMin | func (r Rect) ResizedMin(size Vec) Rect {
return Rect{
Min: r.Min,
Max: r.Min.Add(size),
}
} | go | func (r Rect) ResizedMin(size Vec) Rect {
return Rect{
Min: r.Min,
Max: r.Min.Add(size),
}
} | [
"func",
"(",
"r",
"Rect",
")",
"ResizedMin",
"(",
"size",
"Vec",
")",
"Rect",
"{",
"return",
"Rect",
"{",
"Min",
":",
"r",
".",
"Min",
",",
"Max",
":",
"r",
".",
"Min",
".",
"Add",
"(",
"size",
")",
",",
"}",
"\n",
"}"
] | // ResizedMin returns the Rect resized to the given size while keeping the position of the Rect's
// Min.
//
// Sizes of zero area are safe here. | [
"ResizedMin",
"returns",
"the",
"Rect",
"resized",
"to",
"the",
"given",
"size",
"while",
"keeping",
"the",
"position",
"of",
"the",
"Rect",
"s",
"Min",
".",
"Sizes",
"of",
"zero",
"area",
"are",
"safe",
"here",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L584-L589 |
30,857 | faiface/pixel | geometry.go | Union | func (r Rect) Union(s Rect) Rect {
return R(
math.Min(r.Min.X, s.Min.X),
math.Min(r.Min.Y, s.Min.Y),
math.Max(r.Max.X, s.Max.X),
math.Max(r.Max.Y, s.Max.Y),
)
} | go | func (r Rect) Union(s Rect) Rect {
return R(
math.Min(r.Min.X, s.Min.X),
math.Min(r.Min.Y, s.Min.Y),
math.Max(r.Max.X, s.Max.X),
math.Max(r.Max.Y, s.Max.Y),
)
} | [
"func",
"(",
"r",
"Rect",
")",
"Union",
"(",
"s",
"Rect",
")",
"Rect",
"{",
"return",
"R",
"(",
"math",
".",
"Min",
"(",
"r",
".",
"Min",
".",
"X",
",",
"s",
".",
"Min",
".",
"X",
")",
",",
"math",
".",
"Min",
"(",
"r",
".",
"Min",
".",
... | // Union returns the minimal Rect which covers both r and s. Rects r and s must be normalized. | [
"Union",
"returns",
"the",
"minimal",
"Rect",
"which",
"covers",
"both",
"r",
"and",
"s",
".",
"Rects",
"r",
"and",
"s",
"must",
"be",
"normalized",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L597-L604 |
30,858 | faiface/pixel | geometry.go | IntersectionPoints | func (r Rect) IntersectionPoints(l Line) []Vec {
// Use map keys to ensure unique points
pointMap := make(map[Vec]struct{})
for _, edge := range r.Edges() {
if intersect, ok := l.Intersect(edge); ok {
pointMap[intersect] = struct{}{}
}
}
points := make([]Vec, 0, len(pointMap))
for point := range pointMap... | go | func (r Rect) IntersectionPoints(l Line) []Vec {
// Use map keys to ensure unique points
pointMap := make(map[Vec]struct{})
for _, edge := range r.Edges() {
if intersect, ok := l.Intersect(edge); ok {
pointMap[intersect] = struct{}{}
}
}
points := make([]Vec, 0, len(pointMap))
for point := range pointMap... | [
"func",
"(",
"r",
"Rect",
")",
"IntersectionPoints",
"(",
"l",
"Line",
")",
"[",
"]",
"Vec",
"{",
"// Use map keys to ensure unique points",
"pointMap",
":=",
"make",
"(",
"map",
"[",
"Vec",
"]",
"struct",
"{",
"}",
")",
"\n\n",
"for",
"_",
",",
"edge",
... | // IntersectionPoints returns all the points where the Rect intersects with the line provided. This can be zero, one or
// two points, depending on the location of the shapes. The points of intersection will be returned in order of
// closest-to-l.A to closest-to-l.B. | [
"IntersectionPoints",
"returns",
"all",
"the",
"points",
"where",
"the",
"Rect",
"intersects",
"with",
"the",
"line",
"provided",
".",
"This",
"can",
"be",
"zero",
"one",
"or",
"two",
"points",
"depending",
"on",
"the",
"location",
"of",
"the",
"shapes",
"."... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L642-L665 |
30,859 | faiface/pixel | geometry.go | Vertices | func (r Rect) Vertices() [4]Vec {
return [4]Vec{
r.Min,
V(r.Min.X, r.Max.Y),
r.Max,
V(r.Max.X, r.Min.Y),
}
} | go | func (r Rect) Vertices() [4]Vec {
return [4]Vec{
r.Min,
V(r.Min.X, r.Max.Y),
r.Max,
V(r.Max.X, r.Min.Y),
}
} | [
"func",
"(",
"r",
"Rect",
")",
"Vertices",
"(",
")",
"[",
"4",
"]",
"Vec",
"{",
"return",
"[",
"4",
"]",
"Vec",
"{",
"r",
".",
"Min",
",",
"V",
"(",
"r",
".",
"Min",
".",
"X",
",",
"r",
".",
"Max",
".",
"Y",
")",
",",
"r",
".",
"Max",
... | // Vertices returns a slice of the four corners which make up the rectangle. | [
"Vertices",
"returns",
"a",
"slice",
"of",
"the",
"four",
"corners",
"which",
"make",
"up",
"the",
"rectangle",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L668-L675 |
30,860 | faiface/pixel | geometry.go | C | func C(center Vec, radius float64) Circle {
return Circle{
Center: center,
Radius: radius,
}
} | go | func C(center Vec, radius float64) Circle {
return Circle{
Center: center,
Radius: radius,
}
} | [
"func",
"C",
"(",
"center",
"Vec",
",",
"radius",
"float64",
")",
"Circle",
"{",
"return",
"Circle",
"{",
"Center",
":",
"center",
",",
"Radius",
":",
"radius",
",",
"}",
"\n",
"}"
] | // C returns a new Circle with the given radius and center coordinates.
//
// Note that a negative radius is valid. | [
"C",
"returns",
"a",
"new",
"Circle",
"with",
"the",
"given",
"radius",
"and",
"center",
"coordinates",
".",
"Note",
"that",
"a",
"negative",
"radius",
"is",
"valid",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L688-L693 |
30,861 | faiface/pixel | geometry.go | Area | func (c Circle) Area() float64 {
return math.Pi * math.Pow(c.Radius, 2)
} | go | func (c Circle) Area() float64 {
return math.Pi * math.Pow(c.Radius, 2)
} | [
"func",
"(",
"c",
"Circle",
")",
"Area",
"(",
")",
"float64",
"{",
"return",
"math",
".",
"Pi",
"*",
"math",
".",
"Pow",
"(",
"c",
".",
"Radius",
",",
"2",
")",
"\n",
"}"
] | // Area returns the area of the Circle. | [
"Area",
"returns",
"the",
"area",
"of",
"the",
"Circle",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L716-L718 |
30,862 | faiface/pixel | geometry.go | Moved | func (c Circle) Moved(delta Vec) Circle {
return Circle{
Center: c.Center.Add(delta),
Radius: c.Radius,
}
} | go | func (c Circle) Moved(delta Vec) Circle {
return Circle{
Center: c.Center.Add(delta),
Radius: c.Radius,
}
} | [
"func",
"(",
"c",
"Circle",
")",
"Moved",
"(",
"delta",
"Vec",
")",
"Circle",
"{",
"return",
"Circle",
"{",
"Center",
":",
"c",
".",
"Center",
".",
"Add",
"(",
"delta",
")",
",",
"Radius",
":",
"c",
".",
"Radius",
",",
"}",
"\n",
"}"
] | // Moved returns the Circle moved by the given vector delta. | [
"Moved",
"returns",
"the",
"Circle",
"moved",
"by",
"the",
"given",
"vector",
"delta",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L721-L726 |
30,863 | faiface/pixel | geometry.go | maxCircle | func maxCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return d
}
return c
} | go | func maxCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return d
}
return c
} | [
"func",
"maxCircle",
"(",
"c",
",",
"d",
"Circle",
")",
"Circle",
"{",
"if",
"c",
".",
"Radius",
"<",
"d",
".",
"Radius",
"{",
"return",
"d",
"\n",
"}",
"\n",
"return",
"c",
"\n",
"}"
] | // maxCircle will return the larger circle based on the radius. | [
"maxCircle",
"will",
"return",
"the",
"larger",
"circle",
"based",
"on",
"the",
"radius",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L753-L758 |
30,864 | faiface/pixel | geometry.go | minCircle | func minCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return c
}
return d
} | go | func minCircle(c, d Circle) Circle {
if c.Radius < d.Radius {
return c
}
return d
} | [
"func",
"minCircle",
"(",
"c",
",",
"d",
"Circle",
")",
"Circle",
"{",
"if",
"c",
".",
"Radius",
"<",
"d",
".",
"Radius",
"{",
"return",
"c",
"\n",
"}",
"\n",
"return",
"d",
"\n",
"}"
] | // minCircle will return the smaller circle based on the radius. | [
"minCircle",
"will",
"return",
"the",
"smaller",
"circle",
"based",
"on",
"the",
"radius",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L761-L766 |
30,865 | faiface/pixel | geometry.go | Union | func (c Circle) Union(d Circle) Circle {
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
// Get distance between centers
dist := c.Center.To(d.Center).Len()
// If the bigger Circle encompasses the smaller one, we have the result
if dist+smallerC.Radius <= biggerC.Radius {
re... | go | func (c Circle) Union(d Circle) Circle {
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
// Get distance between centers
dist := c.Center.To(d.Center).Len()
// If the bigger Circle encompasses the smaller one, we have the result
if dist+smallerC.Radius <= biggerC.Radius {
re... | [
"func",
"(",
"c",
"Circle",
")",
"Union",
"(",
"d",
"Circle",
")",
"Circle",
"{",
"biggerC",
":=",
"maxCircle",
"(",
"c",
".",
"Norm",
"(",
")",
",",
"d",
".",
"Norm",
"(",
")",
")",
"\n",
"smallerC",
":=",
"minCircle",
"(",
"c",
".",
"Norm",
"... | // Union returns the minimal Circle which covers both `c` and `d`. | [
"Union",
"returns",
"the",
"minimal",
"Circle",
"which",
"covers",
"both",
"c",
"and",
"d",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L769-L792 |
30,866 | faiface/pixel | geometry.go | Intersect | func (c Circle) Intersect(d Circle) Circle {
// Check if one of the circles encompasses the other; if so, return that one
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius {
return biggerC
}
// Calcu... | go | func (c Circle) Intersect(d Circle) Circle {
// Check if one of the circles encompasses the other; if so, return that one
biggerC := maxCircle(c.Norm(), d.Norm())
smallerC := minCircle(c.Norm(), d.Norm())
if biggerC.Radius >= biggerC.Center.To(smallerC.Center).Len()+smallerC.Radius {
return biggerC
}
// Calcu... | [
"func",
"(",
"c",
"Circle",
")",
"Intersect",
"(",
"d",
"Circle",
")",
"Circle",
"{",
"// Check if one of the circles encompasses the other; if so, return that one",
"biggerC",
":=",
"maxCircle",
"(",
"c",
".",
"Norm",
"(",
")",
",",
"d",
".",
"Norm",
"(",
")",
... | // Intersect returns the maximal Circle which is covered by both `c` and `d`.
//
// If `c` and `d` don't overlap, this function returns a zero-sized circle at the centerpoint between the two Circle's
// centers. | [
"Intersect",
"returns",
"the",
"maximal",
"Circle",
"which",
"is",
"covered",
"by",
"both",
"c",
"and",
"d",
".",
"If",
"c",
"and",
"d",
"don",
"t",
"overlap",
"this",
"function",
"returns",
"a",
"zero",
"-",
"sized",
"circle",
"at",
"the",
"centerpoint"... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L798-L828 |
30,867 | faiface/pixel | geometry.go | Moved | func (m Matrix) Moved(delta Vec) Matrix {
m[4], m[5] = m[4]+delta.X, m[5]+delta.Y
return m
} | go | func (m Matrix) Moved(delta Vec) Matrix {
m[4], m[5] = m[4]+delta.X, m[5]+delta.Y
return m
} | [
"func",
"(",
"m",
"Matrix",
")",
"Moved",
"(",
"delta",
"Vec",
")",
"Matrix",
"{",
"m",
"[",
"4",
"]",
",",
"m",
"[",
"5",
"]",
"=",
"m",
"[",
"4",
"]",
"+",
"delta",
".",
"X",
",",
"m",
"[",
"5",
"]",
"+",
"delta",
".",
"Y",
"\n",
"ret... | // Moved moves everything by the delta vector. | [
"Moved",
"moves",
"everything",
"by",
"the",
"delta",
"vector",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L1038-L1041 |
30,868 | faiface/pixel | geometry.go | ScaledXY | func (m Matrix) ScaledXY(around Vec, scale Vec) Matrix {
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m[0], m[2], m[4] = m[0]*scale.X, m[2]*scale.X, m[4]*scale.X
m[1], m[3], m[5] = m[1]*scale.Y, m[3]*scale.Y, m[5]*scale.Y
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | go | func (m Matrix) ScaledXY(around Vec, scale Vec) Matrix {
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m[0], m[2], m[4] = m[0]*scale.X, m[2]*scale.X, m[4]*scale.X
m[1], m[3], m[5] = m[1]*scale.Y, m[3]*scale.Y, m[5]*scale.Y
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | [
"func",
"(",
"m",
"Matrix",
")",
"ScaledXY",
"(",
"around",
"Vec",
",",
"scale",
"Vec",
")",
"Matrix",
"{",
"m",
"[",
"4",
"]",
",",
"m",
"[",
"5",
"]",
"=",
"m",
"[",
"4",
"]",
"-",
"around",
".",
"X",
",",
"m",
"[",
"5",
"]",
"-",
"arou... | // ScaledXY scales everything around a given point by the scale factor in each axis respectively. | [
"ScaledXY",
"scales",
"everything",
"around",
"a",
"given",
"point",
"by",
"the",
"scale",
"factor",
"in",
"each",
"axis",
"respectively",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L1044-L1050 |
30,869 | faiface/pixel | geometry.go | Scaled | func (m Matrix) Scaled(around Vec, scale float64) Matrix {
return m.ScaledXY(around, V(scale, scale))
} | go | func (m Matrix) Scaled(around Vec, scale float64) Matrix {
return m.ScaledXY(around, V(scale, scale))
} | [
"func",
"(",
"m",
"Matrix",
")",
"Scaled",
"(",
"around",
"Vec",
",",
"scale",
"float64",
")",
"Matrix",
"{",
"return",
"m",
".",
"ScaledXY",
"(",
"around",
",",
"V",
"(",
"scale",
",",
"scale",
")",
")",
"\n",
"}"
] | // Scaled scales everything around a given point by the scale factor. | [
"Scaled",
"scales",
"everything",
"around",
"a",
"given",
"point",
"by",
"the",
"scale",
"factor",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L1053-L1055 |
30,870 | faiface/pixel | geometry.go | Rotated | func (m Matrix) Rotated(around Vec, angle float64) Matrix {
sint, cost := math.Sincos(angle)
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m = m.Chained(Matrix{cost, sint, -sint, cost, 0, 0})
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | go | func (m Matrix) Rotated(around Vec, angle float64) Matrix {
sint, cost := math.Sincos(angle)
m[4], m[5] = m[4]-around.X, m[5]-around.Y
m = m.Chained(Matrix{cost, sint, -sint, cost, 0, 0})
m[4], m[5] = m[4]+around.X, m[5]+around.Y
return m
} | [
"func",
"(",
"m",
"Matrix",
")",
"Rotated",
"(",
"around",
"Vec",
",",
"angle",
"float64",
")",
"Matrix",
"{",
"sint",
",",
"cost",
":=",
"math",
".",
"Sincos",
"(",
"angle",
")",
"\n",
"m",
"[",
"4",
"]",
",",
"m",
"[",
"5",
"]",
"=",
"m",
"... | // Rotated rotates everything around a given point by the given angle in radians. | [
"Rotated",
"rotates",
"everything",
"around",
"a",
"given",
"point",
"by",
"the",
"given",
"angle",
"in",
"radians",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L1058-L1064 |
30,871 | faiface/pixel | geometry.go | Chained | func (m Matrix) Chained(next Matrix) Matrix {
return Matrix{
next[0]*m[0] + next[2]*m[1],
next[1]*m[0] + next[3]*m[1],
next[0]*m[2] + next[2]*m[3],
next[1]*m[2] + next[3]*m[3],
next[0]*m[4] + next[2]*m[5] + next[4],
next[1]*m[4] + next[3]*m[5] + next[5],
}
} | go | func (m Matrix) Chained(next Matrix) Matrix {
return Matrix{
next[0]*m[0] + next[2]*m[1],
next[1]*m[0] + next[3]*m[1],
next[0]*m[2] + next[2]*m[3],
next[1]*m[2] + next[3]*m[3],
next[0]*m[4] + next[2]*m[5] + next[4],
next[1]*m[4] + next[3]*m[5] + next[5],
}
} | [
"func",
"(",
"m",
"Matrix",
")",
"Chained",
"(",
"next",
"Matrix",
")",
"Matrix",
"{",
"return",
"Matrix",
"{",
"next",
"[",
"0",
"]",
"*",
"m",
"[",
"0",
"]",
"+",
"next",
"[",
"2",
"]",
"*",
"m",
"[",
"1",
"]",
",",
"next",
"[",
"1",
"]",... | // Chained adds another Matrix to this one. All tranformations by the next Matrix will be applied
// after the transformations of this Matrix. | [
"Chained",
"adds",
"another",
"Matrix",
"to",
"this",
"one",
".",
"All",
"tranformations",
"by",
"the",
"next",
"Matrix",
"will",
"be",
"applied",
"after",
"the",
"transformations",
"of",
"this",
"Matrix",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/geometry.go#L1068-L1077 |
30,872 | faiface/pixel | text/text.go | BoundsOf | func (txt *Text) BoundsOf(s string) pixel.Rect {
dot := txt.Dot
prevR := txt.prevR
bounds := pixel.Rect{}
for _, r := range s {
var control bool
dot, control = txt.controlRune(r, dot)
if control {
continue
}
var b pixel.Rect
_, _, b, dot = txt.Atlas().DrawRune(prevR, r, dot)
if bounds.W()*bounds... | go | func (txt *Text) BoundsOf(s string) pixel.Rect {
dot := txt.Dot
prevR := txt.prevR
bounds := pixel.Rect{}
for _, r := range s {
var control bool
dot, control = txt.controlRune(r, dot)
if control {
continue
}
var b pixel.Rect
_, _, b, dot = txt.Atlas().DrawRune(prevR, r, dot)
if bounds.W()*bounds... | [
"func",
"(",
"txt",
"*",
"Text",
")",
"BoundsOf",
"(",
"s",
"string",
")",
"pixel",
".",
"Rect",
"{",
"dot",
":=",
"txt",
".",
"Dot",
"\n",
"prevR",
":=",
"txt",
".",
"prevR",
"\n",
"bounds",
":=",
"pixel",
".",
"Rect",
"{",
"}",
"\n\n",
"for",
... | // BoundsOf returns the bounding box of s if it was to be written to the Text right now. | [
"BoundsOf",
"returns",
"the",
"bounding",
"box",
"of",
"s",
"if",
"it",
"was",
"to",
"be",
"written",
"to",
"the",
"Text",
"right",
"now",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/text.go#L158-L183 |
30,873 | faiface/pixel | text/text.go | Clear | func (txt *Text) Clear() {
txt.prevR = -1
txt.bounds = pixel.Rect{}
txt.tris.SetLen(0)
txt.dirty = true
txt.Dot = txt.Orig
} | go | func (txt *Text) Clear() {
txt.prevR = -1
txt.bounds = pixel.Rect{}
txt.tris.SetLen(0)
txt.dirty = true
txt.Dot = txt.Orig
} | [
"func",
"(",
"txt",
"*",
"Text",
")",
"Clear",
"(",
")",
"{",
"txt",
".",
"prevR",
"=",
"-",
"1",
"\n",
"txt",
".",
"bounds",
"=",
"pixel",
".",
"Rect",
"{",
"}",
"\n",
"txt",
".",
"tris",
".",
"SetLen",
"(",
"0",
")",
"\n",
"txt",
".",
"di... | // Clear removes all written text from the Text. The Dot field is reset to Orig. | [
"Clear",
"removes",
"all",
"written",
"text",
"from",
"the",
"Text",
".",
"The",
"Dot",
"field",
"is",
"reset",
"to",
"Orig",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/text.go#L186-L192 |
30,874 | faiface/pixel | text/text.go | WriteByte | func (txt *Text) WriteByte(c byte) error {
txt.buf = append(txt.buf, c)
txt.drawBuf()
return nil
} | go | func (txt *Text) WriteByte(c byte) error {
txt.buf = append(txt.buf, c)
txt.drawBuf()
return nil
} | [
"func",
"(",
"txt",
"*",
"Text",
")",
"WriteByte",
"(",
"c",
"byte",
")",
"error",
"{",
"txt",
".",
"buf",
"=",
"append",
"(",
"txt",
".",
"buf",
",",
"c",
")",
"\n",
"txt",
".",
"drawBuf",
"(",
")",
"\n",
"return",
"nil",
"\n",
"}"
] | // WriteByte writes a byte to the Text. This method never fails, always returns nil.
//
// Writing a multi-byte rune byte-by-byte is perfectly supported. | [
"WriteByte",
"writes",
"a",
"byte",
"to",
"the",
"Text",
".",
"This",
"method",
"never",
"fails",
"always",
"returns",
"nil",
".",
"Writing",
"a",
"multi",
"-",
"byte",
"rune",
"byte",
"-",
"by",
"-",
"byte",
"is",
"perfectly",
"supported",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/text.go#L211-L215 |
30,875 | faiface/pixel | text/text.go | Draw | func (txt *Text) Draw(t pixel.Target, matrix pixel.Matrix) {
txt.DrawColorMask(t, matrix, nil)
} | go | func (txt *Text) Draw(t pixel.Target, matrix pixel.Matrix) {
txt.DrawColorMask(t, matrix, nil)
} | [
"func",
"(",
"txt",
"*",
"Text",
")",
"Draw",
"(",
"t",
"pixel",
".",
"Target",
",",
"matrix",
"pixel",
".",
"Matrix",
")",
"{",
"txt",
".",
"DrawColorMask",
"(",
"t",
",",
"matrix",
",",
"nil",
")",
"\n",
"}"
] | // Draw draws all text written to the Text to the provided Target. The text is transformed by the
// provided Matrix.
//
// This method is equivalent to calling DrawColorMask with nil color mask.
//
// If there's a lot of text written to the Text, changing a matrix or a color mask often might hurt
// performance. Consi... | [
"Draw",
"draws",
"all",
"text",
"written",
"to",
"the",
"Text",
"to",
"the",
"provided",
"Target",
".",
"The",
"text",
"is",
"transformed",
"by",
"the",
"provided",
"Matrix",
".",
"This",
"method",
"is",
"equivalent",
"to",
"calling",
"DrawColorMask",
"with"... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/text.go#L233-L235 |
30,876 | faiface/pixel | text/text.go | DrawColorMask | func (txt *Text) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color) {
if matrix != txt.mat {
txt.mat = matrix
txt.dirty = true
}
if mask == nil {
mask = pixel.Alpha(1)
}
rgba := pixel.ToRGBA(mask)
if rgba != txt.col {
txt.col = rgba
txt.dirty = true
}
if txt.dirty {
txt.trans.SetL... | go | func (txt *Text) DrawColorMask(t pixel.Target, matrix pixel.Matrix, mask color.Color) {
if matrix != txt.mat {
txt.mat = matrix
txt.dirty = true
}
if mask == nil {
mask = pixel.Alpha(1)
}
rgba := pixel.ToRGBA(mask)
if rgba != txt.col {
txt.col = rgba
txt.dirty = true
}
if txt.dirty {
txt.trans.SetL... | [
"func",
"(",
"txt",
"*",
"Text",
")",
"DrawColorMask",
"(",
"t",
"pixel",
".",
"Target",
",",
"matrix",
"pixel",
".",
"Matrix",
",",
"mask",
"color",
".",
"Color",
")",
"{",
"if",
"matrix",
"!=",
"txt",
".",
"mat",
"{",
"txt",
".",
"mat",
"=",
"m... | // DrawColorMask draws all text written to the Text to the provided Target. The text is transformed
// by the provided Matrix and masked by the provided color mask.
//
// If there's a lot of text written to the Text, changing a matrix or a color mask often might hurt
// performance. Consider using your Target's SetMatr... | [
"DrawColorMask",
"draws",
"all",
"text",
"written",
"to",
"the",
"Text",
"to",
"the",
"provided",
"Target",
".",
"The",
"text",
"is",
"transformed",
"by",
"the",
"provided",
"Matrix",
"and",
"masked",
"by",
"the",
"provided",
"color",
"mask",
".",
"If",
"t... | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/text.go#L242-L270 |
30,877 | faiface/pixel | data.go | Slice | func (td *TrianglesData) Slice(i, j int) Triangles {
s := TrianglesData((*td)[i:j])
return &s
} | go | func (td *TrianglesData) Slice(i, j int) Triangles {
s := TrianglesData((*td)[i:j])
return &s
} | [
"func",
"(",
"td",
"*",
"TrianglesData",
")",
"Slice",
"(",
"i",
",",
"j",
"int",
")",
"Triangles",
"{",
"s",
":=",
"TrianglesData",
"(",
"(",
"*",
"td",
")",
"[",
"i",
":",
"j",
"]",
")",
"\n",
"return",
"&",
"s",
"\n",
"}"
] | // Slice returns a sub-Triangles of this TrianglesData. | [
"Slice",
"returns",
"a",
"sub",
"-",
"Triangles",
"of",
"this",
"TrianglesData",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L64-L67 |
30,878 | faiface/pixel | data.go | Update | func (td *TrianglesData) Update(t Triangles) {
if td.Len() != t.Len() {
panic(fmt.Errorf("(%T).Update: invalid triangles length", td))
}
td.updateData(t)
} | go | func (td *TrianglesData) Update(t Triangles) {
if td.Len() != t.Len() {
panic(fmt.Errorf("(%T).Update: invalid triangles length", td))
}
td.updateData(t)
} | [
"func",
"(",
"td",
"*",
"TrianglesData",
")",
"Update",
"(",
"t",
"Triangles",
")",
"{",
"if",
"td",
".",
"Len",
"(",
")",
"!=",
"t",
".",
"Len",
"(",
")",
"{",
"panic",
"(",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
",",
"td",
")",
")",
"\n",
... | // Update copies vertex properties from the supplied Triangles into this TrianglesData.
//
// TrianglesPosition, TrianglesColor and TrianglesTexture are supported. | [
"Update",
"copies",
"vertex",
"properties",
"from",
"the",
"supplied",
"Triangles",
"into",
"this",
"TrianglesData",
".",
"TrianglesPosition",
"TrianglesColor",
"and",
"TrianglesTexture",
"are",
"supported",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L97-L102 |
30,879 | faiface/pixel | data.go | Copy | func (td *TrianglesData) Copy() Triangles {
copyTd := MakeTrianglesData(td.Len())
copyTd.Update(td)
return copyTd
} | go | func (td *TrianglesData) Copy() Triangles {
copyTd := MakeTrianglesData(td.Len())
copyTd.Update(td)
return copyTd
} | [
"func",
"(",
"td",
"*",
"TrianglesData",
")",
"Copy",
"(",
")",
"Triangles",
"{",
"copyTd",
":=",
"MakeTrianglesData",
"(",
"td",
".",
"Len",
"(",
")",
")",
"\n",
"copyTd",
".",
"Update",
"(",
"td",
")",
"\n",
"return",
"copyTd",
"\n",
"}"
] | // Copy returns an exact independent copy of this TrianglesData. | [
"Copy",
"returns",
"an",
"exact",
"independent",
"copy",
"of",
"this",
"TrianglesData",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L105-L109 |
30,880 | faiface/pixel | data.go | Picture | func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64) {
return (*td)[i].Picture, (*td)[i].Intensity
} | go | func (td *TrianglesData) Picture(i int) (pic Vec, intensity float64) {
return (*td)[i].Picture, (*td)[i].Intensity
} | [
"func",
"(",
"td",
"*",
"TrianglesData",
")",
"Picture",
"(",
"i",
"int",
")",
"(",
"pic",
"Vec",
",",
"intensity",
"float64",
")",
"{",
"return",
"(",
"*",
"td",
")",
"[",
"i",
"]",
".",
"Picture",
",",
"(",
"*",
"td",
")",
"[",
"i",
"]",
".... | // Picture returns the picture property of i-th vertex. | [
"Picture",
"returns",
"the",
"picture",
"property",
"of",
"i",
"-",
"th",
"vertex",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L122-L124 |
30,881 | faiface/pixel | data.go | MakePictureData | func MakePictureData(rect Rect) *PictureData {
w := int(math.Ceil(rect.Max.X)) - int(math.Floor(rect.Min.X))
h := int(math.Ceil(rect.Max.Y)) - int(math.Floor(rect.Min.Y))
pd := &PictureData{
Stride: w,
Rect: rect,
}
pd.Pix = make([]color.RGBA, w*h)
return pd
} | go | func MakePictureData(rect Rect) *PictureData {
w := int(math.Ceil(rect.Max.X)) - int(math.Floor(rect.Min.X))
h := int(math.Ceil(rect.Max.Y)) - int(math.Floor(rect.Min.Y))
pd := &PictureData{
Stride: w,
Rect: rect,
}
pd.Pix = make([]color.RGBA, w*h)
return pd
} | [
"func",
"MakePictureData",
"(",
"rect",
"Rect",
")",
"*",
"PictureData",
"{",
"w",
":=",
"int",
"(",
"math",
".",
"Ceil",
"(",
"rect",
".",
"Max",
".",
"X",
")",
")",
"-",
"int",
"(",
"math",
".",
"Floor",
"(",
"rect",
".",
"Min",
".",
"X",
")"... | // MakePictureData creates a zero-initialized PictureData covering the given rectangle. | [
"MakePictureData",
"creates",
"a",
"zero",
"-",
"initialized",
"PictureData",
"covering",
"the",
"given",
"rectangle",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L144-L153 |
30,882 | faiface/pixel | data.go | PictureDataFromImage | func PictureDataFromImage(img image.Image) *PictureData {
rgba := image.NewRGBA(img.Bounds())
draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src)
verticalFlip(rgba)
pd := MakePictureData(R(
float64(rgba.Bounds().Min.X),
float64(rgba.Bounds().Min.Y),
float64(rgba.Bounds().Max.X),
float64(rgba.B... | go | func PictureDataFromImage(img image.Image) *PictureData {
rgba := image.NewRGBA(img.Bounds())
draw.Draw(rgba, rgba.Bounds(), img, img.Bounds().Min, draw.Src)
verticalFlip(rgba)
pd := MakePictureData(R(
float64(rgba.Bounds().Min.X),
float64(rgba.Bounds().Min.Y),
float64(rgba.Bounds().Max.X),
float64(rgba.B... | [
"func",
"PictureDataFromImage",
"(",
"img",
"image",
".",
"Image",
")",
"*",
"PictureData",
"{",
"rgba",
":=",
"image",
".",
"NewRGBA",
"(",
"img",
".",
"Bounds",
"(",
")",
")",
"\n",
"draw",
".",
"Draw",
"(",
"rgba",
",",
"rgba",
".",
"Bounds",
"(",... | // PictureDataFromImage converts an image.Image into PictureData.
//
// The resulting PictureData's Bounds will be the equivalent of the supplied image.Image's Bounds. | [
"PictureDataFromImage",
"converts",
"an",
"image",
".",
"Image",
"into",
"PictureData",
".",
"The",
"resulting",
"PictureData",
"s",
"Bounds",
"will",
"be",
"the",
"equivalent",
"of",
"the",
"supplied",
"image",
".",
"Image",
"s",
"Bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L173-L194 |
30,883 | faiface/pixel | data.go | Image | func (pd *PictureData) Image() *image.RGBA {
bounds := image.Rect(
int(math.Floor(pd.Rect.Min.X)),
int(math.Floor(pd.Rect.Min.Y)),
int(math.Ceil(pd.Rect.Max.X)),
int(math.Ceil(pd.Rect.Max.Y)),
)
rgba := image.NewRGBA(bounds)
i := 0
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
for x := bounds.Min.X; x ... | go | func (pd *PictureData) Image() *image.RGBA {
bounds := image.Rect(
int(math.Floor(pd.Rect.Min.X)),
int(math.Floor(pd.Rect.Min.Y)),
int(math.Ceil(pd.Rect.Max.X)),
int(math.Ceil(pd.Rect.Max.Y)),
)
rgba := image.NewRGBA(bounds)
i := 0
for y := bounds.Min.Y; y < bounds.Max.Y; y++ {
for x := bounds.Min.X; x ... | [
"func",
"(",
"pd",
"*",
"PictureData",
")",
"Image",
"(",
")",
"*",
"image",
".",
"RGBA",
"{",
"bounds",
":=",
"image",
".",
"Rect",
"(",
"int",
"(",
"math",
".",
"Floor",
"(",
"pd",
".",
"Rect",
".",
"Min",
".",
"X",
")",
")",
",",
"int",
"(... | // Image converts PictureData into an image.RGBA.
//
// The resulting image.RGBA's Bounds will be equivalent of the PictureData's Bounds. | [
"Image",
"converts",
"PictureData",
"into",
"an",
"image",
".",
"RGBA",
".",
"The",
"resulting",
"image",
".",
"RGBA",
"s",
"Bounds",
"will",
"be",
"equivalent",
"of",
"the",
"PictureData",
"s",
"Bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L233-L257 |
30,884 | faiface/pixel | data.go | Index | func (pd *PictureData) Index(at Vec) int {
at = at.Sub(pd.Rect.Min.Map(math.Floor))
x, y := int(at.X), int(at.Y)
return y*pd.Stride + x
} | go | func (pd *PictureData) Index(at Vec) int {
at = at.Sub(pd.Rect.Min.Map(math.Floor))
x, y := int(at.X), int(at.Y)
return y*pd.Stride + x
} | [
"func",
"(",
"pd",
"*",
"PictureData",
")",
"Index",
"(",
"at",
"Vec",
")",
"int",
"{",
"at",
"=",
"at",
".",
"Sub",
"(",
"pd",
".",
"Rect",
".",
"Min",
".",
"Map",
"(",
"math",
".",
"Floor",
")",
")",
"\n",
"x",
",",
"y",
":=",
"int",
"(",... | // Index returns the index of the pixel at the specified position inside the Pix slice. | [
"Index",
"returns",
"the",
"index",
"of",
"the",
"pixel",
"at",
"the",
"specified",
"position",
"inside",
"the",
"Pix",
"slice",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L260-L264 |
30,885 | faiface/pixel | data.go | Color | func (pd *PictureData) Color(at Vec) RGBA {
if !pd.Rect.Contains(at) {
return RGBA{0, 0, 0, 0}
}
return ToRGBA(pd.Pix[pd.Index(at)])
} | go | func (pd *PictureData) Color(at Vec) RGBA {
if !pd.Rect.Contains(at) {
return RGBA{0, 0, 0, 0}
}
return ToRGBA(pd.Pix[pd.Index(at)])
} | [
"func",
"(",
"pd",
"*",
"PictureData",
")",
"Color",
"(",
"at",
"Vec",
")",
"RGBA",
"{",
"if",
"!",
"pd",
".",
"Rect",
".",
"Contains",
"(",
"at",
")",
"{",
"return",
"RGBA",
"{",
"0",
",",
"0",
",",
"0",
",",
"0",
"}",
"\n",
"}",
"\n",
"re... | // Color returns the color located at the given position. | [
"Color",
"returns",
"the",
"color",
"located",
"at",
"the",
"given",
"position",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/data.go#L272-L277 |
30,886 | graph-gophers/graphql-go | introspection.go | ToJSON | func (s *Schema) ToJSON() ([]byte, error) {
result := s.exec(context.Background(), introspectionQuery, "", nil, &resolvable.Schema{
Query: &resolvable.Object{},
Schema: *s.schema,
})
if len(result.Errors) != 0 {
panic(result.Errors[0])
}
return json.MarshalIndent(result.Data, "", "\t")
} | go | func (s *Schema) ToJSON() ([]byte, error) {
result := s.exec(context.Background(), introspectionQuery, "", nil, &resolvable.Schema{
Query: &resolvable.Object{},
Schema: *s.schema,
})
if len(result.Errors) != 0 {
panic(result.Errors[0])
}
return json.MarshalIndent(result.Data, "", "\t")
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"ToJSON",
"(",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"result",
":=",
"s",
".",
"exec",
"(",
"context",
".",
"Background",
"(",
")",
",",
"introspectionQuery",
",",
"\"",
"\"",
",",
"nil",
",",
... | // ToJSON encodes the schema in a JSON format used by tools like Relay. | [
"ToJSON",
"encodes",
"the",
"schema",
"in",
"a",
"JSON",
"format",
"used",
"by",
"tools",
"like",
"Relay",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/introspection.go#L17-L26 |
30,887 | graph-gophers/graphql-go | graphql.go | MustParseSchema | func MustParseSchema(schemaString string, resolver interface{}, opts ...SchemaOpt) *Schema {
s, err := ParseSchema(schemaString, resolver, opts...)
if err != nil {
panic(err)
}
return s
} | go | func MustParseSchema(schemaString string, resolver interface{}, opts ...SchemaOpt) *Schema {
s, err := ParseSchema(schemaString, resolver, opts...)
if err != nil {
panic(err)
}
return s
} | [
"func",
"MustParseSchema",
"(",
"schemaString",
"string",
",",
"resolver",
"interface",
"{",
"}",
",",
"opts",
"...",
"SchemaOpt",
")",
"*",
"Schema",
"{",
"s",
",",
"err",
":=",
"ParseSchema",
"(",
"schemaString",
",",
"resolver",
",",
"opts",
"...",
")",... | // MustParseSchema calls ParseSchema and panics on error. | [
"MustParseSchema",
"calls",
"ParseSchema",
"and",
"panics",
"on",
"error",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/graphql.go#L52-L58 |
30,888 | graph-gophers/graphql-go | graphql.go | Tracer | func Tracer(tracer trace.Tracer) SchemaOpt {
return func(s *Schema) {
s.tracer = tracer
}
} | go | func Tracer(tracer trace.Tracer) SchemaOpt {
return func(s *Schema) {
s.tracer = tracer
}
} | [
"func",
"Tracer",
"(",
"tracer",
"trace",
".",
"Tracer",
")",
"SchemaOpt",
"{",
"return",
"func",
"(",
"s",
"*",
"Schema",
")",
"{",
"s",
".",
"tracer",
"=",
"tracer",
"\n",
"}",
"\n",
"}"
] | // Tracer is used to trace queries and fields. It defaults to trace.OpenTracingTracer. | [
"Tracer",
"is",
"used",
"to",
"trace",
"queries",
"and",
"fields",
".",
"It",
"defaults",
"to",
"trace",
".",
"OpenTracingTracer",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/graphql.go#L109-L113 |
30,889 | graph-gophers/graphql-go | graphql.go | ValidationTracer | func ValidationTracer(tracer trace.ValidationTracer) SchemaOpt {
return func(s *Schema) {
s.validationTracer = tracer
}
} | go | func ValidationTracer(tracer trace.ValidationTracer) SchemaOpt {
return func(s *Schema) {
s.validationTracer = tracer
}
} | [
"func",
"ValidationTracer",
"(",
"tracer",
"trace",
".",
"ValidationTracer",
")",
"SchemaOpt",
"{",
"return",
"func",
"(",
"s",
"*",
"Schema",
")",
"{",
"s",
".",
"validationTracer",
"=",
"tracer",
"\n",
"}",
"\n",
"}"
] | // ValidationTracer is used to trace validation errors. It defaults to trace.NoopValidationTracer. | [
"ValidationTracer",
"is",
"used",
"to",
"trace",
"validation",
"errors",
".",
"It",
"defaults",
"to",
"trace",
".",
"NoopValidationTracer",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/graphql.go#L116-L120 |
30,890 | graph-gophers/graphql-go | graphql.go | Logger | func Logger(logger log.Logger) SchemaOpt {
return func(s *Schema) {
s.logger = logger
}
} | go | func Logger(logger log.Logger) SchemaOpt {
return func(s *Schema) {
s.logger = logger
}
} | [
"func",
"Logger",
"(",
"logger",
"log",
".",
"Logger",
")",
"SchemaOpt",
"{",
"return",
"func",
"(",
"s",
"*",
"Schema",
")",
"{",
"s",
".",
"logger",
"=",
"logger",
"\n",
"}",
"\n",
"}"
] | // Logger is used to log panics during query execution. It defaults to exec.DefaultLogger. | [
"Logger",
"is",
"used",
"to",
"log",
"panics",
"during",
"query",
"execution",
".",
"It",
"defaults",
"to",
"exec",
".",
"DefaultLogger",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/graphql.go#L123-L127 |
30,891 | graph-gophers/graphql-go | graphql.go | Validate | func (s *Schema) Validate(queryString string) []*errors.QueryError {
doc, qErr := query.Parse(queryString)
if qErr != nil {
return []*errors.QueryError{qErr}
}
return validation.Validate(s.schema, doc, s.maxDepth)
} | go | func (s *Schema) Validate(queryString string) []*errors.QueryError {
doc, qErr := query.Parse(queryString)
if qErr != nil {
return []*errors.QueryError{qErr}
}
return validation.Validate(s.schema, doc, s.maxDepth)
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Validate",
"(",
"queryString",
"string",
")",
"[",
"]",
"*",
"errors",
".",
"QueryError",
"{",
"doc",
",",
"qErr",
":=",
"query",
".",
"Parse",
"(",
"queryString",
")",
"\n",
"if",
"qErr",
"!=",
"nil",
"{",
"r... | // Validate validates the given query with the schema. | [
"Validate",
"validates",
"the",
"given",
"query",
"with",
"the",
"schema",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/graphql.go#L146-L153 |
30,892 | graph-gophers/graphql-go | time.go | UnmarshalGraphQL | func (t *Time) UnmarshalGraphQL(input interface{}) error {
switch input := input.(type) {
case time.Time:
t.Time = input
return nil
case string:
var err error
t.Time, err = time.Parse(time.RFC3339, input)
return err
case int:
t.Time = time.Unix(int64(input), 0)
return nil
case float64:
t.Time = tim... | go | func (t *Time) UnmarshalGraphQL(input interface{}) error {
switch input := input.(type) {
case time.Time:
t.Time = input
return nil
case string:
var err error
t.Time, err = time.Parse(time.RFC3339, input)
return err
case int:
t.Time = time.Unix(int64(input), 0)
return nil
case float64:
t.Time = tim... | [
"func",
"(",
"t",
"*",
"Time",
")",
"UnmarshalGraphQL",
"(",
"input",
"interface",
"{",
"}",
")",
"error",
"{",
"switch",
"input",
":=",
"input",
".",
"(",
"type",
")",
"{",
"case",
"time",
".",
"Time",
":",
"t",
".",
"Time",
"=",
"input",
"\n",
... | // UnmarshalGraphQL is a custom unmarshaler for Time
//
// This function will be called whenever you use the
// time scalar as an input | [
"UnmarshalGraphQL",
"is",
"a",
"custom",
"unmarshaler",
"for",
"Time",
"This",
"function",
"will",
"be",
"called",
"whenever",
"you",
"use",
"the",
"time",
"scalar",
"as",
"an",
"input"
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/time.go#L25-L43 |
30,893 | graph-gophers/graphql-go | internal/schema/schema.go | Resolve | func (s *Schema) Resolve(name string) common.Type {
return s.Types[name]
} | go | func (s *Schema) Resolve(name string) common.Type {
return s.Types[name]
} | [
"func",
"(",
"s",
"*",
"Schema",
")",
"Resolve",
"(",
"name",
"string",
")",
"common",
".",
"Type",
"{",
"return",
"s",
".",
"Types",
"[",
"name",
"]",
"\n",
"}"
] | // Resolve a named type in the schema by its name. | [
"Resolve",
"a",
"named",
"type",
"in",
"the",
"schema",
"by",
"its",
"name",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/internal/schema/schema.go#L53-L55 |
30,894 | graph-gophers/graphql-go | internal/schema/schema.go | Get | func (l FieldList) Get(name string) *Field {
for _, f := range l {
if f.Name == name {
return f
}
}
return nil
} | go | func (l FieldList) Get(name string) *Field {
for _, f := range l {
if f.Name == name {
return f
}
}
return nil
} | [
"func",
"(",
"l",
"FieldList",
")",
"Get",
"(",
"name",
"string",
")",
"*",
"Field",
"{",
"for",
"_",
",",
"f",
":=",
"range",
"l",
"{",
"if",
"f",
".",
"Name",
"==",
"name",
"{",
"return",
"f",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"nil",
"\... | // Get iterates over the field list, returning a pointer-to-Field when the field name matches the
// provided `name` argument.
// Returns nil when no field was found by that name. | [
"Get",
"iterates",
"over",
"the",
"field",
"list",
"returning",
"a",
"pointer",
"-",
"to",
"-",
"Field",
"when",
"the",
"field",
"name",
"matches",
"the",
"provided",
"name",
"argument",
".",
"Returns",
"nil",
"when",
"no",
"field",
"was",
"found",
"by",
... | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/internal/schema/schema.go#L170-L177 |
30,895 | graph-gophers/graphql-go | internal/schema/schema.go | Names | func (l FieldList) Names() []string {
names := make([]string, len(l))
for i, f := range l {
names[i] = f.Name
}
return names
} | go | func (l FieldList) Names() []string {
names := make([]string, len(l))
for i, f := range l {
names[i] = f.Name
}
return names
} | [
"func",
"(",
"l",
"FieldList",
")",
"Names",
"(",
")",
"[",
"]",
"string",
"{",
"names",
":=",
"make",
"(",
"[",
"]",
"string",
",",
"len",
"(",
"l",
")",
")",
"\n",
"for",
"i",
",",
"f",
":=",
"range",
"l",
"{",
"names",
"[",
"i",
"]",
"="... | // Names returns a string slice of the field names in the FieldList. | [
"Names",
"returns",
"a",
"string",
"slice",
"of",
"the",
"field",
"names",
"in",
"the",
"FieldList",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/internal/schema/schema.go#L180-L186 |
30,896 | graph-gophers/graphql-go | internal/schema/schema.go | New | func New() *Schema {
s := &Schema{
entryPointNames: make(map[string]string),
Types: make(map[string]NamedType),
Directives: make(map[string]*DirectiveDecl),
}
for n, t := range Meta.Types {
s.Types[n] = t
}
for n, d := range Meta.Directives {
s.Directives[n] = d
}
return s
} | go | func New() *Schema {
s := &Schema{
entryPointNames: make(map[string]string),
Types: make(map[string]NamedType),
Directives: make(map[string]*DirectiveDecl),
}
for n, t := range Meta.Types {
s.Types[n] = t
}
for n, d := range Meta.Directives {
s.Directives[n] = d
}
return s
} | [
"func",
"New",
"(",
")",
"*",
"Schema",
"{",
"s",
":=",
"&",
"Schema",
"{",
"entryPointNames",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"string",
")",
",",
"Types",
":",
"make",
"(",
"map",
"[",
"string",
"]",
"NamedType",
")",
",",
"Directives... | // New initializes an instance of Schema. | [
"New",
"initializes",
"an",
"instance",
"of",
"Schema",
"."
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/internal/schema/schema.go#L235-L248 |
30,897 | graph-gophers/graphql-go | log/log.go | LogPanic | func (l *DefaultLogger) LogPanic(_ context.Context, value interface{}) {
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
log.Printf("graphql: panic occurred: %v\n%s", value, buf)
} | go | func (l *DefaultLogger) LogPanic(_ context.Context, value interface{}) {
const size = 64 << 10
buf := make([]byte, size)
buf = buf[:runtime.Stack(buf, false)]
log.Printf("graphql: panic occurred: %v\n%s", value, buf)
} | [
"func",
"(",
"l",
"*",
"DefaultLogger",
")",
"LogPanic",
"(",
"_",
"context",
".",
"Context",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"const",
"size",
"=",
"64",
"<<",
"10",
"\n",
"buf",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"size",
")... | // LogPanic is used to log recovered panic values that occur during query execution | [
"LogPanic",
"is",
"used",
"to",
"log",
"recovered",
"panic",
"values",
"that",
"occur",
"during",
"query",
"execution"
] | 3e8838d4614c12ab337e796548521744f921e05d | https://github.com/graph-gophers/graphql-go/blob/3e8838d4614c12ab337e796548521744f921e05d/log/log.go#L18-L23 |
30,898 | xeipuuv/gojsonschema | validation.go | Validate | func Validate(ls JSONLoader, ld JSONLoader) (*Result, error) {
// load schema
schema, err := NewSchema(ls)
if err != nil {
return nil, err
}
return schema.Validate(ld)
} | go | func Validate(ls JSONLoader, ld JSONLoader) (*Result, error) {
// load schema
schema, err := NewSchema(ls)
if err != nil {
return nil, err
}
return schema.Validate(ld)
} | [
"func",
"Validate",
"(",
"ls",
"JSONLoader",
",",
"ld",
"JSONLoader",
")",
"(",
"*",
"Result",
",",
"error",
")",
"{",
"// load schema",
"schema",
",",
"err",
":=",
"NewSchema",
"(",
"ls",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",... | // Validate loads and validates a JSON schema | [
"Validate",
"loads",
"and",
"validates",
"a",
"JSON",
"schema"
] | 354ad34c2300dd6e84920ac70b41487336219e43 | https://github.com/xeipuuv/gojsonschema/blob/354ad34c2300dd6e84920ac70b41487336219e43/validation.go#L39-L46 |
30,899 | xeipuuv/gojsonschema | validation.go | Validate | func (v *Schema) Validate(l JSONLoader) (*Result, error) {
root, err := l.LoadJSON()
if err != nil {
return nil, err
}
return v.validateDocument(root), nil
} | go | func (v *Schema) Validate(l JSONLoader) (*Result, error) {
root, err := l.LoadJSON()
if err != nil {
return nil, err
}
return v.validateDocument(root), nil
} | [
"func",
"(",
"v",
"*",
"Schema",
")",
"Validate",
"(",
"l",
"JSONLoader",
")",
"(",
"*",
"Result",
",",
"error",
")",
"{",
"root",
",",
"err",
":=",
"l",
".",
"LoadJSON",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err... | // Validate loads and validates a JSON document | [
"Validate",
"loads",
"and",
"validates",
"a",
"JSON",
"document"
] | 354ad34c2300dd6e84920ac70b41487336219e43 | https://github.com/xeipuuv/gojsonschema/blob/354ad34c2300dd6e84920ac70b41487336219e43/validation.go#L49-L55 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.