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
sequencelengths 21
1.41k
| docstring
stringlengths 6
2.61k
| docstring_tokens
sequencelengths 3
215
| sha
stringlengths 40
40
| url
stringlengths 85
252
|
---|---|---|---|---|---|---|---|---|---|---|---|
150,900 | labstack/gommon | color/color.go | Printf | func (c *Color) Printf(format string, args ...interface{}) {
fmt.Fprintf(c.output, format, args...)
} | go | func (c *Color) Printf(format string, args ...interface{}) {
fmt.Fprintf(c.output, format, args...)
} | [
"func",
"(",
"c",
"*",
"Color",
")",
"Printf",
"(",
"format",
"string",
",",
"args",
"...",
"interface",
"{",
"}",
")",
"{",
"fmt",
".",
"Fprintf",
"(",
"c",
".",
"output",
",",
"format",
",",
"args",
"...",
")",
"\n",
"}"
] | // Printf is analogous to `fmt.Printf` with termial detection. | [
"Printf",
"is",
"analogous",
"to",
"fmt",
".",
"Printf",
"with",
"termial",
"detection",
"."
] | 82ef680aef5189b68682876cf70d09daa4ac0f51 | https://github.com/labstack/gommon/blob/82ef680aef5189b68682876cf70d09daa4ac0f51/color/color.go#L172-L174 |
150,901 | caarlos0/env | env.go | ParseWithFuncs | func ParseWithFuncs(v interface{}, funcMap CustomParsers) error {
ptrRef := reflect.ValueOf(v)
if ptrRef.Kind() != reflect.Ptr {
return ErrNotAStructPtr
}
ref := ptrRef.Elem()
if ref.Kind() != reflect.Struct {
return ErrNotAStructPtr
}
var parsers = defaultCustomParsers()
for k, v := range funcMap {
parsers[k] = v
}
return doParse(ref, parsers)
} | go | func ParseWithFuncs(v interface{}, funcMap CustomParsers) error {
ptrRef := reflect.ValueOf(v)
if ptrRef.Kind() != reflect.Ptr {
return ErrNotAStructPtr
}
ref := ptrRef.Elem()
if ref.Kind() != reflect.Struct {
return ErrNotAStructPtr
}
var parsers = defaultCustomParsers()
for k, v := range funcMap {
parsers[k] = v
}
return doParse(ref, parsers)
} | [
"func",
"ParseWithFuncs",
"(",
"v",
"interface",
"{",
"}",
",",
"funcMap",
"CustomParsers",
")",
"error",
"{",
"ptrRef",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"if",
"ptrRef",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Ptr",
"{",
"return",
"ErrNotAStructPtr",
"\n",
"}",
"\n",
"ref",
":=",
"ptrRef",
".",
"Elem",
"(",
")",
"\n",
"if",
"ref",
".",
"Kind",
"(",
")",
"!=",
"reflect",
".",
"Struct",
"{",
"return",
"ErrNotAStructPtr",
"\n",
"}",
"\n",
"var",
"parsers",
"=",
"defaultCustomParsers",
"(",
")",
"\n",
"for",
"k",
",",
"v",
":=",
"range",
"funcMap",
"{",
"parsers",
"[",
"k",
"]",
"=",
"v",
"\n",
"}",
"\n",
"return",
"doParse",
"(",
"ref",
",",
"parsers",
")",
"\n",
"}"
] | // ParseWithFuncs is the same as `Parse` except it also allows the user to pass
// in custom parsers. | [
"ParseWithFuncs",
"is",
"the",
"same",
"as",
"Parse",
"except",
"it",
"also",
"allows",
"the",
"user",
"to",
"pass",
"in",
"custom",
"parsers",
"."
] | 2ae6b6e118789b55aae151656169a4a07d4bff42 | https://github.com/caarlos0/env/blob/2ae6b6e118789b55aae151656169a4a07d4bff42/env.go#L98-L112 |
150,902 | caarlos0/env | env.go | parseKeyForOption | func parseKeyForOption(key string) (string, []string) {
opts := strings.Split(key, ",")
return opts[0], opts[1:]
} | go | func parseKeyForOption(key string) (string, []string) {
opts := strings.Split(key, ",")
return opts[0], opts[1:]
} | [
"func",
"parseKeyForOption",
"(",
"key",
"string",
")",
"(",
"string",
",",
"[",
"]",
"string",
")",
"{",
"opts",
":=",
"strings",
".",
"Split",
"(",
"key",
",",
"\"",
"\"",
")",
"\n",
"return",
"opts",
"[",
"0",
"]",
",",
"opts",
"[",
"1",
":",
"]",
"\n",
"}"
] | // split the env tag's key into the expected key and desired option, if any. | [
"split",
"the",
"env",
"tag",
"s",
"key",
"into",
"the",
"expected",
"key",
"and",
"desired",
"option",
"if",
"any",
"."
] | 2ae6b6e118789b55aae151656169a4a07d4bff42 | https://github.com/caarlos0/env/blob/2ae6b6e118789b55aae151656169a4a07d4bff42/env.go#L183-L186 |
150,903 | go-gl/glfw | v3.2/glfw/native_windows.go | GetWin32Adapter | func (m *Monitor) GetWin32Adapter() string {
ret := C.glfwGetWin32Adapter(m.data)
panicError()
return C.GoString(ret)
} | go | func (m *Monitor) GetWin32Adapter() string {
ret := C.glfwGetWin32Adapter(m.data)
panicError()
return C.GoString(ret)
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetWin32Adapter",
"(",
")",
"string",
"{",
"ret",
":=",
"C",
".",
"glfwGetWin32Adapter",
"(",
"m",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"ret",
")",
"\n",
"}"
] | // GetWin32Adapter returns the adapter device name of the monitor. | [
"GetWin32Adapter",
"returns",
"the",
"adapter",
"device",
"name",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_windows.go#L11-L15 |
150,904 | go-gl/glfw | v3.2/glfw/native_windows.go | GetWin32Monitor | func (m *Monitor) GetWin32Monitor() string {
ret := C.glfwGetWin32Monitor(m.data)
panicError()
return C.GoString(ret)
} | go | func (m *Monitor) GetWin32Monitor() string {
ret := C.glfwGetWin32Monitor(m.data)
panicError()
return C.GoString(ret)
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetWin32Monitor",
"(",
")",
"string",
"{",
"ret",
":=",
"C",
".",
"glfwGetWin32Monitor",
"(",
"m",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"ret",
")",
"\n",
"}"
] | // GetWin32Monitor returns the display device name of the monitor. | [
"GetWin32Monitor",
"returns",
"the",
"display",
"device",
"name",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_windows.go#L18-L22 |
150,905 | go-gl/glfw | v3.2/glfw/native_windows.go | GetWin32Window | func (w *Window) GetWin32Window() C.HWND {
ret := C.glfwGetWin32Window(w.data)
panicError()
return ret
} | go | func (w *Window) GetWin32Window() C.HWND {
ret := C.glfwGetWin32Window(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetWin32Window",
"(",
")",
"C",
".",
"HWND",
"{",
"ret",
":=",
"C",
".",
"glfwGetWin32Window",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetWin32Window returns the HWND of the window. | [
"GetWin32Window",
"returns",
"the",
"HWND",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_windows.go#L25-L29 |
150,906 | go-gl/glfw | v3.2/glfw/native_windows.go | GetWGLContext | func (w *Window) GetWGLContext() C.HGLRC {
ret := C.glfwGetWGLContext(w.data)
panicError()
return ret
} | go | func (w *Window) GetWGLContext() C.HGLRC {
ret := C.glfwGetWGLContext(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetWGLContext",
"(",
")",
"C",
".",
"HGLRC",
"{",
"ret",
":=",
"C",
".",
"glfwGetWGLContext",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetWGLContext returns the HGLRC of the window. | [
"GetWGLContext",
"returns",
"the",
"HGLRC",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_windows.go#L32-L36 |
150,907 | go-gl/glfw | v3.0/glfw/monitor.go | GetPosition | func (m *Monitor) GetPosition() (x, y int) {
var xpos, ypos C.int
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
return int(xpos), int(ypos)
} | go | func (m *Monitor) GetPosition() (x, y int) {
var xpos, ypos C.int
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
return int(xpos), int(ypos)
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetPosition",
"(",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"var",
"xpos",
",",
"ypos",
"C",
".",
"int",
"\n\n",
"C",
".",
"glfwGetMonitorPos",
"(",
"m",
".",
"data",
",",
"&",
"xpos",
",",
"&",
"ypos",
")",
"\n",
"return",
"int",
"(",
"xpos",
")",
",",
"int",
"(",
"ypos",
")",
"\n",
"}"
] | //GetPosition returns the position, in screen coordinates, of the upper-left
//corner of the monitor. | [
"GetPosition",
"returns",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/monitor.go#L86-L91 |
150,908 | go-gl/glfw | v3.0/glfw/monitor.go | SetGamma | func (m *Monitor) SetGamma(gamma float32) {
C.glfwSetGamma(m.data, C.float(gamma))
} | go | func (m *Monitor) SetGamma(gamma float32) {
C.glfwSetGamma(m.data, C.float(gamma))
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"SetGamma",
"(",
"gamma",
"float32",
")",
"{",
"C",
".",
"glfwSetGamma",
"(",
"m",
".",
"data",
",",
"C",
".",
"float",
"(",
"gamma",
")",
")",
"\n",
"}"
] | //SetGamma generates a 256-element gamma ramp from the specified exponent and then calls
//SetGamma with it. | [
"SetGamma",
"generates",
"a",
"256",
"-",
"element",
"gamma",
"ramp",
"from",
"the",
"specified",
"exponent",
"and",
"then",
"calls",
"SetGamma",
"with",
"it",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/monitor.go#L164-L166 |
150,909 | go-gl/glfw | v3.0/glfw/monitor.go | GetGammaRamp | func (m *Monitor) GetGammaRamp() (*GammaRamp, error) {
var ramp GammaRamp
rampC := C.glfwGetGammaRamp(m.data)
if rampC == nil {
return nil, errors.New("Can't get the gamma ramp.")
}
length := int(rampC.size)
ramp.Red = make([]uint16, length)
ramp.Green = make([]uint16, length)
ramp.Blue = make([]uint16, length)
for i := 0; i < length; i++ {
ramp.Red[i] = uint16(C.GetGammaAtIndex(rampC.red, C.int(i)))
ramp.Green[i] = uint16(C.GetGammaAtIndex(rampC.green, C.int(i)))
ramp.Blue[i] = uint16(C.GetGammaAtIndex(rampC.blue, C.int(i)))
}
return &ramp, nil
} | go | func (m *Monitor) GetGammaRamp() (*GammaRamp, error) {
var ramp GammaRamp
rampC := C.glfwGetGammaRamp(m.data)
if rampC == nil {
return nil, errors.New("Can't get the gamma ramp.")
}
length := int(rampC.size)
ramp.Red = make([]uint16, length)
ramp.Green = make([]uint16, length)
ramp.Blue = make([]uint16, length)
for i := 0; i < length; i++ {
ramp.Red[i] = uint16(C.GetGammaAtIndex(rampC.red, C.int(i)))
ramp.Green[i] = uint16(C.GetGammaAtIndex(rampC.green, C.int(i)))
ramp.Blue[i] = uint16(C.GetGammaAtIndex(rampC.blue, C.int(i)))
}
return &ramp, nil
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetGammaRamp",
"(",
")",
"(",
"*",
"GammaRamp",
",",
"error",
")",
"{",
"var",
"ramp",
"GammaRamp",
"\n\n",
"rampC",
":=",
"C",
".",
"glfwGetGammaRamp",
"(",
"m",
".",
"data",
")",
"\n",
"if",
"rampC",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"length",
":=",
"int",
"(",
"rampC",
".",
"size",
")",
"\n",
"ramp",
".",
"Red",
"=",
"make",
"(",
"[",
"]",
"uint16",
",",
"length",
")",
"\n",
"ramp",
".",
"Green",
"=",
"make",
"(",
"[",
"]",
"uint16",
",",
"length",
")",
"\n",
"ramp",
".",
"Blue",
"=",
"make",
"(",
"[",
"]",
"uint16",
",",
"length",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
"{",
"ramp",
".",
"Red",
"[",
"i",
"]",
"=",
"uint16",
"(",
"C",
".",
"GetGammaAtIndex",
"(",
"rampC",
".",
"red",
",",
"C",
".",
"int",
"(",
"i",
")",
")",
")",
"\n",
"ramp",
".",
"Green",
"[",
"i",
"]",
"=",
"uint16",
"(",
"C",
".",
"GetGammaAtIndex",
"(",
"rampC",
".",
"green",
",",
"C",
".",
"int",
"(",
"i",
")",
")",
")",
"\n",
"ramp",
".",
"Blue",
"[",
"i",
"]",
"=",
"uint16",
"(",
"C",
".",
"GetGammaAtIndex",
"(",
"rampC",
".",
"blue",
",",
"C",
".",
"int",
"(",
"i",
")",
")",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"ramp",
",",
"nil",
"\n",
"}"
] | //GetGammaRamp retrieves the current gamma ramp of the monitor. | [
"GetGammaRamp",
"retrieves",
"the",
"current",
"gamma",
"ramp",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/monitor.go#L169-L189 |
150,910 | go-gl/glfw | v3.0/glfw/monitor.go | SetGammaRamp | func (m *Monitor) SetGammaRamp(ramp *GammaRamp) {
var rampC C.GLFWgammaramp
length := len(ramp.Red)
for i := 0; i < length; i++ {
C.SetGammaAtIndex(rampC.red, C.int(i), C.ushort(ramp.Red[i]))
C.SetGammaAtIndex(rampC.green, C.int(i), C.ushort(ramp.Green[i]))
C.SetGammaAtIndex(rampC.blue, C.int(i), C.ushort(ramp.Blue[i]))
}
C.glfwSetGammaRamp(m.data, &rampC)
} | go | func (m *Monitor) SetGammaRamp(ramp *GammaRamp) {
var rampC C.GLFWgammaramp
length := len(ramp.Red)
for i := 0; i < length; i++ {
C.SetGammaAtIndex(rampC.red, C.int(i), C.ushort(ramp.Red[i]))
C.SetGammaAtIndex(rampC.green, C.int(i), C.ushort(ramp.Green[i]))
C.SetGammaAtIndex(rampC.blue, C.int(i), C.ushort(ramp.Blue[i]))
}
C.glfwSetGammaRamp(m.data, &rampC)
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"SetGammaRamp",
"(",
"ramp",
"*",
"GammaRamp",
")",
"{",
"var",
"rampC",
"C",
".",
"GLFWgammaramp",
"\n\n",
"length",
":=",
"len",
"(",
"ramp",
".",
"Red",
")",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
"{",
"C",
".",
"SetGammaAtIndex",
"(",
"rampC",
".",
"red",
",",
"C",
".",
"int",
"(",
"i",
")",
",",
"C",
".",
"ushort",
"(",
"ramp",
".",
"Red",
"[",
"i",
"]",
")",
")",
"\n",
"C",
".",
"SetGammaAtIndex",
"(",
"rampC",
".",
"green",
",",
"C",
".",
"int",
"(",
"i",
")",
",",
"C",
".",
"ushort",
"(",
"ramp",
".",
"Green",
"[",
"i",
"]",
")",
")",
"\n",
"C",
".",
"SetGammaAtIndex",
"(",
"rampC",
".",
"blue",
",",
"C",
".",
"int",
"(",
"i",
")",
",",
"C",
".",
"ushort",
"(",
"ramp",
".",
"Blue",
"[",
"i",
"]",
")",
")",
"\n",
"}",
"\n\n",
"C",
".",
"glfwSetGammaRamp",
"(",
"m",
".",
"data",
",",
"&",
"rampC",
")",
"\n",
"}"
] | //SetGammaRamp sets the current gamma ramp for the monitor. | [
"SetGammaRamp",
"sets",
"the",
"current",
"gamma",
"ramp",
"for",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/monitor.go#L192-L204 |
150,911 | go-gl/glfw | v3.2/glfw/input.go | GetInputMode | func (w *Window) GetInputMode(mode InputMode) int {
ret := int(C.glfwGetInputMode(w.data, C.int(mode)))
panicError()
return ret
} | go | func (w *Window) GetInputMode(mode InputMode) int {
ret := int(C.glfwGetInputMode(w.data, C.int(mode)))
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetInputMode",
"(",
"mode",
"InputMode",
")",
"int",
"{",
"ret",
":=",
"int",
"(",
"C",
".",
"glfwGetInputMode",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"mode",
")",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetInputMode returns the value of an input option of the window. | [
"GetInputMode",
"returns",
"the",
"value",
"of",
"an",
"input",
"option",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L317-L321 |
150,912 | go-gl/glfw | v3.2/glfw/input.go | SetInputMode | func (w *Window) SetInputMode(mode InputMode, value int) {
C.glfwSetInputMode(w.data, C.int(mode), C.int(value))
panicError()
} | go | func (w *Window) SetInputMode(mode InputMode, value int) {
C.glfwSetInputMode(w.data, C.int(mode), C.int(value))
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetInputMode",
"(",
"mode",
"InputMode",
",",
"value",
"int",
")",
"{",
"C",
".",
"glfwSetInputMode",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"mode",
")",
",",
"C",
".",
"int",
"(",
"value",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetInputMode sets an input option for the window. | [
"SetInputMode",
"sets",
"an",
"input",
"option",
"for",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L324-L327 |
150,913 | go-gl/glfw | v3.2/glfw/input.go | GetKeyName | func GetKeyName(key Key, scancode int) string {
ret := C.glfwGetKeyName(C.int(key), C.int(scancode))
panicError()
return C.GoString(ret)
} | go | func GetKeyName(key Key, scancode int) string {
ret := C.glfwGetKeyName(C.int(key), C.int(scancode))
panicError()
return C.GoString(ret)
} | [
"func",
"GetKeyName",
"(",
"key",
"Key",
",",
"scancode",
"int",
")",
"string",
"{",
"ret",
":=",
"C",
".",
"glfwGetKeyName",
"(",
"C",
".",
"int",
"(",
"key",
")",
",",
"C",
".",
"int",
"(",
"scancode",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"C",
".",
"GoString",
"(",
"ret",
")",
"\n",
"}"
] | // GetKeyName returns the localized name of the specified printable key.
//
// If the key is glfw.KeyUnknown, the scancode is used, otherwise the scancode is ignored. | [
"GetKeyName",
"returns",
"the",
"localized",
"name",
"of",
"the",
"specified",
"printable",
"key",
".",
"If",
"the",
"key",
"is",
"glfw",
".",
"KeyUnknown",
"the",
"scancode",
"is",
"used",
"otherwise",
"the",
"scancode",
"is",
"ignored",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L349-L353 |
150,914 | go-gl/glfw | v3.2/glfw/input.go | SetCursor | func (w *Window) SetCursor(c *Cursor) {
if c == nil {
C.glfwSetCursor(w.data, nil)
} else {
C.glfwSetCursor(w.data, c.data)
}
panicError()
} | go | func (w *Window) SetCursor(c *Cursor) {
if c == nil {
C.glfwSetCursor(w.data, nil)
} else {
C.glfwSetCursor(w.data, c.data)
}
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetCursor",
"(",
"c",
"*",
"Cursor",
")",
"{",
"if",
"c",
"==",
"nil",
"{",
"C",
".",
"glfwSetCursor",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetCursor",
"(",
"w",
".",
"data",
",",
"c",
".",
"data",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetCursor sets the cursor image to be used when the cursor is over the client area
// of the specified window. The set cursor will only be visible when the cursor mode of the
// window is CursorNormal.
//
// On some platforms, the set cursor may not be visible unless the window also has input focus. | [
"SetCursor",
"sets",
"the",
"cursor",
"image",
"to",
"be",
"used",
"when",
"the",
"cursor",
"is",
"over",
"the",
"client",
"area",
"of",
"the",
"specified",
"window",
".",
"The",
"set",
"cursor",
"will",
"only",
"be",
"visible",
"when",
"the",
"cursor",
"mode",
"of",
"the",
"window",
"is",
"CursorNormal",
".",
"On",
"some",
"platforms",
"the",
"set",
"cursor",
"may",
"not",
"be",
"visible",
"unless",
"the",
"window",
"also",
"has",
"input",
"focus",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L451-L458 |
150,915 | go-gl/glfw | v3.2/glfw/input.go | SetJoystickCallback | func SetJoystickCallback(cbfun JoystickCallback) (previous JoystickCallback) {
previous = fJoystickHolder
fJoystickHolder = cbfun
if cbfun == nil {
C.glfwSetJoystickCallback(nil)
} else {
C.glfwSetJoystickCallbackCB()
}
panicError()
return previous
} | go | func SetJoystickCallback(cbfun JoystickCallback) (previous JoystickCallback) {
previous = fJoystickHolder
fJoystickHolder = cbfun
if cbfun == nil {
C.glfwSetJoystickCallback(nil)
} else {
C.glfwSetJoystickCallbackCB()
}
panicError()
return previous
} | [
"func",
"SetJoystickCallback",
"(",
"cbfun",
"JoystickCallback",
")",
"(",
"previous",
"JoystickCallback",
")",
"{",
"previous",
"=",
"fJoystickHolder",
"\n",
"fJoystickHolder",
"=",
"cbfun",
"\n",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetJoystickCallback",
"(",
"nil",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetJoystickCallbackCB",
"(",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"previous",
"\n",
"}"
] | // SetJoystickCallback sets the joystick configuration callback, or removes the
// currently set callback. This is called when a joystick is connected to or
// disconnected from the system. | [
"SetJoystickCallback",
"sets",
"the",
"joystick",
"configuration",
"callback",
"or",
"removes",
"the",
"currently",
"set",
"callback",
".",
"This",
"is",
"called",
"when",
"a",
"joystick",
"is",
"connected",
"to",
"or",
"disconnected",
"from",
"the",
"system",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L466-L476 |
150,916 | go-gl/glfw | v3.2/glfw/input.go | SetCursorPosCallback | func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback) {
previous = w.fCursorPosHolder
w.fCursorPosHolder = cbfun
if cbfun == nil {
C.glfwSetCursorPosCallback(w.data, nil)
} else {
C.glfwSetCursorPosCallbackCB(w.data)
}
panicError()
return previous
} | go | func (w *Window) SetCursorPosCallback(cbfun CursorPosCallback) (previous CursorPosCallback) {
previous = w.fCursorPosHolder
w.fCursorPosHolder = cbfun
if cbfun == nil {
C.glfwSetCursorPosCallback(w.data, nil)
} else {
C.glfwSetCursorPosCallbackCB(w.data)
}
panicError()
return previous
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetCursorPosCallback",
"(",
"cbfun",
"CursorPosCallback",
")",
"(",
"previous",
"CursorPosCallback",
")",
"{",
"previous",
"=",
"w",
".",
"fCursorPosHolder",
"\n",
"w",
".",
"fCursorPosHolder",
"=",
"cbfun",
"\n",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetCursorPosCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetCursorPosCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"previous",
"\n",
"}"
] | // SetCursorPosCallback sets the cursor position callback which is called
// when the cursor is moved. The callback is provided with the position relative
// to the upper-left corner of the client area of the window. | [
"SetCursorPosCallback",
"sets",
"the",
"cursor",
"position",
"callback",
"which",
"is",
"called",
"when",
"the",
"cursor",
"is",
"moved",
".",
"The",
"callback",
"is",
"provided",
"with",
"the",
"position",
"relative",
"to",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L588-L598 |
150,917 | go-gl/glfw | v3.2/glfw/input.go | SetDropCallback | func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
previous = w.fDropHolder
w.fDropHolder = cbfun
if cbfun == nil {
C.glfwSetDropCallback(w.data, nil)
} else {
C.glfwSetDropCallbackCB(w.data)
}
panicError()
return previous
} | go | func (w *Window) SetDropCallback(cbfun DropCallback) (previous DropCallback) {
previous = w.fDropHolder
w.fDropHolder = cbfun
if cbfun == nil {
C.glfwSetDropCallback(w.data, nil)
} else {
C.glfwSetDropCallbackCB(w.data)
}
panicError()
return previous
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetDropCallback",
"(",
"cbfun",
"DropCallback",
")",
"(",
"previous",
"DropCallback",
")",
"{",
"previous",
"=",
"w",
".",
"fDropHolder",
"\n",
"w",
".",
"fDropHolder",
"=",
"cbfun",
"\n",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetDropCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetDropCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"previous",
"\n",
"}"
] | // SetDropCallback sets the drop callback which is called when an object
// is dropped over the window. | [
"SetDropCallback",
"sets",
"the",
"drop",
"callback",
"which",
"is",
"called",
"when",
"an",
"object",
"is",
"dropped",
"over",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L639-L649 |
150,918 | go-gl/glfw | v3.2/glfw/input.go | JoystickPresent | func JoystickPresent(joy Joystick) bool {
ret := glfwbool(C.glfwJoystickPresent(C.int(joy)))
panicError()
return ret
} | go | func JoystickPresent(joy Joystick) bool {
ret := glfwbool(C.glfwJoystickPresent(C.int(joy)))
panicError()
return ret
} | [
"func",
"JoystickPresent",
"(",
"joy",
"Joystick",
")",
"bool",
"{",
"ret",
":=",
"glfwbool",
"(",
"C",
".",
"glfwJoystickPresent",
"(",
"C",
".",
"int",
"(",
"joy",
")",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // JoystickPresent reports whether the specified joystick is present. | [
"JoystickPresent",
"reports",
"whether",
"the",
"specified",
"joystick",
"is",
"present",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L652-L656 |
150,919 | go-gl/glfw | v3.2/glfw/input.go | GetJoystickAxes | func GetJoystickAxes(joy Joystick) []float32 {
var length int
axis := C.glfwGetJoystickAxes(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
panicError()
if axis == nil {
return nil
}
a := make([]float32, length)
for i := 0; i < length; i++ {
a[i] = float32(C.GetAxisAtIndex(axis, C.int(i)))
}
return a
} | go | func GetJoystickAxes(joy Joystick) []float32 {
var length int
axis := C.glfwGetJoystickAxes(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
panicError()
if axis == nil {
return nil
}
a := make([]float32, length)
for i := 0; i < length; i++ {
a[i] = float32(C.GetAxisAtIndex(axis, C.int(i)))
}
return a
} | [
"func",
"GetJoystickAxes",
"(",
"joy",
"Joystick",
")",
"[",
"]",
"float32",
"{",
"var",
"length",
"int",
"\n\n",
"axis",
":=",
"C",
".",
"glfwGetJoystickAxes",
"(",
"C",
".",
"int",
"(",
"joy",
")",
",",
"(",
"*",
"C",
".",
"int",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"length",
")",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"if",
"axis",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"a",
":=",
"make",
"(",
"[",
"]",
"float32",
",",
"length",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
"{",
"a",
"[",
"i",
"]",
"=",
"float32",
"(",
"C",
".",
"GetAxisAtIndex",
"(",
"axis",
",",
"C",
".",
"int",
"(",
"i",
")",
")",
")",
"\n",
"}",
"\n",
"return",
"a",
"\n",
"}"
] | // GetJoystickAxes returns a slice of axis values. | [
"GetJoystickAxes",
"returns",
"a",
"slice",
"of",
"axis",
"values",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/input.go#L659-L673 |
150,920 | go-gl/glfw | v3.2/glfw/error.go | Error | func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.Code.String(), e.Desc)
} | go | func (e *Error) Error() string {
return fmt.Sprintf("%s: %s", e.Code.String(), e.Desc)
} | [
"func",
"(",
"e",
"*",
"Error",
")",
"Error",
"(",
")",
"string",
"{",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"e",
".",
"Code",
".",
"String",
"(",
")",
",",
"e",
".",
"Desc",
")",
"\n",
"}"
] | // Error prints the error code and description in a readable format. | [
"Error",
"prints",
"the",
"error",
"code",
"and",
"description",
"in",
"a",
"readable",
"format",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/error.go#L104-L106 |
150,921 | go-gl/glfw | v3.2/glfw/error.go | flushErrors | func flushErrors() {
err := fetchError()
if err != nil {
fmt.Println("GLFW: An uncaught error has occurred:", err)
fmt.Println("GLFW: Please report this bug in the Go package immediately.")
}
} | go | func flushErrors() {
err := fetchError()
if err != nil {
fmt.Println("GLFW: An uncaught error has occurred:", err)
fmt.Println("GLFW: Please report this bug in the Go package immediately.")
}
} | [
"func",
"flushErrors",
"(",
")",
"{",
"err",
":=",
"fetchError",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
",",
"err",
")",
"\n",
"fmt",
".",
"Println",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // flushErrors is called by Terminate before it actually calls C.glfwTerminate,
// this ensures that any uncaught errors buffered in lastError are printed
// before the program exits. | [
"flushErrors",
"is",
"called",
"by",
"Terminate",
"before",
"it",
"actually",
"calls",
"C",
".",
"glfwTerminate",
"this",
"ensures",
"that",
"any",
"uncaught",
"errors",
"buffered",
"in",
"lastError",
"are",
"printed",
"before",
"the",
"program",
"exits",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/error.go#L134-L140 |
150,922 | go-gl/glfw | v3.0/glfw/glfw.go | GetVersion | func GetVersion() (major, minor, revision int) {
var (
maj C.int
min C.int
rev C.int
)
C.glfwGetVersion(&maj, &min, &rev)
return int(maj), int(min), int(rev)
} | go | func GetVersion() (major, minor, revision int) {
var (
maj C.int
min C.int
rev C.int
)
C.glfwGetVersion(&maj, &min, &rev)
return int(maj), int(min), int(rev)
} | [
"func",
"GetVersion",
"(",
")",
"(",
"major",
",",
"minor",
",",
"revision",
"int",
")",
"{",
"var",
"(",
"maj",
"C",
".",
"int",
"\n",
"min",
"C",
".",
"int",
"\n",
"rev",
"C",
".",
"int",
"\n",
")",
"\n\n",
"C",
".",
"glfwGetVersion",
"(",
"&",
"maj",
",",
"&",
"min",
",",
"&",
"rev",
")",
"\n",
"return",
"int",
"(",
"maj",
")",
",",
"int",
"(",
"min",
")",
",",
"int",
"(",
"rev",
")",
"\n",
"}"
] | //GetVersion retrieves the major, minor and revision numbers of the GLFW
//library. It is intended for when you are using GLFW as a shared library and
//want to ensure that you are using the minimum required version.
//
//This function may be called before Init. | [
"GetVersion",
"retrieves",
"the",
"major",
"minor",
"and",
"revision",
"numbers",
"of",
"the",
"GLFW",
"library",
".",
"It",
"is",
"intended",
"for",
"when",
"you",
"are",
"using",
"GLFW",
"as",
"a",
"shared",
"library",
"and",
"want",
"to",
"ensure",
"that",
"you",
"are",
"using",
"the",
"minimum",
"required",
"version",
".",
"This",
"function",
"may",
"be",
"called",
"before",
"Init",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/glfw.go#L67-L76 |
150,923 | go-gl/glfw | v3.0/glfw/input.go | GetKey | func (w *Window) GetKey(key Key) Action {
return Action(C.glfwGetKey(w.data, C.int(key)))
} | go | func (w *Window) GetKey(key Key) Action {
return Action(C.glfwGetKey(w.data, C.int(key)))
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetKey",
"(",
"key",
"Key",
")",
"Action",
"{",
"return",
"Action",
"(",
"C",
".",
"glfwGetKey",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"key",
")",
")",
")",
"\n",
"}"
] | //GetKey returns the last reported state of a keyboard key. The returned state
//is one of Press or Release. The higher-level state Repeat is only reported to
//the key callback.
//
//If the StickyKeys input mode is enabled, this function returns Press the first
//time you call this function after a key has been pressed, even if the key has
//already been released.
//
//The key functions deal with physical keys, with key tokens named after their
//use on the standard US keyboard layout. If you want to input text, use the
//Unicode character callback instead. | [
"GetKey",
"returns",
"the",
"last",
"reported",
"state",
"of",
"a",
"keyboard",
"key",
".",
"The",
"returned",
"state",
"is",
"one",
"of",
"Press",
"or",
"Release",
".",
"The",
"higher",
"-",
"level",
"state",
"Repeat",
"is",
"only",
"reported",
"to",
"the",
"key",
"callback",
".",
"If",
"the",
"StickyKeys",
"input",
"mode",
"is",
"enabled",
"this",
"function",
"returns",
"Press",
"the",
"first",
"time",
"you",
"call",
"this",
"function",
"after",
"a",
"key",
"has",
"been",
"pressed",
"even",
"if",
"the",
"key",
"has",
"already",
"been",
"released",
".",
"The",
"key",
"functions",
"deal",
"with",
"physical",
"keys",
"with",
"key",
"tokens",
"named",
"after",
"their",
"use",
"on",
"the",
"standard",
"US",
"keyboard",
"layout",
".",
"If",
"you",
"want",
"to",
"input",
"text",
"use",
"the",
"Unicode",
"character",
"callback",
"instead",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/input.go#L290-L292 |
150,924 | go-gl/glfw | v3.0/glfw/input.go | GetMouseButton | func (w *Window) GetMouseButton(button MouseButton) Action {
return Action(C.glfwGetMouseButton(w.data, C.int(button)))
} | go | func (w *Window) GetMouseButton(button MouseButton) Action {
return Action(C.glfwGetMouseButton(w.data, C.int(button)))
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetMouseButton",
"(",
"button",
"MouseButton",
")",
"Action",
"{",
"return",
"Action",
"(",
"C",
".",
"glfwGetMouseButton",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"button",
")",
")",
")",
"\n",
"}"
] | //GetMouseButton returns the last state reported for the specified mouse button.
//
//If the StickyMouseButtons input mode is enabled, this function returns Press
//the first time you call this function after a mouse button has been pressed,
//even if the mouse button has already been released. | [
"GetMouseButton",
"returns",
"the",
"last",
"state",
"reported",
"for",
"the",
"specified",
"mouse",
"button",
".",
"If",
"the",
"StickyMouseButtons",
"input",
"mode",
"is",
"enabled",
"this",
"function",
"returns",
"Press",
"the",
"first",
"time",
"you",
"call",
"this",
"function",
"after",
"a",
"mouse",
"button",
"has",
"been",
"pressed",
"even",
"if",
"the",
"mouse",
"button",
"has",
"already",
"been",
"released",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/input.go#L299-L301 |
150,925 | go-gl/glfw | v3.0/glfw/input.go | SetCharacterCallback | func (w *Window) SetCharacterCallback(cbfun func(w *Window, char uint)) {
if cbfun == nil {
C.glfwSetCharCallback(w.data, nil)
} else {
w.fCharHolder = cbfun
C.glfwSetCharCallbackCB(w.data)
}
} | go | func (w *Window) SetCharacterCallback(cbfun func(w *Window, char uint)) {
if cbfun == nil {
C.glfwSetCharCallback(w.data, nil)
} else {
w.fCharHolder = cbfun
C.glfwSetCharCallbackCB(w.data)
}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetCharacterCallback",
"(",
"cbfun",
"func",
"(",
"w",
"*",
"Window",
",",
"char",
"uint",
")",
")",
"{",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetCharCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"fCharHolder",
"=",
"cbfun",
"\n",
"C",
".",
"glfwSetCharCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"}"
] | //SetCharacterCallback sets the character callback which is called when a
//Unicode character is input.
//
//The character callback is intended for text input. If you want to know whether
//a specific key was pressed or released, use the key callback instead. | [
"SetCharacterCallback",
"sets",
"the",
"character",
"callback",
"which",
"is",
"called",
"when",
"a",
"Unicode",
"character",
"is",
"input",
".",
"The",
"character",
"callback",
"is",
"intended",
"for",
"text",
"input",
".",
"If",
"you",
"want",
"to",
"know",
"whether",
"a",
"specific",
"key",
"was",
"pressed",
"or",
"released",
"use",
"the",
"key",
"callback",
"instead",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/input.go#L354-L361 |
150,926 | go-gl/glfw | v3.0/glfw/input.go | SetCursorPositionCallback | func (w *Window) SetCursorPositionCallback(cbfun func(w *Window, xpos float64, ypos float64)) {
if cbfun == nil {
C.glfwSetCursorPosCallback(w.data, nil)
} else {
w.fCursorPosHolder = cbfun
C.glfwSetCursorPosCallbackCB(w.data)
}
} | go | func (w *Window) SetCursorPositionCallback(cbfun func(w *Window, xpos float64, ypos float64)) {
if cbfun == nil {
C.glfwSetCursorPosCallback(w.data, nil)
} else {
w.fCursorPosHolder = cbfun
C.glfwSetCursorPosCallbackCB(w.data)
}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetCursorPositionCallback",
"(",
"cbfun",
"func",
"(",
"w",
"*",
"Window",
",",
"xpos",
"float64",
",",
"ypos",
"float64",
")",
")",
"{",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetCursorPosCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"fCursorPosHolder",
"=",
"cbfun",
"\n",
"C",
".",
"glfwSetCursorPosCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"}"
] | //SetCursorPositionCallback sets the cursor position callback which is called
//when the cursor is moved. The callback is provided with the position relative
//to the upper-left corner of the client area of the window. | [
"SetCursorPositionCallback",
"sets",
"the",
"cursor",
"position",
"callback",
"which",
"is",
"called",
"when",
"the",
"cursor",
"is",
"moved",
".",
"The",
"callback",
"is",
"provided",
"with",
"the",
"position",
"relative",
"to",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/input.go#L383-L390 |
150,927 | go-gl/glfw | v3.0/glfw/input.go | GetJoystickButtons | func GetJoystickButtons(joy Joystick) ([]byte, error) {
var length int
buttons := C.glfwGetJoystickButtons(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
if buttons == nil {
return nil, errors.New("Joystick is not present.")
}
b := make([]byte, length)
for i := 0; i < length; i++ {
b[i] = byte(C.GetButtonsAtIndex(buttons, C.int(i)))
}
return b, nil
} | go | func GetJoystickButtons(joy Joystick) ([]byte, error) {
var length int
buttons := C.glfwGetJoystickButtons(C.int(joy), (*C.int)(unsafe.Pointer(&length)))
if buttons == nil {
return nil, errors.New("Joystick is not present.")
}
b := make([]byte, length)
for i := 0; i < length; i++ {
b[i] = byte(C.GetButtonsAtIndex(buttons, C.int(i)))
}
return b, nil
} | [
"func",
"GetJoystickButtons",
"(",
"joy",
"Joystick",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"var",
"length",
"int",
"\n\n",
"buttons",
":=",
"C",
".",
"glfwGetJoystickButtons",
"(",
"C",
".",
"int",
"(",
"joy",
")",
",",
"(",
"*",
"C",
".",
"int",
")",
"(",
"unsafe",
".",
"Pointer",
"(",
"&",
"length",
")",
")",
")",
"\n",
"if",
"buttons",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n\n",
"b",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"length",
")",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"length",
";",
"i",
"++",
"{",
"b",
"[",
"i",
"]",
"=",
"byte",
"(",
"C",
".",
"GetButtonsAtIndex",
"(",
"buttons",
",",
"C",
".",
"int",
"(",
"i",
")",
")",
")",
"\n",
"}",
"\n\n",
"return",
"b",
",",
"nil",
"\n",
"}"
] | //GetJoystickButtons returns a slice of button values. | [
"GetJoystickButtons",
"returns",
"a",
"slice",
"of",
"button",
"values",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/input.go#L437-L451 |
150,928 | go-gl/glfw | v3.0/glfw/window.go | GetPosition | func (w *Window) GetPosition() (x, y int) {
var xpos, ypos C.int
C.glfwGetWindowPos(w.data, &xpos, &ypos)
return int(xpos), int(ypos)
} | go | func (w *Window) GetPosition() (x, y int) {
var xpos, ypos C.int
C.glfwGetWindowPos(w.data, &xpos, &ypos)
return int(xpos), int(ypos)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetPosition",
"(",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"var",
"xpos",
",",
"ypos",
"C",
".",
"int",
"\n\n",
"C",
".",
"glfwGetWindowPos",
"(",
"w",
".",
"data",
",",
"&",
"xpos",
",",
"&",
"ypos",
")",
"\n",
"return",
"int",
"(",
"xpos",
")",
",",
"int",
"(",
"ypos",
")",
"\n",
"}"
] | //GetPosition returns the position, in screen coordinates, of the upper-left
//corner of the client area of the window. | [
"GetPosition",
"returns",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L300-L305 |
150,929 | go-gl/glfw | v3.0/glfw/window.go | GetSize | func (w *Window) GetSize() (width, height int) {
var wi, h C.int
C.glfwGetWindowSize(w.data, &wi, &h)
return int(wi), int(h)
} | go | func (w *Window) GetSize() (width, height int) {
var wi, h C.int
C.glfwGetWindowSize(w.data, &wi, &h)
return int(wi), int(h)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetSize",
"(",
")",
"(",
"width",
",",
"height",
"int",
")",
"{",
"var",
"wi",
",",
"h",
"C",
".",
"int",
"\n",
"C",
".",
"glfwGetWindowSize",
"(",
"w",
".",
"data",
",",
"&",
"wi",
",",
"&",
"h",
")",
"\n",
"return",
"int",
"(",
"wi",
")",
",",
"int",
"(",
"h",
")",
"\n",
"}"
] | //GetSize returns the size, in screen coordinates, of the client area of the
//specified window. | [
"GetSize",
"returns",
"the",
"size",
"in",
"screen",
"coordinates",
"of",
"the",
"client",
"area",
"of",
"the",
"specified",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L328-L332 |
150,930 | go-gl/glfw | v3.0/glfw/window.go | GetFramebufferSize | func (w *Window) GetFramebufferSize() (width, height int) {
var wi, h C.int
C.glfwGetFramebufferSize(w.data, &wi, &h)
return int(wi), int(h)
} | go | func (w *Window) GetFramebufferSize() (width, height int) {
var wi, h C.int
C.glfwGetFramebufferSize(w.data, &wi, &h)
return int(wi), int(h)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetFramebufferSize",
"(",
")",
"(",
"width",
",",
"height",
"int",
")",
"{",
"var",
"wi",
",",
"h",
"C",
".",
"int",
"\n",
"C",
".",
"glfwGetFramebufferSize",
"(",
"w",
".",
"data",
",",
"&",
"wi",
",",
"&",
"h",
")",
"\n",
"return",
"int",
"(",
"wi",
")",
",",
"int",
"(",
"h",
")",
"\n",
"}"
] | //GetFramebufferSize retrieves the size, in pixels, of the framebuffer of the
//specified window. | [
"GetFramebufferSize",
"retrieves",
"the",
"size",
"in",
"pixels",
"of",
"the",
"framebuffer",
"of",
"the",
"specified",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L351-L355 |
150,931 | go-gl/glfw | v3.0/glfw/window.go | GetMonitor | func (w *Window) GetMonitor() (*Monitor, error) {
m := C.glfwGetWindowMonitor(w.data)
if m == nil {
return nil, errors.New("Can't get the monitor.")
}
return &Monitor{m}, nil
} | go | func (w *Window) GetMonitor() (*Monitor, error) {
m := C.glfwGetWindowMonitor(w.data)
if m == nil {
return nil, errors.New("Can't get the monitor.")
}
return &Monitor{m}, nil
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetMonitor",
"(",
")",
"(",
"*",
"Monitor",
",",
"error",
")",
"{",
"m",
":=",
"C",
".",
"glfwGetWindowMonitor",
"(",
"w",
".",
"data",
")",
"\n\n",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
",",
"errors",
".",
"New",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"return",
"&",
"Monitor",
"{",
"m",
"}",
",",
"nil",
"\n",
"}"
] | //GetMonitor returns the handle of the monitor that the window is in
//fullscreen on. | [
"GetMonitor",
"returns",
"the",
"handle",
"of",
"the",
"monitor",
"that",
"the",
"window",
"is",
"in",
"fullscreen",
"on",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L399-L406 |
150,932 | go-gl/glfw | v3.0/glfw/window.go | GetAttribute | func (w *Window) GetAttribute(attrib Hint) int {
return int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
} | go | func (w *Window) GetAttribute(attrib Hint) int {
return int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetAttribute",
"(",
"attrib",
"Hint",
")",
"int",
"{",
"return",
"int",
"(",
"C",
".",
"glfwGetWindowAttrib",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"attrib",
")",
")",
")",
"\n",
"}"
] | //GetAttribute returns an attribute of the window. There are many attributes,
//some related to the window and others to its context. | [
"GetAttribute",
"returns",
"an",
"attribute",
"of",
"the",
"window",
".",
"There",
"are",
"many",
"attributes",
"some",
"related",
"to",
"the",
"window",
"and",
"others",
"to",
"its",
"context",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L410-L412 |
150,933 | go-gl/glfw | v3.0/glfw/window.go | SetPositionCallback | func (w *Window) SetPositionCallback(cbfun func(w *Window, xpos int, ypos int)) {
if cbfun == nil {
C.glfwSetWindowPosCallback(w.data, nil)
} else {
w.fPosHolder = cbfun
C.glfwSetWindowPosCallbackCB(w.data)
}
} | go | func (w *Window) SetPositionCallback(cbfun func(w *Window, xpos int, ypos int)) {
if cbfun == nil {
C.glfwSetWindowPosCallback(w.data, nil)
} else {
w.fPosHolder = cbfun
C.glfwSetWindowPosCallbackCB(w.data)
}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetPositionCallback",
"(",
"cbfun",
"func",
"(",
"w",
"*",
"Window",
",",
"xpos",
"int",
",",
"ypos",
"int",
")",
")",
"{",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetWindowPosCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"fPosHolder",
"=",
"cbfun",
"\n",
"C",
".",
"glfwSetWindowPosCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"}"
] | //SetPositionCallback sets the position callback of the window, which is called
//when the window is moved. The callback is provided with the screen position
//of the upper-left corner of the client area of the window. | [
"SetPositionCallback",
"sets",
"the",
"position",
"callback",
"of",
"the",
"window",
"which",
"is",
"called",
"when",
"the",
"window",
"is",
"moved",
".",
"The",
"callback",
"is",
"provided",
"with",
"the",
"screen",
"position",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/window.go#L429-L436 |
150,934 | go-gl/glfw | v3.2/glfw/window.go | WindowHint | func WindowHint(target Hint, hint int) {
C.glfwWindowHint(C.int(target), C.int(hint))
panicError()
} | go | func WindowHint(target Hint, hint int) {
C.glfwWindowHint(C.int(target), C.int(hint))
panicError()
} | [
"func",
"WindowHint",
"(",
"target",
"Hint",
",",
"hint",
"int",
")",
"{",
"C",
".",
"glfwWindowHint",
"(",
"C",
".",
"int",
"(",
"target",
")",
",",
"C",
".",
"int",
"(",
"hint",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // WindowHint sets hints for the next call to CreateWindow. The hints,
// once set, retain their values until changed by a call to WindowHint or
// DefaultWindowHints, or until the library is terminated with Terminate.
//
// This function may only be called from the main thread. | [
"WindowHint",
"sets",
"hints",
"for",
"the",
"next",
"call",
"to",
"CreateWindow",
".",
"The",
"hints",
"once",
"set",
"retain",
"their",
"values",
"until",
"changed",
"by",
"a",
"call",
"to",
"WindowHint",
"or",
"DefaultWindowHints",
"or",
"until",
"the",
"library",
"is",
"terminated",
"with",
"Terminate",
".",
"This",
"function",
"may",
"only",
"be",
"called",
"from",
"the",
"main",
"thread",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L234-L237 |
150,935 | go-gl/glfw | v3.2/glfw/window.go | Destroy | func (w *Window) Destroy() {
windows.remove(w.data)
C.glfwDestroyWindow(w.data)
panicError()
} | go | func (w *Window) Destroy() {
windows.remove(w.data)
C.glfwDestroyWindow(w.data)
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Destroy",
"(",
")",
"{",
"windows",
".",
"remove",
"(",
"w",
".",
"data",
")",
"\n",
"C",
".",
"glfwDestroyWindow",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // Destroy destroys the specified window and its context. On calling this
// function, no further callbacks will be called for that window.
//
// This function may only be called from the main thread. | [
"Destroy",
"destroys",
"the",
"specified",
"window",
"and",
"its",
"context",
".",
"On",
"calling",
"this",
"function",
"no",
"further",
"callbacks",
"will",
"be",
"called",
"for",
"that",
"window",
".",
"This",
"function",
"may",
"only",
"be",
"called",
"from",
"the",
"main",
"thread",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L301-L305 |
150,936 | go-gl/glfw | v3.2/glfw/window.go | ShouldClose | func (w *Window) ShouldClose() bool {
ret := glfwbool(C.glfwWindowShouldClose(w.data))
panicError()
return ret
} | go | func (w *Window) ShouldClose() bool {
ret := glfwbool(C.glfwWindowShouldClose(w.data))
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"ShouldClose",
"(",
")",
"bool",
"{",
"ret",
":=",
"glfwbool",
"(",
"C",
".",
"glfwWindowShouldClose",
"(",
"w",
".",
"data",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // ShouldClose reports the value of the close flag of the specified window. | [
"ShouldClose",
"reports",
"the",
"value",
"of",
"the",
"close",
"flag",
"of",
"the",
"specified",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L308-L312 |
150,937 | go-gl/glfw | v3.2/glfw/window.go | SetShouldClose | func (w *Window) SetShouldClose(value bool) {
if !value {
C.glfwSetWindowShouldClose(w.data, C.int(False))
} else {
C.glfwSetWindowShouldClose(w.data, C.int(True))
}
panicError()
} | go | func (w *Window) SetShouldClose(value bool) {
if !value {
C.glfwSetWindowShouldClose(w.data, C.int(False))
} else {
C.glfwSetWindowShouldClose(w.data, C.int(True))
}
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetShouldClose",
"(",
"value",
"bool",
")",
"{",
"if",
"!",
"value",
"{",
"C",
".",
"glfwSetWindowShouldClose",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"False",
")",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetWindowShouldClose",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"True",
")",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetShouldClose sets the value of the close flag of the window. This can be
// used to override the user's attempt to close the window, or to signal that it
// should be closed. | [
"SetShouldClose",
"sets",
"the",
"value",
"of",
"the",
"close",
"flag",
"of",
"the",
"window",
".",
"This",
"can",
"be",
"used",
"to",
"override",
"the",
"user",
"s",
"attempt",
"to",
"close",
"the",
"window",
"or",
"to",
"signal",
"that",
"it",
"should",
"be",
"closed",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L317-L324 |
150,938 | go-gl/glfw | v3.2/glfw/window.go | GetPos | func (w *Window) GetPos() (x, y int) {
var xpos, ypos C.int
C.glfwGetWindowPos(w.data, &xpos, &ypos)
panicError()
return int(xpos), int(ypos)
} | go | func (w *Window) GetPos() (x, y int) {
var xpos, ypos C.int
C.glfwGetWindowPos(w.data, &xpos, &ypos)
panicError()
return int(xpos), int(ypos)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetPos",
"(",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"var",
"xpos",
",",
"ypos",
"C",
".",
"int",
"\n",
"C",
".",
"glfwGetWindowPos",
"(",
"w",
".",
"data",
",",
"&",
"xpos",
",",
"&",
"ypos",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"int",
"(",
"xpos",
")",
",",
"int",
"(",
"ypos",
")",
"\n",
"}"
] | // GetPos returns the position, in screen coordinates, of the upper-left
// corner of the client area of the window. | [
"GetPos",
"returns",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L389-L394 |
150,939 | go-gl/glfw | v3.2/glfw/window.go | SetSizeLimits | func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
C.glfwSetWindowSizeLimits(w.data, C.int(minw), C.int(minh), C.int(maxw), C.int(maxh))
panicError()
} | go | func (w *Window) SetSizeLimits(minw, minh, maxw, maxh int) {
C.glfwSetWindowSizeLimits(w.data, C.int(minw), C.int(minh), C.int(maxw), C.int(maxh))
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetSizeLimits",
"(",
"minw",
",",
"minh",
",",
"maxw",
",",
"maxh",
"int",
")",
"{",
"C",
".",
"glfwSetWindowSizeLimits",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"minw",
")",
",",
"C",
".",
"int",
"(",
"minh",
")",
",",
"C",
".",
"int",
"(",
"maxw",
")",
",",
"C",
".",
"int",
"(",
"maxh",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetSizeLimits sets the size limits of the client area of the specified window.
// If the window is full screen or not resizable, this function does nothing.
//
// The size limits are applied immediately and may cause the window to be resized. | [
"SetSizeLimits",
"sets",
"the",
"size",
"limits",
"of",
"the",
"client",
"area",
"of",
"the",
"specified",
"window",
".",
"If",
"the",
"window",
"is",
"full",
"screen",
"or",
"not",
"resizable",
"this",
"function",
"does",
"nothing",
".",
"The",
"size",
"limits",
"are",
"applied",
"immediately",
"and",
"may",
"cause",
"the",
"window",
"to",
"be",
"resized",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L443-L446 |
150,940 | go-gl/glfw | v3.2/glfw/window.go | GetFrameSize | func (w *Window) GetFrameSize() (left, top, right, bottom int) {
var l, t, r, b C.int
C.glfwGetWindowFrameSize(w.data, &l, &t, &r, &b)
panicError()
return int(l), int(t), int(r), int(b)
} | go | func (w *Window) GetFrameSize() (left, top, right, bottom int) {
var l, t, r, b C.int
C.glfwGetWindowFrameSize(w.data, &l, &t, &r, &b)
panicError()
return int(l), int(t), int(r), int(b)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetFrameSize",
"(",
")",
"(",
"left",
",",
"top",
",",
"right",
",",
"bottom",
"int",
")",
"{",
"var",
"l",
",",
"t",
",",
"r",
",",
"b",
"C",
".",
"int",
"\n",
"C",
".",
"glfwGetWindowFrameSize",
"(",
"w",
".",
"data",
",",
"&",
"l",
",",
"&",
"t",
",",
"&",
"r",
",",
"&",
"b",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"int",
"(",
"l",
")",
",",
"int",
"(",
"t",
")",
",",
"int",
"(",
"r",
")",
",",
"int",
"(",
"b",
")",
"\n",
"}"
] | // GetFrameSize retrieves the size, in screen coordinates, of each edge of the frame
// of the specified window. This size includes the title bar, if the window has one.
// The size of the frame may vary depending on the window-related hints used to create it.
//
// Because this function retrieves the size of each window frame edge and not the offset
// along a particular coordinate axis, the retrieved values will always be zero or positive. | [
"GetFrameSize",
"retrieves",
"the",
"size",
"in",
"screen",
"coordinates",
"of",
"each",
"edge",
"of",
"the",
"frame",
"of",
"the",
"specified",
"window",
".",
"This",
"size",
"includes",
"the",
"title",
"bar",
"if",
"the",
"window",
"has",
"one",
".",
"The",
"size",
"of",
"the",
"frame",
"may",
"vary",
"depending",
"on",
"the",
"window",
"-",
"related",
"hints",
"used",
"to",
"create",
"it",
".",
"Because",
"this",
"function",
"retrieves",
"the",
"size",
"of",
"each",
"window",
"frame",
"edge",
"and",
"not",
"the",
"offset",
"along",
"a",
"particular",
"coordinate",
"axis",
"the",
"retrieved",
"values",
"will",
"always",
"be",
"zero",
"or",
"positive",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L477-L482 |
150,941 | go-gl/glfw | v3.2/glfw/window.go | Focus | func (w *Window) Focus() error {
C.glfwFocusWindow(w.data)
return acceptError(APIUnavailable)
} | go | func (w *Window) Focus() error {
C.glfwFocusWindow(w.data)
return acceptError(APIUnavailable)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Focus",
"(",
")",
"error",
"{",
"C",
".",
"glfwFocusWindow",
"(",
"w",
".",
"data",
")",
"\n",
"return",
"acceptError",
"(",
"APIUnavailable",
")",
"\n",
"}"
] | // Focus brings the specified window to front and sets input focus.
// The window should already be visible and not iconified.
//
// By default, both windowed and full screen mode windows are focused when initially created.
// Set the glfw.Focused to disable this behavior.
//
// Do not use this function to steal focus from other applications unless you are certain that
// is what the user wants. Focus stealing can be extremely disruptive. | [
"Focus",
"brings",
"the",
"specified",
"window",
"to",
"front",
"and",
"sets",
"input",
"focus",
".",
"The",
"window",
"should",
"already",
"be",
"visible",
"and",
"not",
"iconified",
".",
"By",
"default",
"both",
"windowed",
"and",
"full",
"screen",
"mode",
"windows",
"are",
"focused",
"when",
"initially",
"created",
".",
"Set",
"the",
"glfw",
".",
"Focused",
"to",
"disable",
"this",
"behavior",
".",
"Do",
"not",
"use",
"this",
"function",
"to",
"steal",
"focus",
"from",
"other",
"applications",
"unless",
"you",
"are",
"certain",
"that",
"is",
"what",
"the",
"user",
"wants",
".",
"Focus",
"stealing",
"can",
"be",
"extremely",
"disruptive",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L492-L495 |
150,942 | go-gl/glfw | v3.2/glfw/window.go | Maximize | func (w *Window) Maximize() error {
C.glfwMaximizeWindow(w.data)
return acceptError(APIUnavailable)
} | go | func (w *Window) Maximize() error {
C.glfwMaximizeWindow(w.data)
return acceptError(APIUnavailable)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Maximize",
"(",
")",
"error",
"{",
"C",
".",
"glfwMaximizeWindow",
"(",
"w",
".",
"data",
")",
"\n",
"return",
"acceptError",
"(",
"APIUnavailable",
")",
"\n",
"}"
] | // Maximize maximizes the specified window if it was previously not maximized.
// If the window is already maximized, this function does nothing.
//
// If the specified window is a full screen window, this function does nothing. | [
"Maximize",
"maximizes",
"the",
"specified",
"window",
"if",
"it",
"was",
"previously",
"not",
"maximized",
".",
"If",
"the",
"window",
"is",
"already",
"maximized",
"this",
"function",
"does",
"nothing",
".",
"If",
"the",
"specified",
"window",
"is",
"a",
"full",
"screen",
"window",
"this",
"function",
"does",
"nothing",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L512-L515 |
150,943 | go-gl/glfw | v3.2/glfw/window.go | GetMonitor | func (w *Window) GetMonitor() *Monitor {
m := C.glfwGetWindowMonitor(w.data)
panicError()
if m == nil {
return nil
}
return &Monitor{m}
} | go | func (w *Window) GetMonitor() *Monitor {
m := C.glfwGetWindowMonitor(w.data)
panicError()
if m == nil {
return nil
}
return &Monitor{m}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetMonitor",
"(",
")",
"*",
"Monitor",
"{",
"m",
":=",
"C",
".",
"glfwGetWindowMonitor",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"if",
"m",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"Monitor",
"{",
"m",
"}",
"\n",
"}"
] | // GetMonitor returns the handle of the monitor that the window is in
// fullscreen on.
//
// Returns nil if the window is in windowed mode. | [
"GetMonitor",
"returns",
"the",
"handle",
"of",
"the",
"monitor",
"that",
"the",
"window",
"is",
"in",
"fullscreen",
"on",
".",
"Returns",
"nil",
"if",
"the",
"window",
"is",
"in",
"windowed",
"mode",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L550-L557 |
150,944 | go-gl/glfw | v3.2/glfw/window.go | SetMonitor | func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) {
var m *C.GLFWmonitor
if monitor == nil {
m = nil
} else {
m = monitor.data
}
C.glfwSetWindowMonitor(w.data, m, C.int(xpos), C.int(ypos), C.int(width), C.int(height), C.int(refreshRate))
panicError()
} | go | func (w *Window) SetMonitor(monitor *Monitor, xpos, ypos, width, height, refreshRate int) {
var m *C.GLFWmonitor
if monitor == nil {
m = nil
} else {
m = monitor.data
}
C.glfwSetWindowMonitor(w.data, m, C.int(xpos), C.int(ypos), C.int(width), C.int(height), C.int(refreshRate))
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetMonitor",
"(",
"monitor",
"*",
"Monitor",
",",
"xpos",
",",
"ypos",
",",
"width",
",",
"height",
",",
"refreshRate",
"int",
")",
"{",
"var",
"m",
"*",
"C",
".",
"GLFWmonitor",
"\n",
"if",
"monitor",
"==",
"nil",
"{",
"m",
"=",
"nil",
"\n",
"}",
"else",
"{",
"m",
"=",
"monitor",
".",
"data",
"\n",
"}",
"\n",
"C",
".",
"glfwSetWindowMonitor",
"(",
"w",
".",
"data",
",",
"m",
",",
"C",
".",
"int",
"(",
"xpos",
")",
",",
"C",
".",
"int",
"(",
"ypos",
")",
",",
"C",
".",
"int",
"(",
"width",
")",
",",
"C",
".",
"int",
"(",
"height",
")",
",",
"C",
".",
"int",
"(",
"refreshRate",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetMonitor sets the monitor that the window uses for full screen mode or,
// if the monitor is NULL, makes it windowed mode.
//
// When setting a monitor, this function updates the width, height and refresh
// rate of the desired video mode and switches to the video mode closest to it.
// The window position is ignored when setting a monitor.
//
// When the monitor is NULL, the position, width and height are used to place
// the window client area. The refresh rate is ignored when no monitor is specified.
// If you only wish to update the resolution of a full screen window or the size of
// a windowed mode window, see window.SetSize.
//
// When a window transitions from full screen to windowed mode, this function
// restores any previous window settings such as whether it is decorated, floating,
// resizable, has size or aspect ratio limits, etc.. | [
"SetMonitor",
"sets",
"the",
"monitor",
"that",
"the",
"window",
"uses",
"for",
"full",
"screen",
"mode",
"or",
"if",
"the",
"monitor",
"is",
"NULL",
"makes",
"it",
"windowed",
"mode",
".",
"When",
"setting",
"a",
"monitor",
"this",
"function",
"updates",
"the",
"width",
"height",
"and",
"refresh",
"rate",
"of",
"the",
"desired",
"video",
"mode",
"and",
"switches",
"to",
"the",
"video",
"mode",
"closest",
"to",
"it",
".",
"The",
"window",
"position",
"is",
"ignored",
"when",
"setting",
"a",
"monitor",
".",
"When",
"the",
"monitor",
"is",
"NULL",
"the",
"position",
"width",
"and",
"height",
"are",
"used",
"to",
"place",
"the",
"window",
"client",
"area",
".",
"The",
"refresh",
"rate",
"is",
"ignored",
"when",
"no",
"monitor",
"is",
"specified",
".",
"If",
"you",
"only",
"wish",
"to",
"update",
"the",
"resolution",
"of",
"a",
"full",
"screen",
"window",
"or",
"the",
"size",
"of",
"a",
"windowed",
"mode",
"window",
"see",
"window",
".",
"SetSize",
".",
"When",
"a",
"window",
"transitions",
"from",
"full",
"screen",
"to",
"windowed",
"mode",
"this",
"function",
"restores",
"any",
"previous",
"window",
"settings",
"such",
"as",
"whether",
"it",
"is",
"decorated",
"floating",
"resizable",
"has",
"size",
"or",
"aspect",
"ratio",
"limits",
"etc",
".."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L574-L583 |
150,945 | go-gl/glfw | v3.2/glfw/window.go | GetAttrib | func (w *Window) GetAttrib(attrib Hint) int {
ret := int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
panicError()
return ret
} | go | func (w *Window) GetAttrib(attrib Hint) int {
ret := int(C.glfwGetWindowAttrib(w.data, C.int(attrib)))
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetAttrib",
"(",
"attrib",
"Hint",
")",
"int",
"{",
"ret",
":=",
"int",
"(",
"C",
".",
"glfwGetWindowAttrib",
"(",
"w",
".",
"data",
",",
"C",
".",
"int",
"(",
"attrib",
")",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetAttrib returns an attribute of the window. There are many attributes,
// some related to the window and others to its context. | [
"GetAttrib",
"returns",
"an",
"attribute",
"of",
"the",
"window",
".",
"There",
"are",
"many",
"attributes",
"some",
"related",
"to",
"the",
"window",
"and",
"others",
"to",
"its",
"context",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L587-L591 |
150,946 | go-gl/glfw | v3.2/glfw/window.go | SetUserPointer | func (w *Window) SetUserPointer(pointer unsafe.Pointer) {
C.glfwSetWindowUserPointer(w.data, pointer)
panicError()
} | go | func (w *Window) SetUserPointer(pointer unsafe.Pointer) {
C.glfwSetWindowUserPointer(w.data, pointer)
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetUserPointer",
"(",
"pointer",
"unsafe",
".",
"Pointer",
")",
"{",
"C",
".",
"glfwSetWindowUserPointer",
"(",
"w",
".",
"data",
",",
"pointer",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetUserPointer sets the user-defined pointer of the window. The current value
// is retained until the window is destroyed. The initial value is nil. | [
"SetUserPointer",
"sets",
"the",
"user",
"-",
"defined",
"pointer",
"of",
"the",
"window",
".",
"The",
"current",
"value",
"is",
"retained",
"until",
"the",
"window",
"is",
"destroyed",
".",
"The",
"initial",
"value",
"is",
"nil",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L595-L598 |
150,947 | go-gl/glfw | v3.2/glfw/window.go | GetUserPointer | func (w *Window) GetUserPointer() unsafe.Pointer {
ret := C.glfwGetWindowUserPointer(w.data)
panicError()
return ret
} | go | func (w *Window) GetUserPointer() unsafe.Pointer {
ret := C.glfwGetWindowUserPointer(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetUserPointer",
"(",
")",
"unsafe",
".",
"Pointer",
"{",
"ret",
":=",
"C",
".",
"glfwGetWindowUserPointer",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetUserPointer returns the current value of the user-defined pointer of the
// window. The initial value is nil. | [
"GetUserPointer",
"returns",
"the",
"current",
"value",
"of",
"the",
"user",
"-",
"defined",
"pointer",
"of",
"the",
"window",
".",
"The",
"initial",
"value",
"is",
"nil",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L602-L606 |
150,948 | go-gl/glfw | v3.2/glfw/window.go | SetPosCallback | func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback) {
previous = w.fPosHolder
w.fPosHolder = cbfun
if cbfun == nil {
C.glfwSetWindowPosCallback(w.data, nil)
} else {
C.glfwSetWindowPosCallbackCB(w.data)
}
panicError()
return previous
} | go | func (w *Window) SetPosCallback(cbfun PosCallback) (previous PosCallback) {
previous = w.fPosHolder
w.fPosHolder = cbfun
if cbfun == nil {
C.glfwSetWindowPosCallback(w.data, nil)
} else {
C.glfwSetWindowPosCallbackCB(w.data)
}
panicError()
return previous
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetPosCallback",
"(",
"cbfun",
"PosCallback",
")",
"(",
"previous",
"PosCallback",
")",
"{",
"previous",
"=",
"w",
".",
"fPosHolder",
"\n",
"w",
".",
"fPosHolder",
"=",
"cbfun",
"\n",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetWindowPosCallback",
"(",
"w",
".",
"data",
",",
"nil",
")",
"\n",
"}",
"else",
"{",
"C",
".",
"glfwSetWindowPosCallbackCB",
"(",
"w",
".",
"data",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"previous",
"\n",
"}"
] | // SetPosCallback sets the position callback of the window, which is called
// when the window is moved. The callback is provided with the screen position
// of the upper-left corner of the client area of the window. | [
"SetPosCallback",
"sets",
"the",
"position",
"callback",
"of",
"the",
"window",
"which",
"is",
"called",
"when",
"the",
"window",
"is",
"moved",
".",
"The",
"callback",
"is",
"provided",
"with",
"the",
"screen",
"position",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L614-L624 |
150,949 | go-gl/glfw | v3.2/glfw/window.go | SetClipboardString | func (w *Window) SetClipboardString(str string) {
cp := C.CString(str)
defer C.free(unsafe.Pointer(cp))
C.glfwSetClipboardString(w.data, cp)
panicError()
} | go | func (w *Window) SetClipboardString(str string) {
cp := C.CString(str)
defer C.free(unsafe.Pointer(cp))
C.glfwSetClipboardString(w.data, cp)
panicError()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetClipboardString",
"(",
"str",
"string",
")",
"{",
"cp",
":=",
"C",
".",
"CString",
"(",
"str",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"cp",
")",
")",
"\n",
"C",
".",
"glfwSetClipboardString",
"(",
"w",
".",
"data",
",",
"cp",
")",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetClipboardString sets the system clipboard to the specified UTF-8 encoded
// string.
//
// This function may only be called from the main thread. | [
"SetClipboardString",
"sets",
"the",
"system",
"clipboard",
"to",
"the",
"specified",
"UTF",
"-",
"8",
"encoded",
"string",
".",
"This",
"function",
"may",
"only",
"be",
"called",
"from",
"the",
"main",
"thread",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L749-L754 |
150,950 | go-gl/glfw | v3.2/glfw/window.go | GetClipboardString | func (w *Window) GetClipboardString() (string, error) {
cs := C.glfwGetClipboardString(w.data)
if cs == nil {
return "", acceptError(FormatUnavailable)
}
return C.GoString(cs), nil
} | go | func (w *Window) GetClipboardString() (string, error) {
cs := C.glfwGetClipboardString(w.data)
if cs == nil {
return "", acceptError(FormatUnavailable)
}
return C.GoString(cs), nil
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetClipboardString",
"(",
")",
"(",
"string",
",",
"error",
")",
"{",
"cs",
":=",
"C",
".",
"glfwGetClipboardString",
"(",
"w",
".",
"data",
")",
"\n",
"if",
"cs",
"==",
"nil",
"{",
"return",
"\"",
"\"",
",",
"acceptError",
"(",
"FormatUnavailable",
")",
"\n",
"}",
"\n",
"return",
"C",
".",
"GoString",
"(",
"cs",
")",
",",
"nil",
"\n",
"}"
] | // GetClipboardString returns the contents of the system clipboard, if it
// contains or is convertible to a UTF-8 encoded string.
//
// This function may only be called from the main thread. | [
"GetClipboardString",
"returns",
"the",
"contents",
"of",
"the",
"system",
"clipboard",
"if",
"it",
"contains",
"or",
"is",
"convertible",
"to",
"a",
"UTF",
"-",
"8",
"encoded",
"string",
".",
"This",
"function",
"may",
"only",
"be",
"called",
"from",
"the",
"main",
"thread",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/window.go#L760-L766 |
150,951 | go-gl/glfw | v3.2/glfw/native_darwin.go | GetCocoaMonitor | func (m *Monitor) GetCocoaMonitor() uintptr {
ret := uintptr(C.glfwGetCocoaMonitor(m.data))
panicError()
return ret
} | go | func (m *Monitor) GetCocoaMonitor() uintptr {
ret := uintptr(C.glfwGetCocoaMonitor(m.data))
panicError()
return ret
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetCocoaMonitor",
"(",
")",
"uintptr",
"{",
"ret",
":=",
"uintptr",
"(",
"C",
".",
"glfwGetCocoaMonitor",
"(",
"m",
".",
"data",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetCocoaMonitor returns the CGDirectDisplayID of the monitor. | [
"GetCocoaMonitor",
"returns",
"the",
"CGDirectDisplayID",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_darwin.go#L21-L25 |
150,952 | go-gl/glfw | v3.2/glfw/native_darwin.go | GetCocoaWindow | func (w *Window) GetCocoaWindow() uintptr {
ret := uintptr(C.workaround_glfwGetCocoaWindow(w.data))
panicError()
return ret
} | go | func (w *Window) GetCocoaWindow() uintptr {
ret := uintptr(C.workaround_glfwGetCocoaWindow(w.data))
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetCocoaWindow",
"(",
")",
"uintptr",
"{",
"ret",
":=",
"uintptr",
"(",
"C",
".",
"workaround_glfwGetCocoaWindow",
"(",
"w",
".",
"data",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetCocoaWindow returns the NSWindow of the window. | [
"GetCocoaWindow",
"returns",
"the",
"NSWindow",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_darwin.go#L28-L32 |
150,953 | go-gl/glfw | v3.2/glfw/native_darwin.go | GetNSGLContext | func (w *Window) GetNSGLContext() uintptr {
ret := uintptr(C.workaround_glfwGetNSGLContext(w.data))
panicError()
return ret
} | go | func (w *Window) GetNSGLContext() uintptr {
ret := uintptr(C.workaround_glfwGetNSGLContext(w.data))
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetNSGLContext",
"(",
")",
"uintptr",
"{",
"ret",
":=",
"uintptr",
"(",
"C",
".",
"workaround_glfwGetNSGLContext",
"(",
"w",
".",
"data",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetNSGLContext returns the NSOpenGLContext of the window. | [
"GetNSGLContext",
"returns",
"the",
"NSOpenGLContext",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_darwin.go#L35-L39 |
150,954 | go-gl/glfw | v3.2/glfw/native_linbsd.go | GetX11Adapter | func (m *Monitor) GetX11Adapter() C.RRCrtc {
ret := C.glfwGetX11Adapter(m.data)
panicError()
return ret
} | go | func (m *Monitor) GetX11Adapter() C.RRCrtc {
ret := C.glfwGetX11Adapter(m.data)
panicError()
return ret
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetX11Adapter",
"(",
")",
"C",
".",
"RRCrtc",
"{",
"ret",
":=",
"C",
".",
"glfwGetX11Adapter",
"(",
"m",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetX11Adapter returns the RRCrtc of the monitor. | [
"GetX11Adapter",
"returns",
"the",
"RRCrtc",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_linbsd.go#L19-L23 |
150,955 | go-gl/glfw | v3.2/glfw/native_linbsd.go | GetX11Monitor | func (m *Monitor) GetX11Monitor() C.RROutput {
ret := C.glfwGetX11Monitor(m.data)
panicError()
return ret
} | go | func (m *Monitor) GetX11Monitor() C.RROutput {
ret := C.glfwGetX11Monitor(m.data)
panicError()
return ret
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetX11Monitor",
"(",
")",
"C",
".",
"RROutput",
"{",
"ret",
":=",
"C",
".",
"glfwGetX11Monitor",
"(",
"m",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetX11Monitor returns the RROutput of the monitor. | [
"GetX11Monitor",
"returns",
"the",
"RROutput",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_linbsd.go#L26-L30 |
150,956 | go-gl/glfw | v3.2/glfw/native_linbsd.go | GetX11Window | func (w *Window) GetX11Window() C.Window {
ret := C.glfwGetX11Window(w.data)
panicError()
return ret
} | go | func (w *Window) GetX11Window() C.Window {
ret := C.glfwGetX11Window(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetX11Window",
"(",
")",
"C",
".",
"Window",
"{",
"ret",
":=",
"C",
".",
"glfwGetX11Window",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetX11Window returns the Window of the window. | [
"GetX11Window",
"returns",
"the",
"Window",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_linbsd.go#L33-L37 |
150,957 | go-gl/glfw | v3.2/glfw/native_linbsd.go | GetGLXContext | func (w *Window) GetGLXContext() C.GLXContext {
ret := C.glfwGetGLXContext(w.data)
panicError()
return ret
} | go | func (w *Window) GetGLXContext() C.GLXContext {
ret := C.glfwGetGLXContext(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetGLXContext",
"(",
")",
"C",
".",
"GLXContext",
"{",
"ret",
":=",
"C",
".",
"glfwGetGLXContext",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetGLXContext returns the GLXContext of the window. | [
"GetGLXContext",
"returns",
"the",
"GLXContext",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_linbsd.go#L40-L44 |
150,958 | go-gl/glfw | v3.2/glfw/native_linbsd.go | GetGLXWindow | func (w *Window) GetGLXWindow() C.GLXWindow {
ret := C.glfwGetGLXWindow(w.data)
panicError()
return ret
} | go | func (w *Window) GetGLXWindow() C.GLXWindow {
ret := C.glfwGetGLXWindow(w.data)
panicError()
return ret
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetGLXWindow",
"(",
")",
"C",
".",
"GLXWindow",
"{",
"ret",
":=",
"C",
".",
"glfwGetGLXWindow",
"(",
"w",
".",
"data",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetGLXWindow returns the GLXWindow of the window. | [
"GetGLXWindow",
"returns",
"the",
"GLXWindow",
"of",
"the",
"window",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/native_linbsd.go#L47-L51 |
150,959 | go-gl/glfw | v3.0/glfw/error.go | SetErrorCallback | func SetErrorCallback(cbfun func(code ErrorCode, desc string)) {
if cbfun == nil {
C.glfwSetErrorCallback(nil)
} else {
fErrorHolder = cbfun
C.glfwSetErrorCallbackCB()
}
} | go | func SetErrorCallback(cbfun func(code ErrorCode, desc string)) {
if cbfun == nil {
C.glfwSetErrorCallback(nil)
} else {
fErrorHolder = cbfun
C.glfwSetErrorCallbackCB()
}
} | [
"func",
"SetErrorCallback",
"(",
"cbfun",
"func",
"(",
"code",
"ErrorCode",
",",
"desc",
"string",
")",
")",
"{",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetErrorCallback",
"(",
"nil",
")",
"\n",
"}",
"else",
"{",
"fErrorHolder",
"=",
"cbfun",
"\n",
"C",
".",
"glfwSetErrorCallbackCB",
"(",
")",
"\n",
"}",
"\n",
"}"
] | //SetErrorCallback sets the error callback, which is called with an error code
//and a human-readable description each time a GLFW error occurs.
//
//This function may be called before Init. | [
"SetErrorCallback",
"sets",
"the",
"error",
"callback",
"which",
"is",
"called",
"with",
"an",
"error",
"code",
"and",
"a",
"human",
"-",
"readable",
"description",
"each",
"time",
"a",
"GLFW",
"error",
"occurs",
".",
"This",
"function",
"may",
"be",
"called",
"before",
"Init",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.0/glfw/error.go#L35-L42 |
150,960 | go-gl/glfw | v3.2/glfw/context.go | ExtensionSupported | func ExtensionSupported(extension string) bool {
e := C.CString(extension)
defer C.free(unsafe.Pointer(e))
ret := glfwbool(C.glfwExtensionSupported(e))
panicError()
return ret
} | go | func ExtensionSupported(extension string) bool {
e := C.CString(extension)
defer C.free(unsafe.Pointer(e))
ret := glfwbool(C.glfwExtensionSupported(e))
panicError()
return ret
} | [
"func",
"ExtensionSupported",
"(",
"extension",
"string",
")",
"bool",
"{",
"e",
":=",
"C",
".",
"CString",
"(",
"extension",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"e",
")",
")",
"\n",
"ret",
":=",
"glfwbool",
"(",
"C",
".",
"glfwExtensionSupported",
"(",
"e",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // ExtensionSupported reports whether the specified OpenGL or context creation
// API extension is supported by the current context. For example, on Windows
// both the OpenGL and WGL extension strings are checked.
//
// As this functions searches one or more extension strings on each call, it is
// recommended that you cache its results if it's going to be used frequently.
// The extension strings will not change during the lifetime of a context, so
// there is no danger in doing this. | [
"ExtensionSupported",
"reports",
"whether",
"the",
"specified",
"OpenGL",
"or",
"context",
"creation",
"API",
"extension",
"is",
"supported",
"by",
"the",
"current",
"context",
".",
"For",
"example",
"on",
"Windows",
"both",
"the",
"OpenGL",
"and",
"WGL",
"extension",
"strings",
"are",
"checked",
".",
"As",
"this",
"functions",
"searches",
"one",
"or",
"more",
"extension",
"strings",
"on",
"each",
"call",
"it",
"is",
"recommended",
"that",
"you",
"cache",
"its",
"results",
"if",
"it",
"s",
"going",
"to",
"be",
"used",
"frequently",
".",
"The",
"extension",
"strings",
"will",
"not",
"change",
"during",
"the",
"lifetime",
"of",
"a",
"context",
"so",
"there",
"is",
"no",
"danger",
"in",
"doing",
"this",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/context.go#L72-L78 |
150,961 | go-gl/glfw | v3.2/glfw/context.go | GetProcAddress | func GetProcAddress(procname string) unsafe.Pointer {
p := C.CString(procname)
defer C.free(unsafe.Pointer(p))
ret := unsafe.Pointer(C.glfwGetProcAddress(p))
panicError()
return ret
} | go | func GetProcAddress(procname string) unsafe.Pointer {
p := C.CString(procname)
defer C.free(unsafe.Pointer(p))
ret := unsafe.Pointer(C.glfwGetProcAddress(p))
panicError()
return ret
} | [
"func",
"GetProcAddress",
"(",
"procname",
"string",
")",
"unsafe",
".",
"Pointer",
"{",
"p",
":=",
"C",
".",
"CString",
"(",
"procname",
")",
"\n",
"defer",
"C",
".",
"free",
"(",
"unsafe",
".",
"Pointer",
"(",
"p",
")",
")",
"\n",
"ret",
":=",
"unsafe",
".",
"Pointer",
"(",
"C",
".",
"glfwGetProcAddress",
"(",
"p",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // GetProcAddress returns the address of the specified OpenGL or OpenGL ES core
// or extension function, if it is supported by the current context.
//
// A context must be current on the calling thread. Calling this function
// without a current context will cause a GLFW_NO_CURRENT_CONTEXT error.
//
// This function is used to provide GL proc resolving capabilities to an
// external C library. | [
"GetProcAddress",
"returns",
"the",
"address",
"of",
"the",
"specified",
"OpenGL",
"or",
"OpenGL",
"ES",
"core",
"or",
"extension",
"function",
"if",
"it",
"is",
"supported",
"by",
"the",
"current",
"context",
".",
"A",
"context",
"must",
"be",
"current",
"on",
"the",
"calling",
"thread",
".",
"Calling",
"this",
"function",
"without",
"a",
"current",
"context",
"will",
"cause",
"a",
"GLFW_NO_CURRENT_CONTEXT",
"error",
".",
"This",
"function",
"is",
"used",
"to",
"provide",
"GL",
"proc",
"resolving",
"capabilities",
"to",
"an",
"external",
"C",
"library",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/context.go#L88-L94 |
150,962 | go-gl/glfw | v3.1/glfw/input.go | CreateCursor | func CreateCursor(img image.Image, xhot, yhot int) *Cursor {
var img_c C.GLFWimage
var pixels []uint8
b := img.Bounds()
switch img := img.(type) {
case *image.RGBA:
pixels = img.Pix
default:
m := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(m, m.Bounds(), img, b.Min, draw.Src)
pixels = m.Pix
}
pix, free := bytes(pixels)
img_c.width = C.int(b.Dx())
img_c.height = C.int(b.Dy())
img_c.pixels = (*C.uchar)(pix)
c := C.glfwCreateCursor(&img_c, C.int(xhot), C.int(yhot))
free()
panicError()
return &Cursor{c}
} | go | func CreateCursor(img image.Image, xhot, yhot int) *Cursor {
var img_c C.GLFWimage
var pixels []uint8
b := img.Bounds()
switch img := img.(type) {
case *image.RGBA:
pixels = img.Pix
default:
m := image.NewRGBA(image.Rect(0, 0, b.Dx(), b.Dy()))
draw.Draw(m, m.Bounds(), img, b.Min, draw.Src)
pixels = m.Pix
}
pix, free := bytes(pixels)
img_c.width = C.int(b.Dx())
img_c.height = C.int(b.Dy())
img_c.pixels = (*C.uchar)(pix)
c := C.glfwCreateCursor(&img_c, C.int(xhot), C.int(yhot))
free()
panicError()
return &Cursor{c}
} | [
"func",
"CreateCursor",
"(",
"img",
"image",
".",
"Image",
",",
"xhot",
",",
"yhot",
"int",
")",
"*",
"Cursor",
"{",
"var",
"img_c",
"C",
".",
"GLFWimage",
"\n",
"var",
"pixels",
"[",
"]",
"uint8",
"\n",
"b",
":=",
"img",
".",
"Bounds",
"(",
")",
"\n\n",
"switch",
"img",
":=",
"img",
".",
"(",
"type",
")",
"{",
"case",
"*",
"image",
".",
"RGBA",
":",
"pixels",
"=",
"img",
".",
"Pix",
"\n",
"default",
":",
"m",
":=",
"image",
".",
"NewRGBA",
"(",
"image",
".",
"Rect",
"(",
"0",
",",
"0",
",",
"b",
".",
"Dx",
"(",
")",
",",
"b",
".",
"Dy",
"(",
")",
")",
")",
"\n",
"draw",
".",
"Draw",
"(",
"m",
",",
"m",
".",
"Bounds",
"(",
")",
",",
"img",
",",
"b",
".",
"Min",
",",
"draw",
".",
"Src",
")",
"\n",
"pixels",
"=",
"m",
".",
"Pix",
"\n",
"}",
"\n\n",
"pix",
",",
"free",
":=",
"bytes",
"(",
"pixels",
")",
"\n\n",
"img_c",
".",
"width",
"=",
"C",
".",
"int",
"(",
"b",
".",
"Dx",
"(",
")",
")",
"\n",
"img_c",
".",
"height",
"=",
"C",
".",
"int",
"(",
"b",
".",
"Dy",
"(",
")",
")",
"\n",
"img_c",
".",
"pixels",
"=",
"(",
"*",
"C",
".",
"uchar",
")",
"(",
"pix",
")",
"\n\n",
"c",
":=",
"C",
".",
"glfwCreateCursor",
"(",
"&",
"img_c",
",",
"C",
".",
"int",
"(",
"xhot",
")",
",",
"C",
".",
"int",
"(",
"yhot",
")",
")",
"\n\n",
"free",
"(",
")",
"\n",
"panicError",
"(",
")",
"\n\n",
"return",
"&",
"Cursor",
"{",
"c",
"}",
"\n",
"}"
] | // Creates a new custom cursor image that can be set for a window with SetCursor.
// The cursor can be destroyed with Destroy. Any remaining cursors are destroyed by Terminate.
//
// The pixels are 32-bit little-endian RGBA, i.e. eight bits per channel. They are arranged
// canonically as packed sequential rows, starting from the top-left corner.
//
// All non-RGBA images will be converted to RGBA.
//
// The cursor hotspot is specified in pixels, relative to the upper-left corner of the cursor image.
// Like all other coordinate systems in GLFW, the X-axis points to the right and the Y-axis points down. | [
"Creates",
"a",
"new",
"custom",
"cursor",
"image",
"that",
"can",
"be",
"set",
"for",
"a",
"window",
"with",
"SetCursor",
".",
"The",
"cursor",
"can",
"be",
"destroyed",
"with",
"Destroy",
".",
"Any",
"remaining",
"cursors",
"are",
"destroyed",
"by",
"Terminate",
".",
"The",
"pixels",
"are",
"32",
"-",
"bit",
"little",
"-",
"endian",
"RGBA",
"i",
".",
"e",
".",
"eight",
"bits",
"per",
"channel",
".",
"They",
"are",
"arranged",
"canonically",
"as",
"packed",
"sequential",
"rows",
"starting",
"from",
"the",
"top",
"-",
"left",
"corner",
".",
"All",
"non",
"-",
"RGBA",
"images",
"will",
"be",
"converted",
"to",
"RGBA",
".",
"The",
"cursor",
"hotspot",
"is",
"specified",
"in",
"pixels",
"relative",
"to",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"cursor",
"image",
".",
"Like",
"all",
"other",
"coordinate",
"systems",
"in",
"GLFW",
"the",
"X",
"-",
"axis",
"points",
"to",
"the",
"right",
"and",
"the",
"Y",
"-",
"axis",
"points",
"down",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.1/glfw/input.go#L383-L409 |
150,963 | go-gl/glfw | v3.1/glfw/input.go | CreateStandardCursor | func CreateStandardCursor(shape int) *Cursor {
c := C.glfwCreateStandardCursor(C.int(shape))
panicError()
return &Cursor{c}
} | go | func CreateStandardCursor(shape int) *Cursor {
c := C.glfwCreateStandardCursor(C.int(shape))
panicError()
return &Cursor{c}
} | [
"func",
"CreateStandardCursor",
"(",
"shape",
"int",
")",
"*",
"Cursor",
"{",
"c",
":=",
"C",
".",
"glfwCreateStandardCursor",
"(",
"C",
".",
"int",
"(",
"shape",
")",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"&",
"Cursor",
"{",
"c",
"}",
"\n",
"}"
] | // Returns a cursor with a standard shape, that can be set for a window with SetCursor. | [
"Returns",
"a",
"cursor",
"with",
"a",
"standard",
"shape",
"that",
"can",
"be",
"set",
"for",
"a",
"window",
"with",
"SetCursor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.1/glfw/input.go#L412-L416 |
150,964 | go-gl/glfw | v3.2/glfw/monitor.go | GetPos | func (m *Monitor) GetPos() (x, y int) {
var xpos, ypos C.int
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
panicError()
return int(xpos), int(ypos)
} | go | func (m *Monitor) GetPos() (x, y int) {
var xpos, ypos C.int
C.glfwGetMonitorPos(m.data, &xpos, &ypos)
panicError()
return int(xpos), int(ypos)
} | [
"func",
"(",
"m",
"*",
"Monitor",
")",
"GetPos",
"(",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"var",
"xpos",
",",
"ypos",
"C",
".",
"int",
"\n",
"C",
".",
"glfwGetMonitorPos",
"(",
"m",
".",
"data",
",",
"&",
"xpos",
",",
"&",
"ypos",
")",
"\n",
"panicError",
"(",
")",
"\n",
"return",
"int",
"(",
"xpos",
")",
",",
"int",
"(",
"ypos",
")",
"\n",
"}"
] | // GetPos returns the position, in screen coordinates, of the upper-left
// corner of the monitor. | [
"GetPos",
"returns",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"monitor",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/monitor.go#L86-L91 |
150,965 | go-gl/glfw | v3.2/glfw/monitor.go | SetMonitorCallback | func SetMonitorCallback(cbfun func(monitor *Monitor, event MonitorEvent)) {
if cbfun == nil {
C.glfwSetMonitorCallback(nil)
} else {
fMonitorHolder = cbfun
C.glfwSetMonitorCallbackCB()
}
panicError()
} | go | func SetMonitorCallback(cbfun func(monitor *Monitor, event MonitorEvent)) {
if cbfun == nil {
C.glfwSetMonitorCallback(nil)
} else {
fMonitorHolder = cbfun
C.glfwSetMonitorCallbackCB()
}
panicError()
} | [
"func",
"SetMonitorCallback",
"(",
"cbfun",
"func",
"(",
"monitor",
"*",
"Monitor",
",",
"event",
"MonitorEvent",
")",
")",
"{",
"if",
"cbfun",
"==",
"nil",
"{",
"C",
".",
"glfwSetMonitorCallback",
"(",
"nil",
")",
"\n",
"}",
"else",
"{",
"fMonitorHolder",
"=",
"cbfun",
"\n",
"C",
".",
"glfwSetMonitorCallbackCB",
"(",
")",
"\n",
"}",
"\n",
"panicError",
"(",
")",
"\n",
"}"
] | // SetMonitorCallback sets the monitor configuration callback, or removes the
// currently set callback. This is called when a monitor is connected to or
// disconnected from the system. | [
"SetMonitorCallback",
"sets",
"the",
"monitor",
"configuration",
"callback",
"or",
"removes",
"the",
"currently",
"set",
"callback",
".",
"This",
"is",
"called",
"when",
"a",
"monitor",
"is",
"connected",
"to",
"or",
"disconnected",
"from",
"the",
"system",
"."
] | e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc | https://github.com/go-gl/glfw/blob/e6da0acd62b1b57ee2799d4d0a76a7d4514dc5bc/v3.2/glfw/monitor.go#L119-L127 |
150,966 | karrick/godirwalk | dirent.go | NewDirent | func NewDirent(osPathname string) (*Dirent, error) {
fi, err := os.Lstat(osPathname)
if err != nil {
return nil, err
}
return &Dirent{
name: filepath.Base(osPathname),
modeType: fi.Mode() & os.ModeType,
}, nil
} | go | func NewDirent(osPathname string) (*Dirent, error) {
fi, err := os.Lstat(osPathname)
if err != nil {
return nil, err
}
return &Dirent{
name: filepath.Base(osPathname),
modeType: fi.Mode() & os.ModeType,
}, nil
} | [
"func",
"NewDirent",
"(",
"osPathname",
"string",
")",
"(",
"*",
"Dirent",
",",
"error",
")",
"{",
"fi",
",",
"err",
":=",
"os",
".",
"Lstat",
"(",
"osPathname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"return",
"&",
"Dirent",
"{",
"name",
":",
"filepath",
".",
"Base",
"(",
"osPathname",
")",
",",
"modeType",
":",
"fi",
".",
"Mode",
"(",
")",
"&",
"os",
".",
"ModeType",
",",
"}",
",",
"nil",
"\n",
"}"
] | // NewDirent returns a newly initialized Dirent structure, or an error. This
// function does not follow symbolic links.
//
// This function is rarely used, as Dirent structures are provided by other
// functions in this library that read and walk directories. | [
"NewDirent",
"returns",
"a",
"newly",
"initialized",
"Dirent",
"structure",
"or",
"an",
"error",
".",
"This",
"function",
"does",
"not",
"follow",
"symbolic",
"links",
".",
"This",
"function",
"is",
"rarely",
"used",
"as",
"Dirent",
"structures",
"are",
"provided",
"by",
"other",
"functions",
"in",
"this",
"library",
"that",
"read",
"and",
"walk",
"directories",
"."
] | 808a2f88690f523a3fb074bc6626124660bc80eb | https://github.com/karrick/godirwalk/blob/808a2f88690f523a3fb074bc6626124660bc80eb/dirent.go#L20-L29 |
150,967 | karrick/godirwalk | readdir_windows.go | readdirents | func readdirents(osDirname string, _ []byte) (Dirents, error) {
dh, err := os.Open(osDirname)
if err != nil {
return nil, err
}
fileinfos, err := dh.Readdir(0)
if er := dh.Close(); err == nil {
err = er
}
if err != nil {
return nil, err
}
entries := make(Dirents, len(fileinfos))
for i, info := range fileinfos {
entries[i] = &Dirent{name: info.Name(), modeType: info.Mode() & os.ModeType}
}
return entries, nil
} | go | func readdirents(osDirname string, _ []byte) (Dirents, error) {
dh, err := os.Open(osDirname)
if err != nil {
return nil, err
}
fileinfos, err := dh.Readdir(0)
if er := dh.Close(); err == nil {
err = er
}
if err != nil {
return nil, err
}
entries := make(Dirents, len(fileinfos))
for i, info := range fileinfos {
entries[i] = &Dirent{name: info.Name(), modeType: info.Mode() & os.ModeType}
}
return entries, nil
} | [
"func",
"readdirents",
"(",
"osDirname",
"string",
",",
"_",
"[",
"]",
"byte",
")",
"(",
"Dirents",
",",
"error",
")",
"{",
"dh",
",",
"err",
":=",
"os",
".",
"Open",
"(",
"osDirname",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"fileinfos",
",",
"err",
":=",
"dh",
".",
"Readdir",
"(",
"0",
")",
"\n",
"if",
"er",
":=",
"dh",
".",
"Close",
"(",
")",
";",
"err",
"==",
"nil",
"{",
"err",
"=",
"er",
"\n",
"}",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n\n",
"entries",
":=",
"make",
"(",
"Dirents",
",",
"len",
"(",
"fileinfos",
")",
")",
"\n",
"for",
"i",
",",
"info",
":=",
"range",
"fileinfos",
"{",
"entries",
"[",
"i",
"]",
"=",
"&",
"Dirent",
"{",
"name",
":",
"info",
".",
"Name",
"(",
")",
",",
"modeType",
":",
"info",
".",
"Mode",
"(",
")",
"&",
"os",
".",
"ModeType",
"}",
"\n",
"}",
"\n\n",
"return",
"entries",
",",
"nil",
"\n",
"}"
] | // The functions in this file are mere wrappers of what is already provided by
// standard library, in order to provide the same API as this library provides.
//
// The scratch buffer argument is ignored by this architecture.
//
// Please send PR or link to article if you know of a more performant way of
// enumerating directory contents and mode types on Windows. | [
"The",
"functions",
"in",
"this",
"file",
"are",
"mere",
"wrappers",
"of",
"what",
"is",
"already",
"provided",
"by",
"standard",
"library",
"in",
"order",
"to",
"provide",
"the",
"same",
"API",
"as",
"this",
"library",
"provides",
".",
"The",
"scratch",
"buffer",
"argument",
"is",
"ignored",
"by",
"this",
"architecture",
".",
"Please",
"send",
"PR",
"or",
"link",
"to",
"article",
"if",
"you",
"know",
"of",
"a",
"more",
"performant",
"way",
"of",
"enumerating",
"directory",
"contents",
"and",
"mode",
"types",
"on",
"Windows",
"."
] | 808a2f88690f523a3fb074bc6626124660bc80eb | https://github.com/karrick/godirwalk/blob/808a2f88690f523a3fb074bc6626124660bc80eb/readdir_windows.go#L15-L35 |
150,968 | karrick/godirwalk | walk.go | walk | func walk(osPathname string, dirent *Dirent, options *Options) error {
err := options.Callback(osPathname, dirent)
if err != nil {
if err == filepath.SkipDir {
return err
}
err = errCallback(err.Error()) // wrap potential errors returned by callback
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
}
// On some platforms, an entry can have more than one mode type bit set.
// For instance, it could have both the symlink bit and the directory bit
// set indicating it's a symlink to a directory.
if dirent.IsSymlink() {
if !options.FollowSymbolicLinks {
return nil
}
skip, err := symlinkDirHelper(osPathname, dirent, options)
if err != nil || skip {
return err
}
}
if !dirent.IsDir() {
return nil
}
// If get here, then specified pathname refers to a directory.
deChildren, err := ReadDirents(osPathname, options.ScratchBuffer)
if err != nil {
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
}
if !options.Unsorted {
sort.Sort(deChildren) // sort children entries unless upstream says to leave unsorted
}
for _, deChild := range deChildren {
osChildname := filepath.Join(osPathname, deChild.name)
err = walk(osChildname, deChild, options)
if err != nil {
if err != filepath.SkipDir {
return err
}
// If received skipdir on a directory, stop processing that
// directory, but continue to its siblings. If received skipdir on a
// non-directory, stop processing remaining siblings.
if deChild.IsSymlink() {
var skip bool
if skip, err = symlinkDirHelper(osChildname, deChild, options); err != nil {
return err
}
if skip {
continue
}
}
if !deChild.IsDir() {
// If not directory, return immediately, thus skipping remainder
// of siblings.
return nil
}
}
}
if options.PostChildrenCallback == nil {
return nil
}
err = options.PostChildrenCallback(osPathname, dirent)
if err == nil || err == filepath.SkipDir {
return err
}
err = errCallback(err.Error()) // wrap potential errors returned by callback
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
} | go | func walk(osPathname string, dirent *Dirent, options *Options) error {
err := options.Callback(osPathname, dirent)
if err != nil {
if err == filepath.SkipDir {
return err
}
err = errCallback(err.Error()) // wrap potential errors returned by callback
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
}
// On some platforms, an entry can have more than one mode type bit set.
// For instance, it could have both the symlink bit and the directory bit
// set indicating it's a symlink to a directory.
if dirent.IsSymlink() {
if !options.FollowSymbolicLinks {
return nil
}
skip, err := symlinkDirHelper(osPathname, dirent, options)
if err != nil || skip {
return err
}
}
if !dirent.IsDir() {
return nil
}
// If get here, then specified pathname refers to a directory.
deChildren, err := ReadDirents(osPathname, options.ScratchBuffer)
if err != nil {
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
}
if !options.Unsorted {
sort.Sort(deChildren) // sort children entries unless upstream says to leave unsorted
}
for _, deChild := range deChildren {
osChildname := filepath.Join(osPathname, deChild.name)
err = walk(osChildname, deChild, options)
if err != nil {
if err != filepath.SkipDir {
return err
}
// If received skipdir on a directory, stop processing that
// directory, but continue to its siblings. If received skipdir on a
// non-directory, stop processing remaining siblings.
if deChild.IsSymlink() {
var skip bool
if skip, err = symlinkDirHelper(osChildname, deChild, options); err != nil {
return err
}
if skip {
continue
}
}
if !deChild.IsDir() {
// If not directory, return immediately, thus skipping remainder
// of siblings.
return nil
}
}
}
if options.PostChildrenCallback == nil {
return nil
}
err = options.PostChildrenCallback(osPathname, dirent)
if err == nil || err == filepath.SkipDir {
return err
}
err = errCallback(err.Error()) // wrap potential errors returned by callback
if action := options.ErrorCallback(osPathname, err); action == SkipNode {
return nil
}
return err
} | [
"func",
"walk",
"(",
"osPathname",
"string",
",",
"dirent",
"*",
"Dirent",
",",
"options",
"*",
"Options",
")",
"error",
"{",
"err",
":=",
"options",
".",
"Callback",
"(",
"osPathname",
",",
"dirent",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"==",
"filepath",
".",
"SkipDir",
"{",
"return",
"err",
"\n",
"}",
"\n",
"err",
"=",
"errCallback",
"(",
"err",
".",
"Error",
"(",
")",
")",
"// wrap potential errors returned by callback",
"\n",
"if",
"action",
":=",
"options",
".",
"ErrorCallback",
"(",
"osPathname",
",",
"err",
")",
";",
"action",
"==",
"SkipNode",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"// On some platforms, an entry can have more than one mode type bit set.",
"// For instance, it could have both the symlink bit and the directory bit",
"// set indicating it's a symlink to a directory.",
"if",
"dirent",
".",
"IsSymlink",
"(",
")",
"{",
"if",
"!",
"options",
".",
"FollowSymbolicLinks",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"skip",
",",
"err",
":=",
"symlinkDirHelper",
"(",
"osPathname",
",",
"dirent",
",",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"||",
"skip",
"{",
"return",
"err",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"!",
"dirent",
".",
"IsDir",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// If get here, then specified pathname refers to a directory.",
"deChildren",
",",
"err",
":=",
"ReadDirents",
"(",
"osPathname",
",",
"options",
".",
"ScratchBuffer",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"action",
":=",
"options",
".",
"ErrorCallback",
"(",
"osPathname",
",",
"err",
")",
";",
"action",
"==",
"SkipNode",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}",
"\n\n",
"if",
"!",
"options",
".",
"Unsorted",
"{",
"sort",
".",
"Sort",
"(",
"deChildren",
")",
"// sort children entries unless upstream says to leave unsorted",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"deChild",
":=",
"range",
"deChildren",
"{",
"osChildname",
":=",
"filepath",
".",
"Join",
"(",
"osPathname",
",",
"deChild",
".",
"name",
")",
"\n",
"err",
"=",
"walk",
"(",
"osChildname",
",",
"deChild",
",",
"options",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"if",
"err",
"!=",
"filepath",
".",
"SkipDir",
"{",
"return",
"err",
"\n",
"}",
"\n",
"// If received skipdir on a directory, stop processing that",
"// directory, but continue to its siblings. If received skipdir on a",
"// non-directory, stop processing remaining siblings.",
"if",
"deChild",
".",
"IsSymlink",
"(",
")",
"{",
"var",
"skip",
"bool",
"\n",
"if",
"skip",
",",
"err",
"=",
"symlinkDirHelper",
"(",
"osChildname",
",",
"deChild",
",",
"options",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"if",
"skip",
"{",
"continue",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"!",
"deChild",
".",
"IsDir",
"(",
")",
"{",
"// If not directory, return immediately, thus skipping remainder",
"// of siblings.",
"return",
"nil",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"options",
".",
"PostChildrenCallback",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"err",
"=",
"options",
".",
"PostChildrenCallback",
"(",
"osPathname",
",",
"dirent",
")",
"\n",
"if",
"err",
"==",
"nil",
"||",
"err",
"==",
"filepath",
".",
"SkipDir",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"err",
"=",
"errCallback",
"(",
"err",
".",
"Error",
"(",
")",
")",
"// wrap potential errors returned by callback",
"\n",
"if",
"action",
":=",
"options",
".",
"ErrorCallback",
"(",
"osPathname",
",",
"err",
")",
";",
"action",
"==",
"SkipNode",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"err",
"\n",
"}"
] | // walk recursively traverses the file system node specified by pathname and the
// Dirent. | [
"walk",
"recursively",
"traverses",
"the",
"file",
"system",
"node",
"specified",
"by",
"pathname",
"and",
"the",
"Dirent",
"."
] | 808a2f88690f523a3fb074bc6626124660bc80eb | https://github.com/karrick/godirwalk/blob/808a2f88690f523a3fb074bc6626124660bc80eb/walk.go#L229-L313 |
150,969 | paulmach/orb | clip/helpers.go | Geometry | func Geometry(b orb.Bound, g orb.Geometry) orb.Geometry {
if g == nil {
return nil
}
if !b.Intersects(g.Bound()) {
return nil
}
switch g := g.(type) {
case orb.Point:
return g // Intersect check above
case orb.MultiPoint:
mp := MultiPoint(b, g)
if len(mp) == 1 {
return mp[0]
}
if mp == nil {
return nil
}
return mp
case orb.LineString:
mls := LineString(b, g)
if len(mls) == 1 {
return mls[0]
}
if len(mls) == 0 {
return nil
}
return mls
case orb.MultiLineString:
mls := MultiLineString(b, g)
if len(mls) == 1 {
return mls[0]
}
if mls == nil {
return nil
}
return mls
case orb.Ring:
r := Ring(b, g)
if r == nil {
return nil
}
return r
case orb.Polygon:
p := Polygon(b, g)
if p == nil {
return nil
}
return p
case orb.MultiPolygon:
mp := MultiPolygon(b, g)
if len(mp) == 1 {
return mp[0]
}
if mp == nil {
return nil
}
return mp
case orb.Collection:
c := Collection(b, g)
if len(c) == 1 {
return c[0]
}
if c == nil {
return nil
}
return c
case orb.Bound:
b = Bound(b, g)
if b.IsEmpty() {
return nil
}
return b
}
panic(fmt.Sprintf("geometry type not supported: %T", g))
} | go | func Geometry(b orb.Bound, g orb.Geometry) orb.Geometry {
if g == nil {
return nil
}
if !b.Intersects(g.Bound()) {
return nil
}
switch g := g.(type) {
case orb.Point:
return g // Intersect check above
case orb.MultiPoint:
mp := MultiPoint(b, g)
if len(mp) == 1 {
return mp[0]
}
if mp == nil {
return nil
}
return mp
case orb.LineString:
mls := LineString(b, g)
if len(mls) == 1 {
return mls[0]
}
if len(mls) == 0 {
return nil
}
return mls
case orb.MultiLineString:
mls := MultiLineString(b, g)
if len(mls) == 1 {
return mls[0]
}
if mls == nil {
return nil
}
return mls
case orb.Ring:
r := Ring(b, g)
if r == nil {
return nil
}
return r
case orb.Polygon:
p := Polygon(b, g)
if p == nil {
return nil
}
return p
case orb.MultiPolygon:
mp := MultiPolygon(b, g)
if len(mp) == 1 {
return mp[0]
}
if mp == nil {
return nil
}
return mp
case orb.Collection:
c := Collection(b, g)
if len(c) == 1 {
return c[0]
}
if c == nil {
return nil
}
return c
case orb.Bound:
b = Bound(b, g)
if b.IsEmpty() {
return nil
}
return b
}
panic(fmt.Sprintf("geometry type not supported: %T", g))
} | [
"func",
"Geometry",
"(",
"b",
"orb",
".",
"Bound",
",",
"g",
"orb",
".",
"Geometry",
")",
"orb",
".",
"Geometry",
"{",
"if",
"g",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"!",
"b",
".",
"Intersects",
"(",
"g",
".",
"Bound",
"(",
")",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"switch",
"g",
":=",
"g",
".",
"(",
"type",
")",
"{",
"case",
"orb",
".",
"Point",
":",
"return",
"g",
"// Intersect check above",
"\n",
"case",
"orb",
".",
"MultiPoint",
":",
"mp",
":=",
"MultiPoint",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"len",
"(",
"mp",
")",
"==",
"1",
"{",
"return",
"mp",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"mp",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"mp",
"\n",
"case",
"orb",
".",
"LineString",
":",
"mls",
":=",
"LineString",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"len",
"(",
"mls",
")",
"==",
"1",
"{",
"return",
"mls",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"mls",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"mls",
"\n",
"case",
"orb",
".",
"MultiLineString",
":",
"mls",
":=",
"MultiLineString",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"len",
"(",
"mls",
")",
"==",
"1",
"{",
"return",
"mls",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"mls",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"mls",
"\n",
"case",
"orb",
".",
"Ring",
":",
"r",
":=",
"Ring",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"r",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"r",
"\n",
"case",
"orb",
".",
"Polygon",
":",
"p",
":=",
"Polygon",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"p",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"p",
"\n",
"case",
"orb",
".",
"MultiPolygon",
":",
"mp",
":=",
"MultiPolygon",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"len",
"(",
"mp",
")",
"==",
"1",
"{",
"return",
"mp",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"mp",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"mp",
"\n",
"case",
"orb",
".",
"Collection",
":",
"c",
":=",
"Collection",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"len",
"(",
"c",
")",
"==",
"1",
"{",
"return",
"c",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"c",
"\n",
"case",
"orb",
".",
"Bound",
":",
"b",
"=",
"Bound",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"b",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"b",
"\n",
"}",
"\n\n",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"g",
")",
")",
"\n",
"}"
] | // Geometry will clip the geometry to the bounding box using the
// correct functions for the type.
// This operation will modify the input of '1d or 2d geometry' by using as a
// scratch space so clone if necessary. | [
"Geometry",
"will",
"clip",
"the",
"geometry",
"to",
"the",
"bounding",
"box",
"using",
"the",
"correct",
"functions",
"for",
"the",
"type",
".",
"This",
"operation",
"will",
"modify",
"the",
"input",
"of",
"1d",
"or",
"2d",
"geometry",
"by",
"using",
"as",
"a",
"scratch",
"space",
"so",
"clone",
"if",
"necessary",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L15-L105 |
150,970 | paulmach/orb | clip/helpers.go | MultiPoint | func MultiPoint(b orb.Bound, mp orb.MultiPoint) orb.MultiPoint {
var result orb.MultiPoint
for _, p := range mp {
if b.Contains(p) {
result = append(result, p)
}
}
return result
} | go | func MultiPoint(b orb.Bound, mp orb.MultiPoint) orb.MultiPoint {
var result orb.MultiPoint
for _, p := range mp {
if b.Contains(p) {
result = append(result, p)
}
}
return result
} | [
"func",
"MultiPoint",
"(",
"b",
"orb",
".",
"Bound",
",",
"mp",
"orb",
".",
"MultiPoint",
")",
"orb",
".",
"MultiPoint",
"{",
"var",
"result",
"orb",
".",
"MultiPoint",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
"{",
"if",
"b",
".",
"Contains",
"(",
"p",
")",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"p",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // MultiPoint returns a new set with the points outside the bound removed. | [
"MultiPoint",
"returns",
"a",
"new",
"set",
"with",
"the",
"points",
"outside",
"the",
"bound",
"removed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L108-L117 |
150,971 | paulmach/orb | clip/helpers.go | LineString | func LineString(b orb.Bound, ls orb.LineString, opts ...Option) orb.MultiLineString {
open := false
if len(opts) > 0 {
o := &options{}
for _, opt := range opts {
opt(o)
}
open = o.openBound
}
result := line(b, ls, open)
if len(result) == 0 {
return nil
}
return result
} | go | func LineString(b orb.Bound, ls orb.LineString, opts ...Option) orb.MultiLineString {
open := false
if len(opts) > 0 {
o := &options{}
for _, opt := range opts {
opt(o)
}
open = o.openBound
}
result := line(b, ls, open)
if len(result) == 0 {
return nil
}
return result
} | [
"func",
"LineString",
"(",
"b",
"orb",
".",
"Bound",
",",
"ls",
"orb",
".",
"LineString",
",",
"opts",
"...",
"Option",
")",
"orb",
".",
"MultiLineString",
"{",
"open",
":=",
"false",
"\n",
"if",
"len",
"(",
"opts",
")",
">",
"0",
"{",
"o",
":=",
"&",
"options",
"{",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"o",
")",
"\n",
"}",
"\n\n",
"open",
"=",
"o",
".",
"openBound",
"\n",
"}",
"\n\n",
"result",
":=",
"line",
"(",
"b",
",",
"ls",
",",
"open",
")",
"\n",
"if",
"len",
"(",
"result",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // LineString clips the linestring to the bounding box. | [
"LineString",
"clips",
"the",
"linestring",
"to",
"the",
"bounding",
"box",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L120-L137 |
150,972 | paulmach/orb | clip/helpers.go | MultiLineString | func MultiLineString(b orb.Bound, mls orb.MultiLineString, opts ...Option) orb.MultiLineString {
open := false
if len(opts) > 0 {
o := &options{}
for _, opt := range opts {
opt(o)
}
open = o.openBound
}
var result orb.MultiLineString
for _, ls := range mls {
r := line(b, ls, open)
if len(r) != 0 {
result = append(result, r...)
}
}
return result
} | go | func MultiLineString(b orb.Bound, mls orb.MultiLineString, opts ...Option) orb.MultiLineString {
open := false
if len(opts) > 0 {
o := &options{}
for _, opt := range opts {
opt(o)
}
open = o.openBound
}
var result orb.MultiLineString
for _, ls := range mls {
r := line(b, ls, open)
if len(r) != 0 {
result = append(result, r...)
}
}
return result
} | [
"func",
"MultiLineString",
"(",
"b",
"orb",
".",
"Bound",
",",
"mls",
"orb",
".",
"MultiLineString",
",",
"opts",
"...",
"Option",
")",
"orb",
".",
"MultiLineString",
"{",
"open",
":=",
"false",
"\n",
"if",
"len",
"(",
"opts",
")",
">",
"0",
"{",
"o",
":=",
"&",
"options",
"{",
"}",
"\n",
"for",
"_",
",",
"opt",
":=",
"range",
"opts",
"{",
"opt",
"(",
"o",
")",
"\n",
"}",
"\n\n",
"open",
"=",
"o",
".",
"openBound",
"\n",
"}",
"\n\n",
"var",
"result",
"orb",
".",
"MultiLineString",
"\n",
"for",
"_",
",",
"ls",
":=",
"range",
"mls",
"{",
"r",
":=",
"line",
"(",
"b",
",",
"ls",
",",
"open",
")",
"\n",
"if",
"len",
"(",
"r",
")",
"!=",
"0",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"r",
"...",
")",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"result",
"\n",
"}"
] | // MultiLineString clips the linestrings to the bounding box
// and returns a linestring union. | [
"MultiLineString",
"clips",
"the",
"linestrings",
"to",
"the",
"bounding",
"box",
"and",
"returns",
"a",
"linestring",
"union",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L141-L160 |
150,973 | paulmach/orb | clip/helpers.go | Ring | func Ring(b orb.Bound, r orb.Ring) orb.Ring {
result := ring(b, r)
if len(result) == 0 {
return nil
}
return result
} | go | func Ring(b orb.Bound, r orb.Ring) orb.Ring {
result := ring(b, r)
if len(result) == 0 {
return nil
}
return result
} | [
"func",
"Ring",
"(",
"b",
"orb",
".",
"Bound",
",",
"r",
"orb",
".",
"Ring",
")",
"orb",
".",
"Ring",
"{",
"result",
":=",
"ring",
"(",
"b",
",",
"r",
")",
"\n",
"if",
"len",
"(",
"result",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // Ring clips the ring to the bounding box and returns another ring.
// This operation will modify the input by using as a scratch space
// so clone if necessary. | [
"Ring",
"clips",
"the",
"ring",
"to",
"the",
"bounding",
"box",
"and",
"returns",
"another",
"ring",
".",
"This",
"operation",
"will",
"modify",
"the",
"input",
"by",
"using",
"as",
"a",
"scratch",
"space",
"so",
"clone",
"if",
"necessary",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L165-L172 |
150,974 | paulmach/orb | clip/helpers.go | Polygon | func Polygon(b orb.Bound, p orb.Polygon) orb.Polygon {
if len(p) == 0 {
return nil
}
r := Ring(b, p[0])
if r == nil {
return nil
}
result := orb.Polygon{r}
for i := 1; i < len(p); i++ {
r := Ring(b, p[i])
if r != nil {
result = append(result, r)
}
}
return result
} | go | func Polygon(b orb.Bound, p orb.Polygon) orb.Polygon {
if len(p) == 0 {
return nil
}
r := Ring(b, p[0])
if r == nil {
return nil
}
result := orb.Polygon{r}
for i := 1; i < len(p); i++ {
r := Ring(b, p[i])
if r != nil {
result = append(result, r)
}
}
return result
} | [
"func",
"Polygon",
"(",
"b",
"orb",
".",
"Bound",
",",
"p",
"orb",
".",
"Polygon",
")",
"orb",
".",
"Polygon",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
":=",
"Ring",
"(",
"b",
",",
"p",
"[",
"0",
"]",
")",
"\n",
"if",
"r",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"result",
":=",
"orb",
".",
"Polygon",
"{",
"r",
"}",
"\n",
"for",
"i",
":=",
"1",
";",
"i",
"<",
"len",
"(",
"p",
")",
";",
"i",
"++",
"{",
"r",
":=",
"Ring",
"(",
"b",
",",
"p",
"[",
"i",
"]",
")",
"\n",
"if",
"r",
"!=",
"nil",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"r",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // Polygon clips the polygon to the bounding box excluding the inner rings
// if they do not intersect the bounding box.
// This operation will modify the input by using as a scratch space
// so clone if necessary. | [
"Polygon",
"clips",
"the",
"polygon",
"to",
"the",
"bounding",
"box",
"excluding",
"the",
"inner",
"rings",
"if",
"they",
"do",
"not",
"intersect",
"the",
"bounding",
"box",
".",
"This",
"operation",
"will",
"modify",
"the",
"input",
"by",
"using",
"as",
"a",
"scratch",
"space",
"so",
"clone",
"if",
"necessary",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L178-L197 |
150,975 | paulmach/orb | clip/helpers.go | MultiPolygon | func MultiPolygon(b orb.Bound, mp orb.MultiPolygon) orb.MultiPolygon {
var result orb.MultiPolygon
for _, polygon := range mp {
p := Polygon(b, polygon)
if p != nil {
result = append(result, p)
}
}
return result
} | go | func MultiPolygon(b orb.Bound, mp orb.MultiPolygon) orb.MultiPolygon {
var result orb.MultiPolygon
for _, polygon := range mp {
p := Polygon(b, polygon)
if p != nil {
result = append(result, p)
}
}
return result
} | [
"func",
"MultiPolygon",
"(",
"b",
"orb",
".",
"Bound",
",",
"mp",
"orb",
".",
"MultiPolygon",
")",
"orb",
".",
"MultiPolygon",
"{",
"var",
"result",
"orb",
".",
"MultiPolygon",
"\n",
"for",
"_",
",",
"polygon",
":=",
"range",
"mp",
"{",
"p",
":=",
"Polygon",
"(",
"b",
",",
"polygon",
")",
"\n",
"if",
"p",
"!=",
"nil",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"p",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // MultiPolygon clips the multi polygon to the bounding box excluding
// any polygons if they don't intersect the bounding box.
// This operation will modify the input by using as a scratch space
// so clone if necessary. | [
"MultiPolygon",
"clips",
"the",
"multi",
"polygon",
"to",
"the",
"bounding",
"box",
"excluding",
"any",
"polygons",
"if",
"they",
"don",
"t",
"intersect",
"the",
"bounding",
"box",
".",
"This",
"operation",
"will",
"modify",
"the",
"input",
"by",
"using",
"as",
"a",
"scratch",
"space",
"so",
"clone",
"if",
"necessary",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L203-L213 |
150,976 | paulmach/orb | clip/helpers.go | Collection | func Collection(b orb.Bound, c orb.Collection) orb.Collection {
var result orb.Collection
for _, g := range c {
clipped := Geometry(b, g)
if clipped != nil {
result = append(result, clipped)
}
}
return result
} | go | func Collection(b orb.Bound, c orb.Collection) orb.Collection {
var result orb.Collection
for _, g := range c {
clipped := Geometry(b, g)
if clipped != nil {
result = append(result, clipped)
}
}
return result
} | [
"func",
"Collection",
"(",
"b",
"orb",
".",
"Bound",
",",
"c",
"orb",
".",
"Collection",
")",
"orb",
".",
"Collection",
"{",
"var",
"result",
"orb",
".",
"Collection",
"\n",
"for",
"_",
",",
"g",
":=",
"range",
"c",
"{",
"clipped",
":=",
"Geometry",
"(",
"b",
",",
"g",
")",
"\n",
"if",
"clipped",
"!=",
"nil",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"clipped",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // Collection clips each element in the collection to the bounding box.
// It will exclude elements if they don't intersect the bounding box.
// This operation will modify the input of '2d geometry' by using as a
// scratch space so clone if necessary. | [
"Collection",
"clips",
"each",
"element",
"in",
"the",
"collection",
"to",
"the",
"bounding",
"box",
".",
"It",
"will",
"exclude",
"elements",
"if",
"they",
"don",
"t",
"intersect",
"the",
"bounding",
"box",
".",
"This",
"operation",
"will",
"modify",
"the",
"input",
"of",
"2d",
"geometry",
"by",
"using",
"as",
"a",
"scratch",
"space",
"so",
"clone",
"if",
"necessary",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/helpers.go#L219-L229 |
150,977 | paulmach/orb | maptile/tilecover/polygon.go | Ring | func Ring(r orb.Ring, z maptile.Zoom) maptile.Set {
if len(r) == 0 {
return make(maptile.Set)
}
return Polygon(orb.Polygon{r}, z)
} | go | func Ring(r orb.Ring, z maptile.Zoom) maptile.Set {
if len(r) == 0 {
return make(maptile.Set)
}
return Polygon(orb.Polygon{r}, z)
} | [
"func",
"Ring",
"(",
"r",
"orb",
".",
"Ring",
",",
"z",
"maptile",
".",
"Zoom",
")",
"maptile",
".",
"Set",
"{",
"if",
"len",
"(",
"r",
")",
"==",
"0",
"{",
"return",
"make",
"(",
"maptile",
".",
"Set",
")",
"\n",
"}",
"\n\n",
"return",
"Polygon",
"(",
"orb",
".",
"Polygon",
"{",
"r",
"}",
",",
"z",
")",
"\n",
"}"
] | // Ring creates a tile cover for the ring. | [
"Ring",
"creates",
"a",
"tile",
"cover",
"for",
"the",
"ring",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/maptile/tilecover/polygon.go#L11-L17 |
150,978 | paulmach/orb | maptile/tilecover/polygon.go | Polygon | func Polygon(p orb.Polygon, z maptile.Zoom) maptile.Set {
set := make(maptile.Set)
polygon(set, p, z)
return set
} | go | func Polygon(p orb.Polygon, z maptile.Zoom) maptile.Set {
set := make(maptile.Set)
polygon(set, p, z)
return set
} | [
"func",
"Polygon",
"(",
"p",
"orb",
".",
"Polygon",
",",
"z",
"maptile",
".",
"Zoom",
")",
"maptile",
".",
"Set",
"{",
"set",
":=",
"make",
"(",
"maptile",
".",
"Set",
")",
"\n",
"polygon",
"(",
"set",
",",
"p",
",",
"z",
")",
"\n\n",
"return",
"set",
"\n",
"}"
] | // Polygon creates a tile cover for the polygon. | [
"Polygon",
"creates",
"a",
"tile",
"cover",
"for",
"the",
"polygon",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/maptile/tilecover/polygon.go#L20-L25 |
150,979 | paulmach/orb | maptile/tilecover/polygon.go | MultiPolygon | func MultiPolygon(mp orb.MultiPolygon, z maptile.Zoom) maptile.Set {
set := make(maptile.Set)
for _, p := range mp {
polygon(set, p, z)
}
return set
} | go | func MultiPolygon(mp orb.MultiPolygon, z maptile.Zoom) maptile.Set {
set := make(maptile.Set)
for _, p := range mp {
polygon(set, p, z)
}
return set
} | [
"func",
"MultiPolygon",
"(",
"mp",
"orb",
".",
"MultiPolygon",
",",
"z",
"maptile",
".",
"Zoom",
")",
"maptile",
".",
"Set",
"{",
"set",
":=",
"make",
"(",
"maptile",
".",
"Set",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
"{",
"polygon",
"(",
"set",
",",
"p",
",",
"z",
")",
"\n",
"}",
"\n\n",
"return",
"set",
"\n",
"}"
] | // MultiPolygon creates a tile cover for the multi-polygon. | [
"MultiPolygon",
"creates",
"a",
"tile",
"cover",
"for",
"the",
"multi",
"-",
"polygon",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/maptile/tilecover/polygon.go#L28-L35 |
150,980 | paulmach/orb | geometry.go | Bound | func (c Collection) Bound() Bound {
if len(c) == 0 {
return emptyBound
}
var b Bound
start := -1
for i, g := range c {
if g != nil {
start = i
b = g.Bound()
break
}
}
if start == -1 {
return emptyBound
}
for i := start + 1; i < len(c); i++ {
if c[i] == nil {
continue
}
b = b.Union(c[i].Bound())
}
return b
} | go | func (c Collection) Bound() Bound {
if len(c) == 0 {
return emptyBound
}
var b Bound
start := -1
for i, g := range c {
if g != nil {
start = i
b = g.Bound()
break
}
}
if start == -1 {
return emptyBound
}
for i := start + 1; i < len(c); i++ {
if c[i] == nil {
continue
}
b = b.Union(c[i].Bound())
}
return b
} | [
"func",
"(",
"c",
"Collection",
")",
"Bound",
"(",
")",
"Bound",
"{",
"if",
"len",
"(",
"c",
")",
"==",
"0",
"{",
"return",
"emptyBound",
"\n",
"}",
"\n\n",
"var",
"b",
"Bound",
"\n",
"start",
":=",
"-",
"1",
"\n\n",
"for",
"i",
",",
"g",
":=",
"range",
"c",
"{",
"if",
"g",
"!=",
"nil",
"{",
"start",
"=",
"i",
"\n",
"b",
"=",
"g",
".",
"Bound",
"(",
")",
"\n",
"break",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"start",
"==",
"-",
"1",
"{",
"return",
"emptyBound",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"start",
"+",
"1",
";",
"i",
"<",
"len",
"(",
"c",
")",
";",
"i",
"++",
"{",
"if",
"c",
"[",
"i",
"]",
"==",
"nil",
"{",
"continue",
"\n",
"}",
"\n\n",
"b",
"=",
"b",
".",
"Union",
"(",
"c",
"[",
"i",
"]",
".",
"Bound",
"(",
")",
")",
"\n",
"}",
"\n\n",
"return",
"b",
"\n",
"}"
] | // Bound returns the bounding box of all the Geometries combined. | [
"Bound",
"returns",
"the",
"bounding",
"box",
"of",
"all",
"the",
"Geometries",
"combined",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/geometry.go#L87-L116 |
150,981 | paulmach/orb | geometry.go | Equal | func (c Collection) Equal(collection Collection) bool {
if len(c) != len(collection) {
return false
}
for i, g := range c {
if !Equal(g, collection[i]) {
return false
}
}
return true
} | go | func (c Collection) Equal(collection Collection) bool {
if len(c) != len(collection) {
return false
}
for i, g := range c {
if !Equal(g, collection[i]) {
return false
}
}
return true
} | [
"func",
"(",
"c",
"Collection",
")",
"Equal",
"(",
"collection",
"Collection",
")",
"bool",
"{",
"if",
"len",
"(",
"c",
")",
"!=",
"len",
"(",
"collection",
")",
"{",
"return",
"false",
"\n",
"}",
"\n\n",
"for",
"i",
",",
"g",
":=",
"range",
"c",
"{",
"if",
"!",
"Equal",
"(",
"g",
",",
"collection",
"[",
"i",
"]",
")",
"{",
"return",
"false",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"true",
"\n",
"}"
] | // Equal compares two collections. Returns true if lengths are the same
// and all the sub geometries are the same and in the same order. | [
"Equal",
"compares",
"two",
"collections",
".",
"Returns",
"true",
"if",
"lengths",
"are",
"the",
"same",
"and",
"all",
"the",
"sub",
"geometries",
"are",
"the",
"same",
"and",
"in",
"the",
"same",
"order",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/geometry.go#L120-L132 |
150,982 | paulmach/orb | geometry.go | Clone | func (c Collection) Clone() Collection {
if c == nil {
return nil
}
nc := make(Collection, len(c))
for i, g := range c {
nc[i] = Clone(g)
}
return nc
} | go | func (c Collection) Clone() Collection {
if c == nil {
return nil
}
nc := make(Collection, len(c))
for i, g := range c {
nc[i] = Clone(g)
}
return nc
} | [
"func",
"(",
"c",
"Collection",
")",
"Clone",
"(",
")",
"Collection",
"{",
"if",
"c",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"nc",
":=",
"make",
"(",
"Collection",
",",
"len",
"(",
"c",
")",
")",
"\n",
"for",
"i",
",",
"g",
":=",
"range",
"c",
"{",
"nc",
"[",
"i",
"]",
"=",
"Clone",
"(",
"g",
")",
"\n",
"}",
"\n\n",
"return",
"nc",
"\n",
"}"
] | // Clone returns a deep copy of the collection. | [
"Clone",
"returns",
"a",
"deep",
"copy",
"of",
"the",
"collection",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/geometry.go#L135-L146 |
150,983 | paulmach/orb | simplify/radial.go | Radial | func Radial(df orb.DistanceFunc, threshold float64) *RadialSimplifier {
return &RadialSimplifier{
DistanceFunc: df,
Threshold: threshold,
}
} | go | func Radial(df orb.DistanceFunc, threshold float64) *RadialSimplifier {
return &RadialSimplifier{
DistanceFunc: df,
Threshold: threshold,
}
} | [
"func",
"Radial",
"(",
"df",
"orb",
".",
"DistanceFunc",
",",
"threshold",
"float64",
")",
"*",
"RadialSimplifier",
"{",
"return",
"&",
"RadialSimplifier",
"{",
"DistanceFunc",
":",
"df",
",",
"Threshold",
":",
"threshold",
",",
"}",
"\n",
"}"
] | // Radial creates a new RadialSimplifier. | [
"Radial",
"creates",
"a",
"new",
"RadialSimplifier",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/simplify/radial.go#L16-L21 |
150,984 | paulmach/orb | clip/smartclip/smart.go | Geometry | func Geometry(box orb.Bound, g orb.Geometry, o orb.Orientation) orb.Geometry {
if g == nil {
return nil
}
if g.Dimensions() != 2 {
return clip.Geometry(box, g)
}
var mp orb.MultiPolygon
switch g := g.(type) {
case orb.Ring:
mp = Ring(box, g, o)
case orb.Polygon:
mp = Polygon(box, g, o)
case orb.MultiPolygon:
mp = MultiPolygon(box, g, o)
case orb.Bound:
return clip.Geometry(box, g)
case orb.Collection:
var result orb.Collection
for _, c := range g {
c := Geometry(box, c, o)
if c != nil {
result = append(result, c)
}
}
if len(result) == 1 {
return result[0]
}
return result
default:
panic(fmt.Sprintf("geometry type not supported: %T", g))
}
if mp == nil {
return nil
}
if len(mp) == 1 {
return mp[0]
}
return mp
} | go | func Geometry(box orb.Bound, g orb.Geometry, o orb.Orientation) orb.Geometry {
if g == nil {
return nil
}
if g.Dimensions() != 2 {
return clip.Geometry(box, g)
}
var mp orb.MultiPolygon
switch g := g.(type) {
case orb.Ring:
mp = Ring(box, g, o)
case orb.Polygon:
mp = Polygon(box, g, o)
case orb.MultiPolygon:
mp = MultiPolygon(box, g, o)
case orb.Bound:
return clip.Geometry(box, g)
case orb.Collection:
var result orb.Collection
for _, c := range g {
c := Geometry(box, c, o)
if c != nil {
result = append(result, c)
}
}
if len(result) == 1 {
return result[0]
}
return result
default:
panic(fmt.Sprintf("geometry type not supported: %T", g))
}
if mp == nil {
return nil
}
if len(mp) == 1 {
return mp[0]
}
return mp
} | [
"func",
"Geometry",
"(",
"box",
"orb",
".",
"Bound",
",",
"g",
"orb",
".",
"Geometry",
",",
"o",
"orb",
".",
"Orientation",
")",
"orb",
".",
"Geometry",
"{",
"if",
"g",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"g",
".",
"Dimensions",
"(",
")",
"!=",
"2",
"{",
"return",
"clip",
".",
"Geometry",
"(",
"box",
",",
"g",
")",
"\n",
"}",
"\n\n",
"var",
"mp",
"orb",
".",
"MultiPolygon",
"\n",
"switch",
"g",
":=",
"g",
".",
"(",
"type",
")",
"{",
"case",
"orb",
".",
"Ring",
":",
"mp",
"=",
"Ring",
"(",
"box",
",",
"g",
",",
"o",
")",
"\n",
"case",
"orb",
".",
"Polygon",
":",
"mp",
"=",
"Polygon",
"(",
"box",
",",
"g",
",",
"o",
")",
"\n",
"case",
"orb",
".",
"MultiPolygon",
":",
"mp",
"=",
"MultiPolygon",
"(",
"box",
",",
"g",
",",
"o",
")",
"\n",
"case",
"orb",
".",
"Bound",
":",
"return",
"clip",
".",
"Geometry",
"(",
"box",
",",
"g",
")",
"\n",
"case",
"orb",
".",
"Collection",
":",
"var",
"result",
"orb",
".",
"Collection",
"\n",
"for",
"_",
",",
"c",
":=",
"range",
"g",
"{",
"c",
":=",
"Geometry",
"(",
"box",
",",
"c",
",",
"o",
")",
"\n",
"if",
"c",
"!=",
"nil",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"c",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"result",
")",
"==",
"1",
"{",
"return",
"result",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"default",
":",
"panic",
"(",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"g",
")",
")",
"\n",
"}",
"\n\n",
"if",
"mp",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"mp",
")",
"==",
"1",
"{",
"return",
"mp",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"return",
"mp",
"\n",
"}"
] | // Geometry will do a smart more involved clipping and wrapping of the geometry.
// It will return simple OGC geometries. Rings that are NOT closed AND have an
// endpoint in the bound will be implicitly closed. | [
"Geometry",
"will",
"do",
"a",
"smart",
"more",
"involved",
"clipping",
"and",
"wrapping",
"of",
"the",
"geometry",
".",
"It",
"will",
"return",
"simple",
"OGC",
"geometries",
".",
"Rings",
"that",
"are",
"NOT",
"closed",
"AND",
"have",
"an",
"endpoint",
"in",
"the",
"bound",
"will",
"be",
"implicitly",
"closed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L16-L62 |
150,985 | paulmach/orb | clip/smartclip/smart.go | Ring | func Ring(box orb.Bound, r orb.Ring, o orb.Orientation) orb.MultiPolygon {
if len(r) == 0 {
return nil
}
open, closed := clipRings(box, []orb.Ring{r})
if len(open) == 0 {
// nothing was clipped
if len(closed) == 0 {
return nil // everything outside bound
}
return orb.MultiPolygon{{r}} // everything inside bound
}
// in a well defined ring there will be no closed sections
return smartWrap(box, open, o)
} | go | func Ring(box orb.Bound, r orb.Ring, o orb.Orientation) orb.MultiPolygon {
if len(r) == 0 {
return nil
}
open, closed := clipRings(box, []orb.Ring{r})
if len(open) == 0 {
// nothing was clipped
if len(closed) == 0 {
return nil // everything outside bound
}
return orb.MultiPolygon{{r}} // everything inside bound
}
// in a well defined ring there will be no closed sections
return smartWrap(box, open, o)
} | [
"func",
"Ring",
"(",
"box",
"orb",
".",
"Bound",
",",
"r",
"orb",
".",
"Ring",
",",
"o",
"orb",
".",
"Orientation",
")",
"orb",
".",
"MultiPolygon",
"{",
"if",
"len",
"(",
"r",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"open",
",",
"closed",
":=",
"clipRings",
"(",
"box",
",",
"[",
"]",
"orb",
".",
"Ring",
"{",
"r",
"}",
")",
"\n",
"if",
"len",
"(",
"open",
")",
"==",
"0",
"{",
"// nothing was clipped",
"if",
"len",
"(",
"closed",
")",
"==",
"0",
"{",
"return",
"nil",
"// everything outside bound",
"\n",
"}",
"\n\n",
"return",
"orb",
".",
"MultiPolygon",
"{",
"{",
"r",
"}",
"}",
"// everything inside bound",
"\n",
"}",
"\n\n",
"// in a well defined ring there will be no closed sections",
"return",
"smartWrap",
"(",
"box",
",",
"open",
",",
"o",
")",
"\n",
"}"
] | // Ring will smart clip a ring to the boundary. This may result multiple rings so
// a multipolygon is possible. Rings that are NOT closed AND have an endpoint in
// the bound will be implicitly closed. | [
"Ring",
"will",
"smart",
"clip",
"a",
"ring",
"to",
"the",
"boundary",
".",
"This",
"may",
"result",
"multiple",
"rings",
"so",
"a",
"multipolygon",
"is",
"possible",
".",
"Rings",
"that",
"are",
"NOT",
"closed",
"AND",
"have",
"an",
"endpoint",
"in",
"the",
"bound",
"will",
"be",
"implicitly",
"closed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L67-L84 |
150,986 | paulmach/orb | clip/smartclip/smart.go | Polygon | func Polygon(box orb.Bound, p orb.Polygon, o orb.Orientation) orb.MultiPolygon {
if len(p) == 0 {
return nil
}
open, closed := clipRings(box, p)
if len(open) == 0 {
// nothing was clipped
if len(closed) == 0 {
return nil // everything outside bound
}
return orb.MultiPolygon{p} // everything inside bound
}
result := smartWrap(box, open, o)
if len(result) == 1 {
result[0] = append(result[0], closed...)
} else {
for _, i := range closed {
result = addToMultiPolygon(result, i)
}
}
return result
} | go | func Polygon(box orb.Bound, p orb.Polygon, o orb.Orientation) orb.MultiPolygon {
if len(p) == 0 {
return nil
}
open, closed := clipRings(box, p)
if len(open) == 0 {
// nothing was clipped
if len(closed) == 0 {
return nil // everything outside bound
}
return orb.MultiPolygon{p} // everything inside bound
}
result := smartWrap(box, open, o)
if len(result) == 1 {
result[0] = append(result[0], closed...)
} else {
for _, i := range closed {
result = addToMultiPolygon(result, i)
}
}
return result
} | [
"func",
"Polygon",
"(",
"box",
"orb",
".",
"Bound",
",",
"p",
"orb",
".",
"Polygon",
",",
"o",
"orb",
".",
"Orientation",
")",
"orb",
".",
"MultiPolygon",
"{",
"if",
"len",
"(",
"p",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"open",
",",
"closed",
":=",
"clipRings",
"(",
"box",
",",
"p",
")",
"\n",
"if",
"len",
"(",
"open",
")",
"==",
"0",
"{",
"// nothing was clipped",
"if",
"len",
"(",
"closed",
")",
"==",
"0",
"{",
"return",
"nil",
"// everything outside bound",
"\n",
"}",
"\n\n",
"return",
"orb",
".",
"MultiPolygon",
"{",
"p",
"}",
"// everything inside bound",
"\n",
"}",
"\n\n",
"result",
":=",
"smartWrap",
"(",
"box",
",",
"open",
",",
"o",
")",
"\n",
"if",
"len",
"(",
"result",
")",
"==",
"1",
"{",
"result",
"[",
"0",
"]",
"=",
"append",
"(",
"result",
"[",
"0",
"]",
",",
"closed",
"...",
")",
"\n",
"}",
"else",
"{",
"for",
"_",
",",
"i",
":=",
"range",
"closed",
"{",
"result",
"=",
"addToMultiPolygon",
"(",
"result",
",",
"i",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // Polygon will smart clip a polygon to the bound.
// Rings that are NOT closed AND have an endpoint in the bound will be
// implicitly closed. | [
"Polygon",
"will",
"smart",
"clip",
"a",
"polygon",
"to",
"the",
"bound",
".",
"Rings",
"that",
"are",
"NOT",
"closed",
"AND",
"have",
"an",
"endpoint",
"in",
"the",
"bound",
"will",
"be",
"implicitly",
"closed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L89-L114 |
150,987 | paulmach/orb | clip/smartclip/smart.go | MultiPolygon | func MultiPolygon(box orb.Bound, mp orb.MultiPolygon, o orb.Orientation) orb.MultiPolygon {
if len(mp) == 0 {
return nil
}
// outer rings
outerRings := make([]orb.Ring, 0, len(mp))
for _, p := range mp {
outerRings = append(outerRings, p[0])
}
outers, closedOuters := clipRings(box, outerRings)
if len(outers) == 0 {
// nothing was clipped
if len(closedOuters) == 0 {
return nil // everything outside bound
}
return mp // everything inside bound
}
// inner rings
var innerRings []orb.Ring
for _, p := range mp {
for _, r := range p[1:] {
innerRings = append(innerRings, r)
}
}
inners, closedInners := clipRings(box, innerRings)
// smart wrap everything that touches the edges
result := smartWrap(box, append(outers, inners...), o)
for _, o := range closedOuters {
result = append(result, orb.Polygon{o})
}
for _, i := range closedInners {
result = addToMultiPolygon(result, i)
}
return result
} | go | func MultiPolygon(box orb.Bound, mp orb.MultiPolygon, o orb.Orientation) orb.MultiPolygon {
if len(mp) == 0 {
return nil
}
// outer rings
outerRings := make([]orb.Ring, 0, len(mp))
for _, p := range mp {
outerRings = append(outerRings, p[0])
}
outers, closedOuters := clipRings(box, outerRings)
if len(outers) == 0 {
// nothing was clipped
if len(closedOuters) == 0 {
return nil // everything outside bound
}
return mp // everything inside bound
}
// inner rings
var innerRings []orb.Ring
for _, p := range mp {
for _, r := range p[1:] {
innerRings = append(innerRings, r)
}
}
inners, closedInners := clipRings(box, innerRings)
// smart wrap everything that touches the edges
result := smartWrap(box, append(outers, inners...), o)
for _, o := range closedOuters {
result = append(result, orb.Polygon{o})
}
for _, i := range closedInners {
result = addToMultiPolygon(result, i)
}
return result
} | [
"func",
"MultiPolygon",
"(",
"box",
"orb",
".",
"Bound",
",",
"mp",
"orb",
".",
"MultiPolygon",
",",
"o",
"orb",
".",
"Orientation",
")",
"orb",
".",
"MultiPolygon",
"{",
"if",
"len",
"(",
"mp",
")",
"==",
"0",
"{",
"return",
"nil",
"\n",
"}",
"\n\n",
"// outer rings",
"outerRings",
":=",
"make",
"(",
"[",
"]",
"orb",
".",
"Ring",
",",
"0",
",",
"len",
"(",
"mp",
")",
")",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
"{",
"outerRings",
"=",
"append",
"(",
"outerRings",
",",
"p",
"[",
"0",
"]",
")",
"\n",
"}",
"\n\n",
"outers",
",",
"closedOuters",
":=",
"clipRings",
"(",
"box",
",",
"outerRings",
")",
"\n",
"if",
"len",
"(",
"outers",
")",
"==",
"0",
"{",
"// nothing was clipped",
"if",
"len",
"(",
"closedOuters",
")",
"==",
"0",
"{",
"return",
"nil",
"// everything outside bound",
"\n",
"}",
"\n\n",
"return",
"mp",
"// everything inside bound",
"\n",
"}",
"\n\n",
"// inner rings",
"var",
"innerRings",
"[",
"]",
"orb",
".",
"Ring",
"\n",
"for",
"_",
",",
"p",
":=",
"range",
"mp",
"{",
"for",
"_",
",",
"r",
":=",
"range",
"p",
"[",
"1",
":",
"]",
"{",
"innerRings",
"=",
"append",
"(",
"innerRings",
",",
"r",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"inners",
",",
"closedInners",
":=",
"clipRings",
"(",
"box",
",",
"innerRings",
")",
"\n\n",
"// smart wrap everything that touches the edges",
"result",
":=",
"smartWrap",
"(",
"box",
",",
"append",
"(",
"outers",
",",
"inners",
"...",
")",
",",
"o",
")",
"\n",
"for",
"_",
",",
"o",
":=",
"range",
"closedOuters",
"{",
"result",
"=",
"append",
"(",
"result",
",",
"orb",
".",
"Polygon",
"{",
"o",
"}",
")",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"i",
":=",
"range",
"closedInners",
"{",
"result",
"=",
"addToMultiPolygon",
"(",
"result",
",",
"i",
")",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // MultiPolygon will smart clip a multipolygon to the bound.
// Rings that are NOT closed AND have an endpoint in the bound will be
// implicitly closed. | [
"MultiPolygon",
"will",
"smart",
"clip",
"a",
"multipolygon",
"to",
"the",
"bound",
".",
"Rings",
"that",
"are",
"NOT",
"closed",
"AND",
"have",
"an",
"endpoint",
"in",
"the",
"bound",
"will",
"be",
"implicitly",
"closed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L119-L161 |
150,988 | paulmach/orb | clip/smartclip/smart.go | clipRings | func clipRings(box orb.Bound, rings []orb.Ring) (open []orb.LineString, closed []orb.Ring) {
var result []orb.LineString
for _, r := range rings {
if !r.Closed() && (box.Contains(r[0]) || box.Contains(r[len(r)-1])) {
r = append(r, r[0])
}
out := clip.LineString(box, orb.LineString(r), clip.OpenBound(true))
if len(out) == 0 {
continue // outside of bound
}
if r.Closed() {
// if the input was a closed ring where the endpoints were within the bound,
// then join the sections.
// This operation is O(n^2), however, n is the number of segments, not edges
// so I think it's manageable.
for i := 0; i < len(out); i++ {
end := out[i][len(out[i])-1]
if end[0] == box.Min[0] || box.Max[0] == end[0] ||
end[1] == box.Min[1] || box.Max[1] == end[1] {
// endpoint must be within the bound to try join
continue
}
for j := 0; j < len(out); j++ {
if i == j {
continue
}
if out[j][0] == end {
out[i] = append(out[i], out[j][1:]...)
i--
out[j] = out[len(out)-1]
out = out[:len(out)-1]
}
}
}
}
result = append(result, out...)
}
at := 0
for _, ls := range result {
// closed ring, so completely inside bound
// unless it touches a boundary
if ls[0] == ls[len(ls)-1] && pointSide(box, ls[0]) == notOnSide {
closed = append(closed, orb.Ring(ls))
} else {
result[at] = ls
at++
}
}
return result[:at], closed
} | go | func clipRings(box orb.Bound, rings []orb.Ring) (open []orb.LineString, closed []orb.Ring) {
var result []orb.LineString
for _, r := range rings {
if !r.Closed() && (box.Contains(r[0]) || box.Contains(r[len(r)-1])) {
r = append(r, r[0])
}
out := clip.LineString(box, orb.LineString(r), clip.OpenBound(true))
if len(out) == 0 {
continue // outside of bound
}
if r.Closed() {
// if the input was a closed ring where the endpoints were within the bound,
// then join the sections.
// This operation is O(n^2), however, n is the number of segments, not edges
// so I think it's manageable.
for i := 0; i < len(out); i++ {
end := out[i][len(out[i])-1]
if end[0] == box.Min[0] || box.Max[0] == end[0] ||
end[1] == box.Min[1] || box.Max[1] == end[1] {
// endpoint must be within the bound to try join
continue
}
for j := 0; j < len(out); j++ {
if i == j {
continue
}
if out[j][0] == end {
out[i] = append(out[i], out[j][1:]...)
i--
out[j] = out[len(out)-1]
out = out[:len(out)-1]
}
}
}
}
result = append(result, out...)
}
at := 0
for _, ls := range result {
// closed ring, so completely inside bound
// unless it touches a boundary
if ls[0] == ls[len(ls)-1] && pointSide(box, ls[0]) == notOnSide {
closed = append(closed, orb.Ring(ls))
} else {
result[at] = ls
at++
}
}
return result[:at], closed
} | [
"func",
"clipRings",
"(",
"box",
"orb",
".",
"Bound",
",",
"rings",
"[",
"]",
"orb",
".",
"Ring",
")",
"(",
"open",
"[",
"]",
"orb",
".",
"LineString",
",",
"closed",
"[",
"]",
"orb",
".",
"Ring",
")",
"{",
"var",
"result",
"[",
"]",
"orb",
".",
"LineString",
"\n",
"for",
"_",
",",
"r",
":=",
"range",
"rings",
"{",
"if",
"!",
"r",
".",
"Closed",
"(",
")",
"&&",
"(",
"box",
".",
"Contains",
"(",
"r",
"[",
"0",
"]",
")",
"||",
"box",
".",
"Contains",
"(",
"r",
"[",
"len",
"(",
"r",
")",
"-",
"1",
"]",
")",
")",
"{",
"r",
"=",
"append",
"(",
"r",
",",
"r",
"[",
"0",
"]",
")",
"\n",
"}",
"\n",
"out",
":=",
"clip",
".",
"LineString",
"(",
"box",
",",
"orb",
".",
"LineString",
"(",
"r",
")",
",",
"clip",
".",
"OpenBound",
"(",
"true",
")",
")",
"\n",
"if",
"len",
"(",
"out",
")",
"==",
"0",
"{",
"continue",
"// outside of bound",
"\n",
"}",
"\n\n",
"if",
"r",
".",
"Closed",
"(",
")",
"{",
"// if the input was a closed ring where the endpoints were within the bound,",
"// then join the sections.",
"// This operation is O(n^2), however, n is the number of segments, not edges",
"// so I think it's manageable.",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"len",
"(",
"out",
")",
";",
"i",
"++",
"{",
"end",
":=",
"out",
"[",
"i",
"]",
"[",
"len",
"(",
"out",
"[",
"i",
"]",
")",
"-",
"1",
"]",
"\n",
"if",
"end",
"[",
"0",
"]",
"==",
"box",
".",
"Min",
"[",
"0",
"]",
"||",
"box",
".",
"Max",
"[",
"0",
"]",
"==",
"end",
"[",
"0",
"]",
"||",
"end",
"[",
"1",
"]",
"==",
"box",
".",
"Min",
"[",
"1",
"]",
"||",
"box",
".",
"Max",
"[",
"1",
"]",
"==",
"end",
"[",
"1",
"]",
"{",
"// endpoint must be within the bound to try join",
"continue",
"\n",
"}",
"\n\n",
"for",
"j",
":=",
"0",
";",
"j",
"<",
"len",
"(",
"out",
")",
";",
"j",
"++",
"{",
"if",
"i",
"==",
"j",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"out",
"[",
"j",
"]",
"[",
"0",
"]",
"==",
"end",
"{",
"out",
"[",
"i",
"]",
"=",
"append",
"(",
"out",
"[",
"i",
"]",
",",
"out",
"[",
"j",
"]",
"[",
"1",
":",
"]",
"...",
")",
"\n",
"i",
"--",
"\n\n",
"out",
"[",
"j",
"]",
"=",
"out",
"[",
"len",
"(",
"out",
")",
"-",
"1",
"]",
"\n",
"out",
"=",
"out",
"[",
":",
"len",
"(",
"out",
")",
"-",
"1",
"]",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n",
"}",
"\n\n",
"result",
"=",
"append",
"(",
"result",
",",
"out",
"...",
")",
"\n",
"}",
"\n\n",
"at",
":=",
"0",
"\n",
"for",
"_",
",",
"ls",
":=",
"range",
"result",
"{",
"// closed ring, so completely inside bound",
"// unless it touches a boundary",
"if",
"ls",
"[",
"0",
"]",
"==",
"ls",
"[",
"len",
"(",
"ls",
")",
"-",
"1",
"]",
"&&",
"pointSide",
"(",
"box",
",",
"ls",
"[",
"0",
"]",
")",
"==",
"notOnSide",
"{",
"closed",
"=",
"append",
"(",
"closed",
",",
"orb",
".",
"Ring",
"(",
"ls",
")",
")",
"\n",
"}",
"else",
"{",
"result",
"[",
"at",
"]",
"=",
"ls",
"\n",
"at",
"++",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"[",
":",
"at",
"]",
",",
"closed",
"\n",
"}"
] | // clipRings will take a set of rings and clip them to the boundary.
// It returns the open lineStrings with endpoints on the boundary and
// the closed interior rings. | [
"clipRings",
"will",
"take",
"a",
"set",
"of",
"rings",
"and",
"clip",
"them",
"to",
"the",
"boundary",
".",
"It",
"returns",
"the",
"open",
"lineStrings",
"with",
"endpoints",
"on",
"the",
"boundary",
"and",
"the",
"closed",
"interior",
"rings",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L166-L223 |
150,989 | paulmach/orb | clip/smartclip/smart.go | smartWrap | func smartWrap(box orb.Bound, input []orb.LineString, o orb.Orientation) orb.MultiPolygon {
points := make([]*endpoint, 0, 2*len(input)+2)
for i, r := range input {
// start
points = append(points, &endpoint{
Point: r[0],
Start: true,
Side: pointSide(box, r[0]),
Index: i,
OtherEnd: 2*i + 1,
})
// end
points = append(points, &endpoint{
Point: r[len(r)-1],
Start: false,
Side: pointSide(box, r[len(r)-1]),
Index: i,
OtherEnd: 2 * i,
})
}
if o == orb.CCW {
sort.Sort(&sortableEndpoints{
mls: input,
eps: points,
})
} else {
sort.Sort(sort.Reverse(&sortableEndpoints{
mls: input,
eps: points,
}))
}
var (
result orb.MultiPolygon
current orb.Ring
)
// this operation is O(n^2). Technically we could use a linked list
// and remove points instead of marking them as "used".
// However since n is 2x the number of segements I think we're okay.
for i := 0; i < 2*len(points); i++ {
ep := points[i%len(points)]
if ep.Used {
continue
}
if !ep.Start {
if len(current) == 0 {
current = orb.Ring(input[ep.Index])
ep.Used = true
}
continue
}
if len(current) == 0 {
continue
}
ep.Used = true
// previous was end, connect to this start
var r orb.Ring
if ep.Point == current[len(current)-1] {
r = emptyTwoRing
} else {
r = aroundBound(box, orb.Ring{ep.Point, current[len(current)-1]}, o)
}
if ep.Point.Equal(current[0]) {
// loop complete!!
current = append(current, r[2:]...)
result = append(result, orb.Polygon{current})
current = nil
i = -1 // start over looking for unused endpoints
} else {
if len(r) > 2 {
current = append(current, r[2:len(r)-1]...)
}
current = append(current, input[ep.Index]...)
points[ep.OtherEnd].Used = true
i = ep.OtherEnd
}
}
return result
} | go | func smartWrap(box orb.Bound, input []orb.LineString, o orb.Orientation) orb.MultiPolygon {
points := make([]*endpoint, 0, 2*len(input)+2)
for i, r := range input {
// start
points = append(points, &endpoint{
Point: r[0],
Start: true,
Side: pointSide(box, r[0]),
Index: i,
OtherEnd: 2*i + 1,
})
// end
points = append(points, &endpoint{
Point: r[len(r)-1],
Start: false,
Side: pointSide(box, r[len(r)-1]),
Index: i,
OtherEnd: 2 * i,
})
}
if o == orb.CCW {
sort.Sort(&sortableEndpoints{
mls: input,
eps: points,
})
} else {
sort.Sort(sort.Reverse(&sortableEndpoints{
mls: input,
eps: points,
}))
}
var (
result orb.MultiPolygon
current orb.Ring
)
// this operation is O(n^2). Technically we could use a linked list
// and remove points instead of marking them as "used".
// However since n is 2x the number of segements I think we're okay.
for i := 0; i < 2*len(points); i++ {
ep := points[i%len(points)]
if ep.Used {
continue
}
if !ep.Start {
if len(current) == 0 {
current = orb.Ring(input[ep.Index])
ep.Used = true
}
continue
}
if len(current) == 0 {
continue
}
ep.Used = true
// previous was end, connect to this start
var r orb.Ring
if ep.Point == current[len(current)-1] {
r = emptyTwoRing
} else {
r = aroundBound(box, orb.Ring{ep.Point, current[len(current)-1]}, o)
}
if ep.Point.Equal(current[0]) {
// loop complete!!
current = append(current, r[2:]...)
result = append(result, orb.Polygon{current})
current = nil
i = -1 // start over looking for unused endpoints
} else {
if len(r) > 2 {
current = append(current, r[2:len(r)-1]...)
}
current = append(current, input[ep.Index]...)
points[ep.OtherEnd].Used = true
i = ep.OtherEnd
}
}
return result
} | [
"func",
"smartWrap",
"(",
"box",
"orb",
".",
"Bound",
",",
"input",
"[",
"]",
"orb",
".",
"LineString",
",",
"o",
"orb",
".",
"Orientation",
")",
"orb",
".",
"MultiPolygon",
"{",
"points",
":=",
"make",
"(",
"[",
"]",
"*",
"endpoint",
",",
"0",
",",
"2",
"*",
"len",
"(",
"input",
")",
"+",
"2",
")",
"\n\n",
"for",
"i",
",",
"r",
":=",
"range",
"input",
"{",
"// start",
"points",
"=",
"append",
"(",
"points",
",",
"&",
"endpoint",
"{",
"Point",
":",
"r",
"[",
"0",
"]",
",",
"Start",
":",
"true",
",",
"Side",
":",
"pointSide",
"(",
"box",
",",
"r",
"[",
"0",
"]",
")",
",",
"Index",
":",
"i",
",",
"OtherEnd",
":",
"2",
"*",
"i",
"+",
"1",
",",
"}",
")",
"\n\n",
"// end",
"points",
"=",
"append",
"(",
"points",
",",
"&",
"endpoint",
"{",
"Point",
":",
"r",
"[",
"len",
"(",
"r",
")",
"-",
"1",
"]",
",",
"Start",
":",
"false",
",",
"Side",
":",
"pointSide",
"(",
"box",
",",
"r",
"[",
"len",
"(",
"r",
")",
"-",
"1",
"]",
")",
",",
"Index",
":",
"i",
",",
"OtherEnd",
":",
"2",
"*",
"i",
",",
"}",
")",
"\n",
"}",
"\n\n",
"if",
"o",
"==",
"orb",
".",
"CCW",
"{",
"sort",
".",
"Sort",
"(",
"&",
"sortableEndpoints",
"{",
"mls",
":",
"input",
",",
"eps",
":",
"points",
",",
"}",
")",
"\n",
"}",
"else",
"{",
"sort",
".",
"Sort",
"(",
"sort",
".",
"Reverse",
"(",
"&",
"sortableEndpoints",
"{",
"mls",
":",
"input",
",",
"eps",
":",
"points",
",",
"}",
")",
")",
"\n",
"}",
"\n\n",
"var",
"(",
"result",
"orb",
".",
"MultiPolygon",
"\n",
"current",
"orb",
".",
"Ring",
"\n",
")",
"\n\n",
"// this operation is O(n^2). Technically we could use a linked list",
"// and remove points instead of marking them as \"used\".",
"// However since n is 2x the number of segements I think we're okay.",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"2",
"*",
"len",
"(",
"points",
")",
";",
"i",
"++",
"{",
"ep",
":=",
"points",
"[",
"i",
"%",
"len",
"(",
"points",
")",
"]",
"\n",
"if",
"ep",
".",
"Used",
"{",
"continue",
"\n",
"}",
"\n\n",
"if",
"!",
"ep",
".",
"Start",
"{",
"if",
"len",
"(",
"current",
")",
"==",
"0",
"{",
"current",
"=",
"orb",
".",
"Ring",
"(",
"input",
"[",
"ep",
".",
"Index",
"]",
")",
"\n",
"ep",
".",
"Used",
"=",
"true",
"\n",
"}",
"\n",
"continue",
"\n",
"}",
"\n\n",
"if",
"len",
"(",
"current",
")",
"==",
"0",
"{",
"continue",
"\n",
"}",
"\n",
"ep",
".",
"Used",
"=",
"true",
"\n\n",
"// previous was end, connect to this start",
"var",
"r",
"orb",
".",
"Ring",
"\n",
"if",
"ep",
".",
"Point",
"==",
"current",
"[",
"len",
"(",
"current",
")",
"-",
"1",
"]",
"{",
"r",
"=",
"emptyTwoRing",
"\n",
"}",
"else",
"{",
"r",
"=",
"aroundBound",
"(",
"box",
",",
"orb",
".",
"Ring",
"{",
"ep",
".",
"Point",
",",
"current",
"[",
"len",
"(",
"current",
")",
"-",
"1",
"]",
"}",
",",
"o",
")",
"\n",
"}",
"\n\n",
"if",
"ep",
".",
"Point",
".",
"Equal",
"(",
"current",
"[",
"0",
"]",
")",
"{",
"// loop complete!!",
"current",
"=",
"append",
"(",
"current",
",",
"r",
"[",
"2",
":",
"]",
"...",
")",
"\n",
"result",
"=",
"append",
"(",
"result",
",",
"orb",
".",
"Polygon",
"{",
"current",
"}",
")",
"\n",
"current",
"=",
"nil",
"\n\n",
"i",
"=",
"-",
"1",
"// start over looking for unused endpoints",
"\n",
"}",
"else",
"{",
"if",
"len",
"(",
"r",
")",
">",
"2",
"{",
"current",
"=",
"append",
"(",
"current",
",",
"r",
"[",
"2",
":",
"len",
"(",
"r",
")",
"-",
"1",
"]",
"...",
")",
"\n",
"}",
"\n",
"current",
"=",
"append",
"(",
"current",
",",
"input",
"[",
"ep",
".",
"Index",
"]",
"...",
")",
"\n\n",
"points",
"[",
"ep",
".",
"OtherEnd",
"]",
".",
"Used",
"=",
"true",
"\n",
"i",
"=",
"ep",
".",
"OtherEnd",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"result",
"\n",
"}"
] | // smartWrap takes the open lineStrings with endpoints on the boundary and
// connects them correctly. | [
"smartWrap",
"takes",
"the",
"open",
"lineStrings",
"with",
"endpoints",
"on",
"the",
"boundary",
"and",
"connects",
"them",
"correctly",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L248-L337 |
150,990 | paulmach/orb | clip/smartclip/smart.go | pointSide | func pointSide(b orb.Bound, p orb.Point) uint8 {
if p[1] == b.Max[1] {
return 4
} else if p[1] == b.Min[1] {
return 2
} else if p[0] == b.Max[0] {
return 3
} else if p[0] == b.Min[0] {
return 1
}
return notOnSide
} | go | func pointSide(b orb.Bound, p orb.Point) uint8 {
if p[1] == b.Max[1] {
return 4
} else if p[1] == b.Min[1] {
return 2
} else if p[0] == b.Max[0] {
return 3
} else if p[0] == b.Min[0] {
return 1
}
return notOnSide
} | [
"func",
"pointSide",
"(",
"b",
"orb",
".",
"Bound",
",",
"p",
"orb",
".",
"Point",
")",
"uint8",
"{",
"if",
"p",
"[",
"1",
"]",
"==",
"b",
".",
"Max",
"[",
"1",
"]",
"{",
"return",
"4",
"\n",
"}",
"else",
"if",
"p",
"[",
"1",
"]",
"==",
"b",
".",
"Min",
"[",
"1",
"]",
"{",
"return",
"2",
"\n",
"}",
"else",
"if",
"p",
"[",
"0",
"]",
"==",
"b",
".",
"Max",
"[",
"0",
"]",
"{",
"return",
"3",
"\n",
"}",
"else",
"if",
"p",
"[",
"0",
"]",
"==",
"b",
".",
"Min",
"[",
"0",
"]",
"{",
"return",
"1",
"\n",
"}",
"\n\n",
"return",
"notOnSide",
"\n",
"}"
] | // 4
// +-+
// 1 | | 3
// +-+
// 2 | [
"4",
"+",
"-",
"+",
"1",
"|",
"|",
"3",
"+",
"-",
"+",
"2"
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L346-L358 |
150,991 | paulmach/orb | clip/smartclip/smart.go | Less | func (e *sortableEndpoints) Less(i, j int) bool {
if e.eps[i].Side != e.eps[j].Side {
return e.eps[i].Side < e.eps[j].Side
}
switch e.eps[i].Side {
case 1:
if e.eps[i].Point[1] != e.eps[j].Point[1] {
return e.eps[i].Point[1] >= e.eps[j].Point[1]
}
return e.eps[i].Before(e.mls)[1] >= e.eps[j].Before(e.mls)[1]
case 2:
if e.eps[i].Point[0] != e.eps[j].Point[0] {
return e.eps[i].Point[0] < e.eps[j].Point[0]
}
return e.eps[i].Before(e.mls)[0] < e.eps[j].Before(e.mls)[0]
case 3:
if e.eps[i].Point[1] != e.eps[j].Point[1] {
return e.eps[i].Point[1] < e.eps[j].Point[1]
}
return e.eps[i].Before(e.mls)[1] < e.eps[j].Before(e.mls)[1]
case 4:
if e.eps[i].Point[0] != e.eps[j].Point[0] {
return e.eps[i].Point[0] >= e.eps[j].Point[0]
}
return e.eps[i].Before(e.mls)[0] >= e.eps[j].Before(e.mls)[0]
}
panic("unreachable")
} | go | func (e *sortableEndpoints) Less(i, j int) bool {
if e.eps[i].Side != e.eps[j].Side {
return e.eps[i].Side < e.eps[j].Side
}
switch e.eps[i].Side {
case 1:
if e.eps[i].Point[1] != e.eps[j].Point[1] {
return e.eps[i].Point[1] >= e.eps[j].Point[1]
}
return e.eps[i].Before(e.mls)[1] >= e.eps[j].Before(e.mls)[1]
case 2:
if e.eps[i].Point[0] != e.eps[j].Point[0] {
return e.eps[i].Point[0] < e.eps[j].Point[0]
}
return e.eps[i].Before(e.mls)[0] < e.eps[j].Before(e.mls)[0]
case 3:
if e.eps[i].Point[1] != e.eps[j].Point[1] {
return e.eps[i].Point[1] < e.eps[j].Point[1]
}
return e.eps[i].Before(e.mls)[1] < e.eps[j].Before(e.mls)[1]
case 4:
if e.eps[i].Point[0] != e.eps[j].Point[0] {
return e.eps[i].Point[0] >= e.eps[j].Point[0]
}
return e.eps[i].Before(e.mls)[0] >= e.eps[j].Before(e.mls)[0]
}
panic("unreachable")
} | [
"func",
"(",
"e",
"*",
"sortableEndpoints",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"if",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Side",
"!=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Side",
"{",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Side",
"<",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Side",
"\n",
"}",
"\n\n",
"switch",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Side",
"{",
"case",
"1",
":",
"if",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"1",
"]",
"!=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"1",
"]",
"{",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"1",
"]",
">=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"1",
"]",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"1",
"]",
">=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"1",
"]",
"\n",
"case",
"2",
":",
"if",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"0",
"]",
"!=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"0",
"]",
"{",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"0",
"]",
"<",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"0",
"]",
"<",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"0",
"]",
"\n",
"case",
"3",
":",
"if",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"1",
"]",
"!=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"1",
"]",
"{",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"1",
"]",
"<",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"1",
"]",
"\n",
"}",
"\n",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"1",
"]",
"<",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"1",
"]",
"\n",
"case",
"4",
":",
"if",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"0",
"]",
"!=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"0",
"]",
"{",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Point",
"[",
"0",
"]",
">=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Point",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"return",
"e",
".",
"eps",
"[",
"i",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"0",
"]",
">=",
"e",
".",
"eps",
"[",
"j",
"]",
".",
"Before",
"(",
"e",
".",
"mls",
")",
"[",
"0",
"]",
"\n",
"}",
"\n\n",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}"
] | // Less sorts the points around the bound.
// First comparing what side it's on and then the actual point to determine the order.
// If two points are the same, we sort by the edge attached to the point so lines that are
// "above" are shorted first. | [
"Less",
"sorts",
"the",
"points",
"around",
"the",
"bound",
".",
"First",
"comparing",
"what",
"side",
"it",
"s",
"on",
"and",
"then",
"the",
"actual",
"point",
"to",
"determine",
"the",
"order",
".",
"If",
"two",
"points",
"are",
"the",
"same",
"we",
"sort",
"by",
"the",
"edge",
"attached",
"to",
"the",
"point",
"so",
"lines",
"that",
"are",
"above",
"are",
"shorted",
"first",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L373-L405 |
150,992 | paulmach/orb | clip/smartclip/smart.go | addToMultiPolygon | func addToMultiPolygon(mp orb.MultiPolygon, ring orb.Ring) orb.MultiPolygon {
for i := range mp {
if polygonContains(mp[i][0], ring) {
mp[i] = append(mp[i], ring)
return mp
}
}
// ring is not in any polygons?
// skip it, TODO: is this correct?
// If input is well formed, I think it is. If it isn't, ¯\_(ツ)_/¯
return mp
} | go | func addToMultiPolygon(mp orb.MultiPolygon, ring orb.Ring) orb.MultiPolygon {
for i := range mp {
if polygonContains(mp[i][0], ring) {
mp[i] = append(mp[i], ring)
return mp
}
}
// ring is not in any polygons?
// skip it, TODO: is this correct?
// If input is well formed, I think it is. If it isn't, ¯\_(ツ)_/¯
return mp
} | [
"func",
"addToMultiPolygon",
"(",
"mp",
"orb",
".",
"MultiPolygon",
",",
"ring",
"orb",
".",
"Ring",
")",
"orb",
".",
"MultiPolygon",
"{",
"for",
"i",
":=",
"range",
"mp",
"{",
"if",
"polygonContains",
"(",
"mp",
"[",
"i",
"]",
"[",
"0",
"]",
",",
"ring",
")",
"{",
"mp",
"[",
"i",
"]",
"=",
"append",
"(",
"mp",
"[",
"i",
"]",
",",
"ring",
")",
"\n",
"return",
"mp",
"\n",
"}",
"\n",
"}",
"\n\n",
"// ring is not in any polygons?",
"// skip it, TODO: is this correct?",
"// If input is well formed, I think it is. If it isn't, ¯\\_(ツ)_/¯",
"return",
"mp",
"\n",
"}"
] | // addToMultiPolygon does a lookup to see which polygon the ring intersects.
// This should work fine if the input is well formed. | [
"addToMultiPolygon",
"does",
"a",
"lookup",
"to",
"see",
"which",
"polygon",
"the",
"ring",
"intersects",
".",
"This",
"should",
"work",
"fine",
"if",
"the",
"input",
"is",
"well",
"formed",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/clip/smartclip/smart.go#L414-L427 |
150,993 | paulmach/orb | bound.go | ToRing | func (b Bound) ToRing() Ring {
return Ring{
b.Min,
Point{b.Max[0], b.Min[1]},
b.Max,
Point{b.Min[0], b.Max[1]},
b.Min,
}
} | go | func (b Bound) ToRing() Ring {
return Ring{
b.Min,
Point{b.Max[0], b.Min[1]},
b.Max,
Point{b.Min[0], b.Max[1]},
b.Min,
}
} | [
"func",
"(",
"b",
"Bound",
")",
"ToRing",
"(",
")",
"Ring",
"{",
"return",
"Ring",
"{",
"b",
".",
"Min",
",",
"Point",
"{",
"b",
".",
"Max",
"[",
"0",
"]",
",",
"b",
".",
"Min",
"[",
"1",
"]",
"}",
",",
"b",
".",
"Max",
",",
"Point",
"{",
"b",
".",
"Min",
"[",
"0",
"]",
",",
"b",
".",
"Max",
"[",
"1",
"]",
"}",
",",
"b",
".",
"Min",
",",
"}",
"\n",
"}"
] | // ToRing converts the bound into a loop defined
// by the boundary of the box. | [
"ToRing",
"converts",
"the",
"bound",
"into",
"a",
"loop",
"defined",
"by",
"the",
"boundary",
"of",
"the",
"box",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L33-L41 |
150,994 | paulmach/orb | bound.go | Union | func (b Bound) Union(other Bound) Bound {
if other.IsEmpty() {
return b
}
b = b.Extend(other.Min)
b = b.Extend(other.Max)
b = b.Extend(other.LeftTop())
b = b.Extend(other.RightBottom())
return b
} | go | func (b Bound) Union(other Bound) Bound {
if other.IsEmpty() {
return b
}
b = b.Extend(other.Min)
b = b.Extend(other.Max)
b = b.Extend(other.LeftTop())
b = b.Extend(other.RightBottom())
return b
} | [
"func",
"(",
"b",
"Bound",
")",
"Union",
"(",
"other",
"Bound",
")",
"Bound",
"{",
"if",
"other",
".",
"IsEmpty",
"(",
")",
"{",
"return",
"b",
"\n",
"}",
"\n\n",
"b",
"=",
"b",
".",
"Extend",
"(",
"other",
".",
"Min",
")",
"\n",
"b",
"=",
"b",
".",
"Extend",
"(",
"other",
".",
"Max",
")",
"\n",
"b",
"=",
"b",
".",
"Extend",
"(",
"other",
".",
"LeftTop",
"(",
")",
")",
"\n",
"b",
"=",
"b",
".",
"Extend",
"(",
"other",
".",
"RightBottom",
"(",
")",
")",
"\n\n",
"return",
"b",
"\n",
"}"
] | // Union extends this bound to contain the union of this and the given bound. | [
"Union",
"extends",
"this",
"bound",
"to",
"contain",
"the",
"union",
"of",
"this",
"and",
"the",
"given",
"bound",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L63-L74 |
150,995 | paulmach/orb | bound.go | Pad | func (b Bound) Pad(d float64) Bound {
b.Min[0] -= d
b.Min[1] -= d
b.Max[0] += d
b.Max[1] += d
return b
} | go | func (b Bound) Pad(d float64) Bound {
b.Min[0] -= d
b.Min[1] -= d
b.Max[0] += d
b.Max[1] += d
return b
} | [
"func",
"(",
"b",
"Bound",
")",
"Pad",
"(",
"d",
"float64",
")",
"Bound",
"{",
"b",
".",
"Min",
"[",
"0",
"]",
"-=",
"d",
"\n",
"b",
".",
"Min",
"[",
"1",
"]",
"-=",
"d",
"\n\n",
"b",
".",
"Max",
"[",
"0",
"]",
"+=",
"d",
"\n",
"b",
".",
"Max",
"[",
"1",
"]",
"+=",
"d",
"\n\n",
"return",
"b",
"\n",
"}"
] | // Pad extends the bound in all directions by the given value. | [
"Pad",
"extends",
"the",
"bound",
"in",
"all",
"directions",
"by",
"the",
"given",
"value",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L104-L112 |
150,996 | paulmach/orb | bound.go | Center | func (b Bound) Center() Point {
return Point{
(b.Min[0] + b.Max[0]) / 2.0,
(b.Min[1] + b.Max[1]) / 2.0,
}
} | go | func (b Bound) Center() Point {
return Point{
(b.Min[0] + b.Max[0]) / 2.0,
(b.Min[1] + b.Max[1]) / 2.0,
}
} | [
"func",
"(",
"b",
"Bound",
")",
"Center",
"(",
")",
"Point",
"{",
"return",
"Point",
"{",
"(",
"b",
".",
"Min",
"[",
"0",
"]",
"+",
"b",
".",
"Max",
"[",
"0",
"]",
")",
"/",
"2.0",
",",
"(",
"b",
".",
"Min",
"[",
"1",
"]",
"+",
"b",
".",
"Max",
"[",
"1",
"]",
")",
"/",
"2.0",
",",
"}",
"\n",
"}"
] | // Center returns the center of the bounds by "averaging" the x and y coords. | [
"Center",
"returns",
"the",
"center",
"of",
"the",
"bounds",
"by",
"averaging",
"the",
"x",
"and",
"y",
"coords",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L115-L120 |
150,997 | paulmach/orb | bound.go | IsEmpty | func (b Bound) IsEmpty() bool {
return b.Min[0] > b.Max[0] || b.Min[1] > b.Max[1]
} | go | func (b Bound) IsEmpty() bool {
return b.Min[0] > b.Max[0] || b.Min[1] > b.Max[1]
} | [
"func",
"(",
"b",
"Bound",
")",
"IsEmpty",
"(",
")",
"bool",
"{",
"return",
"b",
".",
"Min",
"[",
"0",
"]",
">",
"b",
".",
"Max",
"[",
"0",
"]",
"||",
"b",
".",
"Min",
"[",
"1",
"]",
">",
"b",
".",
"Max",
"[",
"1",
"]",
"\n",
"}"
] | // IsEmpty returns true if it contains zero area or if
// it's in some malformed negative state where the left point is larger than the right.
// This can be caused by padding too much negative. | [
"IsEmpty",
"returns",
"true",
"if",
"it",
"contains",
"zero",
"area",
"or",
"if",
"it",
"s",
"in",
"some",
"malformed",
"negative",
"state",
"where",
"the",
"left",
"point",
"is",
"larger",
"than",
"the",
"right",
".",
"This",
"can",
"be",
"caused",
"by",
"padding",
"too",
"much",
"negative",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L155-L157 |
150,998 | paulmach/orb | bound.go | IsZero | func (b Bound) IsZero() bool {
return b.Max == Point{} && b.Min == Point{}
} | go | func (b Bound) IsZero() bool {
return b.Max == Point{} && b.Min == Point{}
} | [
"func",
"(",
"b",
"Bound",
")",
"IsZero",
"(",
")",
"bool",
"{",
"return",
"b",
".",
"Max",
"==",
"Point",
"{",
"}",
"&&",
"b",
".",
"Min",
"==",
"Point",
"{",
"}",
"\n",
"}"
] | // IsZero return true if the bound just includes just null island. | [
"IsZero",
"return",
"true",
"if",
"the",
"bound",
"just",
"includes",
"just",
"null",
"island",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L160-L162 |
150,999 | paulmach/orb | bound.go | Equal | func (b Bound) Equal(c Bound) bool {
return b.Min == c.Min && b.Max == c.Max
} | go | func (b Bound) Equal(c Bound) bool {
return b.Min == c.Min && b.Max == c.Max
} | [
"func",
"(",
"b",
"Bound",
")",
"Equal",
"(",
"c",
"Bound",
")",
"bool",
"{",
"return",
"b",
".",
"Min",
"==",
"c",
".",
"Min",
"&&",
"b",
".",
"Max",
"==",
"c",
".",
"Max",
"\n",
"}"
] | // Equal returns if two bounds are equal. | [
"Equal",
"returns",
"if",
"two",
"bounds",
"are",
"equal",
"."
] | c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29 | https://github.com/paulmach/orb/blob/c6e407b203494d3b1edb9fd5cae4cf34a4ae0f29/bound.go#L170-L172 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.