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 list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
25,400 | rs/zerolog | array.go | Uint16 | func (a *Array) Uint16(i uint16) *Array {
a.buf = enc.AppendUint16(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint16(i uint16) *Array {
a.buf = enc.AppendUint16(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint16",
"(",
"i",
"uint16",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint16",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint16 append append i as a uint16 to the array. | [
"Uint16",
"append",
"append",
"i",
"as",
"a",
"uint16",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L158-L161 |
25,401 | rs/zerolog | array.go | Uint32 | func (a *Array) Uint32(i uint32) *Array {
a.buf = enc.AppendUint32(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint32(i uint32) *Array {
a.buf = enc.AppendUint32(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint32",
"(",
"i",
"uint32",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint32",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint32 append append i as a uint32 to the array. | [
"Uint32",
"append",
"append",
"i",
"as",
"a",
"uint32",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L164-L167 |
25,402 | rs/zerolog | array.go | Uint64 | func (a *Array) Uint64(i uint64) *Array {
a.buf = enc.AppendUint64(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Uint64(i uint64) *Array {
a.buf = enc.AppendUint64(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Uint64",
"(",
"i",
"uint64",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendUint64",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"i",
")",
"\n",
"return",
"a",
"\n... | // Uint64 append append i as a uint64 to the array. | [
"Uint64",
"append",
"append",
"i",
"as",
"a",
"uint64",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L170-L173 |
25,403 | rs/zerolog | array.go | Float32 | func (a *Array) Float32(f float32) *Array {
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f)
return a
} | go | func (a *Array) Float32(f float32) *Array {
a.buf = enc.AppendFloat32(enc.AppendArrayDelim(a.buf), f)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Float32",
"(",
"f",
"float32",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendFloat32",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"f",
")",
"\n",
"return",
"a",
... | // Float32 append append f as a float32 to the array. | [
"Float32",
"append",
"append",
"f",
"as",
"a",
"float32",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L176-L179 |
25,404 | rs/zerolog | array.go | Float64 | func (a *Array) Float64(f float64) *Array {
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f)
return a
} | go | func (a *Array) Float64(f float64) *Array {
a.buf = enc.AppendFloat64(enc.AppendArrayDelim(a.buf), f)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Float64",
"(",
"f",
"float64",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendFloat64",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"f",
")",
"\n",
"return",
"a",
... | // Float64 append append f as a float64 to the array. | [
"Float64",
"append",
"append",
"f",
"as",
"a",
"float64",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L182-L185 |
25,405 | rs/zerolog | array.go | Time | func (a *Array) Time(t time.Time) *Array {
a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat)
return a
} | go | func (a *Array) Time(t time.Time) *Array {
a.buf = enc.AppendTime(enc.AppendArrayDelim(a.buf), t, TimeFieldFormat)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Time",
"(",
"t",
"time",
".",
"Time",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendTime",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"t",
",",
"TimeFieldFormat",
... | // Time append append t formated as string using zerolog.TimeFieldFormat. | [
"Time",
"append",
"append",
"t",
"formated",
"as",
"string",
"using",
"zerolog",
".",
"TimeFieldFormat",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L188-L191 |
25,406 | rs/zerolog | array.go | Dur | func (a *Array) Dur(d time.Duration) *Array {
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger)
return a
} | go | func (a *Array) Dur(d time.Duration) *Array {
a.buf = enc.AppendDuration(enc.AppendArrayDelim(a.buf), d, DurationFieldUnit, DurationFieldInteger)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Dur",
"(",
"d",
"time",
".",
"Duration",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendDuration",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"d",
",",
"DurationFie... | // Dur append append d to the array. | [
"Dur",
"append",
"append",
"d",
"to",
"the",
"array",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L194-L197 |
25,407 | rs/zerolog | array.go | Interface | func (a *Array) Interface(i interface{}) *Array {
if obj, ok := i.(LogObjectMarshaler); ok {
return a.Object(obj)
}
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), i)
return a
} | go | func (a *Array) Interface(i interface{}) *Array {
if obj, ok := i.(LogObjectMarshaler); ok {
return a.Object(obj)
}
a.buf = enc.AppendInterface(enc.AppendArrayDelim(a.buf), i)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"Interface",
"(",
"i",
"interface",
"{",
"}",
")",
"*",
"Array",
"{",
"if",
"obj",
",",
"ok",
":=",
"i",
".",
"(",
"LogObjectMarshaler",
")",
";",
"ok",
"{",
"return",
"a",
".",
"Object",
"(",
"obj",
")",
"\... | // Interface append append i marshaled using reflection. | [
"Interface",
"append",
"append",
"i",
"marshaled",
"using",
"reflection",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L200-L206 |
25,408 | rs/zerolog | array.go | IPAddr | func (a *Array) IPAddr(ip net.IP) *Array {
a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip)
return a
} | go | func (a *Array) IPAddr(ip net.IP) *Array {
a.buf = enc.AppendIPAddr(enc.AppendArrayDelim(a.buf), ip)
return a
} | [
"func",
"(",
"a",
"*",
"Array",
")",
"IPAddr",
"(",
"ip",
"net",
".",
"IP",
")",
"*",
"Array",
"{",
"a",
".",
"buf",
"=",
"enc",
".",
"AppendIPAddr",
"(",
"enc",
".",
"AppendArrayDelim",
"(",
"a",
".",
"buf",
")",
",",
"ip",
")",
"\n",
"return"... | // IPAddr adds IPv4 or IPv6 address to the array | [
"IPAddr",
"adds",
"IPv4",
"or",
"IPv6",
"address",
"to",
"the",
"array"
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/array.go#L209-L212 |
25,409 | rs/zerolog | internal/json/string.go | AppendStrings | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendString(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = e.AppendString(append(dst, ','), val)
}
}
dst = append(dst, ']')
return... | go | func (e Encoder) AppendStrings(dst []byte, vals []string) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendString(dst, vals[0])
if len(vals) > 1 {
for _, val := range vals[1:] {
dst = e.AppendString(append(dst, ','), val)
}
}
dst = append(dst, ']')
return... | [
"func",
"(",
"e",
"Encoder",
")",
"AppendStrings",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
")",
"==",
"0",
"{",
"return",
"append",
"(",
"dst",
",",
"'['",
",",
"']'",... | // AppendStrings encodes the input strings to json and
// appends the encoded string list to the input byte slice. | [
"AppendStrings",
"encodes",
"the",
"input",
"strings",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L17-L30 |
25,410 | rs/zerolog | internal/json/string.go | AppendString | func (Encoder) AppendString(dst []byte, s string) []byte {
// Start with a double quote.
dst = append(dst, '"')
// Loop through each character in the string.
for i := 0; i < len(s); i++ {
// Check if the character needs encoding. Control characters, slashes,
// and the double quote need json encoding. Bytes abo... | go | func (Encoder) AppendString(dst []byte, s string) []byte {
// Start with a double quote.
dst = append(dst, '"')
// Loop through each character in the string.
for i := 0; i < len(s); i++ {
// Check if the character needs encoding. Control characters, slashes,
// and the double quote need json encoding. Bytes abo... | [
"func",
"(",
"Encoder",
")",
"AppendString",
"(",
"dst",
"[",
"]",
"byte",
",",
"s",
"string",
")",
"[",
"]",
"byte",
"{",
"// Start with a double quote.",
"dst",
"=",
"append",
"(",
"dst",
",",
"'\"'",
")",
"\n",
"// Loop through each character in the string.... | // AppendString encodes the input string to json and appends
// the encoded string to the input byte slice.
//
// The operation loops though each byte in the string looking
// for characters that need json or utf8 encoding. If the string
// does not need encoding, then the string is appended in it's
// entirety to the ... | [
"AppendString",
"encodes",
"the",
"input",
"string",
"to",
"json",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
".",
"The",
"operation",
"loops",
"though",
"each",
"byte",
"in",
"the",
"string",
"looking",
"for",
"char... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L41-L61 |
25,411 | rs/zerolog | internal/json/string.go | appendStringComplex | func appendStringComplex(dst []byte, s string, i int) []byte {
start := 0
for i < len(s) {
b := s[i]
if b >= utf8.RuneSelf {
r, size := utf8.DecodeRuneInString(s[i:])
if r == utf8.RuneError && size == 1 {
// In case of error, first append previous simple characters to
// the byte slice if any and ap... | go | func appendStringComplex(dst []byte, s string, i int) []byte {
start := 0
for i < len(s) {
b := s[i]
if b >= utf8.RuneSelf {
r, size := utf8.DecodeRuneInString(s[i:])
if r == utf8.RuneError && size == 1 {
// In case of error, first append previous simple characters to
// the byte slice if any and ap... | [
"func",
"appendStringComplex",
"(",
"dst",
"[",
"]",
"byte",
",",
"s",
"string",
",",
"i",
"int",
")",
"[",
"]",
"byte",
"{",
"start",
":=",
"0",
"\n",
"for",
"i",
"<",
"len",
"(",
"s",
")",
"{",
"b",
":=",
"s",
"[",
"i",
"]",
"\n",
"if",
"... | // appendStringComplex is used by appendString to take over an in
// progress JSON string encoding that encountered a character that needs
// to be encoded. | [
"appendStringComplex",
"is",
"used",
"by",
"appendString",
"to",
"take",
"over",
"an",
"in",
"progress",
"JSON",
"string",
"encoding",
"that",
"encountered",
"a",
"character",
"that",
"needs",
"to",
"be",
"encoded",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/string.go#L66-L121 |
25,412 | rs/zerolog | diode/internal/diodes/poller.go | WithPollingInterval | func WithPollingInterval(interval time.Duration) PollerConfigOption {
return PollerConfigOption(func(c *Poller) {
c.interval = interval
})
} | go | func WithPollingInterval(interval time.Duration) PollerConfigOption {
return PollerConfigOption(func(c *Poller) {
c.interval = interval
})
} | [
"func",
"WithPollingInterval",
"(",
"interval",
"time",
".",
"Duration",
")",
"PollerConfigOption",
"{",
"return",
"PollerConfigOption",
"(",
"func",
"(",
"c",
"*",
"Poller",
")",
"{",
"c",
".",
"interval",
"=",
"interval",
"\n",
"}",
")",
"\n",
"}"
] | // WithPollingInterval sets the interval at which the diode is queried
// for new data. The default is 10ms. | [
"WithPollingInterval",
"sets",
"the",
"interval",
"at",
"which",
"the",
"diode",
"is",
"queried",
"for",
"new",
"data",
".",
"The",
"default",
"is",
"10ms",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L26-L30 |
25,413 | rs/zerolog | diode/internal/diodes/poller.go | NewPoller | func NewPoller(d Diode, opts ...PollerConfigOption) *Poller {
p := &Poller{
Diode: d,
interval: 10 * time.Millisecond,
ctx: context.Background(),
}
for _, o := range opts {
o(p)
}
return p
} | go | func NewPoller(d Diode, opts ...PollerConfigOption) *Poller {
p := &Poller{
Diode: d,
interval: 10 * time.Millisecond,
ctx: context.Background(),
}
for _, o := range opts {
o(p)
}
return p
} | [
"func",
"NewPoller",
"(",
"d",
"Diode",
",",
"opts",
"...",
"PollerConfigOption",
")",
"*",
"Poller",
"{",
"p",
":=",
"&",
"Poller",
"{",
"Diode",
":",
"d",
",",
"interval",
":",
"10",
"*",
"time",
".",
"Millisecond",
",",
"ctx",
":",
"context",
".",... | // NewPoller returns a new Poller that wraps the given diode. | [
"NewPoller",
"returns",
"a",
"new",
"Poller",
"that",
"wraps",
"the",
"given",
"diode",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L42-L54 |
25,414 | rs/zerolog | diode/internal/diodes/poller.go | Next | func (p *Poller) Next() GenericDataType {
for {
data, ok := p.Diode.TryNext()
if !ok {
if p.isDone() {
return nil
}
time.Sleep(p.interval)
continue
}
return data
}
} | go | func (p *Poller) Next() GenericDataType {
for {
data, ok := p.Diode.TryNext()
if !ok {
if p.isDone() {
return nil
}
time.Sleep(p.interval)
continue
}
return data
}
} | [
"func",
"(",
"p",
"*",
"Poller",
")",
"Next",
"(",
")",
"GenericDataType",
"{",
"for",
"{",
"data",
",",
"ok",
":=",
"p",
".",
"Diode",
".",
"TryNext",
"(",
")",
"\n",
"if",
"!",
"ok",
"{",
"if",
"p",
".",
"isDone",
"(",
")",
"{",
"return",
"... | // Next polls the diode until data is available or until the context is done.
// If the context is done, then nil will be returned. | [
"Next",
"polls",
"the",
"diode",
"until",
"data",
"is",
"available",
"or",
"until",
"the",
"context",
"is",
"done",
".",
"If",
"the",
"context",
"is",
"done",
"then",
"nil",
"will",
"be",
"returned",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/poller.go#L58-L71 |
25,415 | rs/zerolog | diode/internal/diodes/one_to_one.go | NewOneToOne | func NewOneToOne(size int, alerter Alerter) *OneToOne {
if alerter == nil {
alerter = AlertFunc(func(int) {})
}
return &OneToOne{
buffer: make([]unsafe.Pointer, size),
alerter: alerter,
}
} | go | func NewOneToOne(size int, alerter Alerter) *OneToOne {
if alerter == nil {
alerter = AlertFunc(func(int) {})
}
return &OneToOne{
buffer: make([]unsafe.Pointer, size),
alerter: alerter,
}
} | [
"func",
"NewOneToOne",
"(",
"size",
"int",
",",
"alerter",
"Alerter",
")",
"*",
"OneToOne",
"{",
"if",
"alerter",
"==",
"nil",
"{",
"alerter",
"=",
"AlertFunc",
"(",
"func",
"(",
"int",
")",
"{",
"}",
")",
"\n",
"}",
"\n\n",
"return",
"&",
"OneToOne"... | // NewOneToOne creates a new diode is meant to be used by a single reader and
// a single writer. The alerter is invoked on the read's go-routine. It is
// called when it notices that the writer go-routine has passed it and wrote
// over data. A nil can be used to ignore alerts. | [
"NewOneToOne",
"creates",
"a",
"new",
"diode",
"is",
"meant",
"to",
"be",
"used",
"by",
"a",
"single",
"reader",
"and",
"a",
"single",
"writer",
".",
"The",
"alerter",
"is",
"invoked",
"on",
"the",
"read",
"s",
"go",
"-",
"routine",
".",
"It",
"is",
... | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/diode/internal/diodes/one_to_one.go#L44-L53 |
25,416 | rs/zerolog | internal/json/base.go | AppendKey | func (e Encoder) AppendKey(dst []byte, key string) []byte {
if len(dst) > 1 && dst[len(dst)-1] != '{' {
dst = append(dst, ',')
}
dst = e.AppendString(dst, key)
return append(dst, ':')
} | go | func (e Encoder) AppendKey(dst []byte, key string) []byte {
if len(dst) > 1 && dst[len(dst)-1] != '{' {
dst = append(dst, ',')
}
dst = e.AppendString(dst, key)
return append(dst, ':')
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendKey",
"(",
"dst",
"[",
"]",
"byte",
",",
"key",
"string",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"dst",
")",
">",
"1",
"&&",
"dst",
"[",
"len",
"(",
"dst",
")",
"-",
"1",
"]",
"!=",
"'{'",
"{"... | // AppendKey appends a new key to the output JSON. | [
"AppendKey",
"appends",
"a",
"new",
"key",
"to",
"the",
"output",
"JSON",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/base.go#L6-L12 |
25,417 | rs/zerolog | internal/json/time.go | AppendTime | func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return e.AppendInt64(dst, t.Unix())
case timeFormatUnixMs:
return e.AppendInt64(dst, t.UnixNano()/1000000)
}
return append(t.AppendFormat(append(dst, '"'), format), '"')
} | go | func (e Encoder) AppendTime(dst []byte, t time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return e.AppendInt64(dst, t.Unix())
case timeFormatUnixMs:
return e.AppendInt64(dst, t.UnixNano()/1000000)
}
return append(t.AppendFormat(append(dst, '"'), format), '"')
} | [
"func",
"(",
"e",
"Encoder",
")",
"AppendTime",
"(",
"dst",
"[",
"]",
"byte",
",",
"t",
"time",
".",
"Time",
",",
"format",
"string",
")",
"[",
"]",
"byte",
"{",
"switch",
"format",
"{",
"case",
"timeFormatUnix",
":",
"return",
"e",
".",
"AppendInt64... | // AppendTime formats the input time with the given format
// and appends the encoded string to the input byte slice. | [
"AppendTime",
"formats",
"the",
"input",
"time",
"with",
"the",
"given",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L16-L24 |
25,418 | rs/zerolog | internal/json/time.go | AppendTimes | func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return appendUnixTimes(dst, vals)
case timeFormatUnixMs:
return appendUnixMsTimes(dst, vals)
}
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = append(vals[0... | go | func (Encoder) AppendTimes(dst []byte, vals []time.Time, format string) []byte {
switch format {
case timeFormatUnix:
return appendUnixTimes(dst, vals)
case timeFormatUnixMs:
return appendUnixMsTimes(dst, vals)
}
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = append(vals[0... | [
"func",
"(",
"Encoder",
")",
"AppendTimes",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"time",
".",
"Time",
",",
"format",
"string",
")",
"[",
"]",
"byte",
"{",
"switch",
"format",
"{",
"case",
"timeFormatUnix",
":",
"return",
"appendUnixTime... | // AppendTimes converts the input times with the given format
// and appends the encoded string list to the input byte slice. | [
"AppendTimes",
"converts",
"the",
"input",
"times",
"with",
"the",
"given",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L28-L47 |
25,419 | rs/zerolog | internal/json/time.go | AppendDurations | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendDuration(dst, vals[0], unit, useInt)
if len(vals) > 1 {
for _, d := range vals[1:] {
dst = e.AppendDuration(app... | go | func (e Encoder) AppendDurations(dst []byte, vals []time.Duration, unit time.Duration, useInt bool) []byte {
if len(vals) == 0 {
return append(dst, '[', ']')
}
dst = append(dst, '[')
dst = e.AppendDuration(dst, vals[0], unit, useInt)
if len(vals) > 1 {
for _, d := range vals[1:] {
dst = e.AppendDuration(app... | [
"func",
"(",
"e",
"Encoder",
")",
"AppendDurations",
"(",
"dst",
"[",
"]",
"byte",
",",
"vals",
"[",
"]",
"time",
".",
"Duration",
",",
"unit",
"time",
".",
"Duration",
",",
"useInt",
"bool",
")",
"[",
"]",
"byte",
"{",
"if",
"len",
"(",
"vals",
... | // AppendDurations formats the input durations with the given unit & format
// and appends the encoded string list to the input byte slice. | [
"AppendDurations",
"formats",
"the",
"input",
"durations",
"with",
"the",
"given",
"unit",
"&",
"format",
"and",
"appends",
"the",
"encoded",
"string",
"list",
"to",
"the",
"input",
"byte",
"slice",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/internal/json/time.go#L90-L103 |
25,420 | rs/zerolog | pkgerrors/stacktrace.go | Write | func (s *state) Write(b []byte) (n int, err error) {
s.b = b
return len(b), nil
} | go | func (s *state) Write(b []byte) (n int, err error) {
s.b = b
return len(b), nil
} | [
"func",
"(",
"s",
"*",
"state",
")",
"Write",
"(",
"b",
"[",
"]",
"byte",
")",
"(",
"n",
"int",
",",
"err",
"error",
")",
"{",
"s",
".",
"b",
"=",
"b",
"\n",
"return",
"len",
"(",
"b",
")",
",",
"nil",
"\n",
"}"
] | // Write implement fmt.Formatter interface. | [
"Write",
"implement",
"fmt",
".",
"Formatter",
"interface",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/pkgerrors/stacktrace.go#L18-L21 |
25,421 | rs/zerolog | hlog/hlog.go | NewHandler | func NewHandler(log zerolog.Logger) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Create a copy of the logger (including internal context slice)
// to prevent data race when using UpdateContext.
l := ... | go | func NewHandler(log zerolog.Logger) func(http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// Create a copy of the logger (including internal context slice)
// to prevent data race when using UpdateContext.
l := ... | [
"func",
"NewHandler",
"(",
"log",
"zerolog",
".",
"Logger",
")",
"func",
"(",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"H... | // NewHandler injects log into requests context. | [
"NewHandler",
"injects",
"log",
"into",
"requests",
"context",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L23-L33 |
25,422 | rs/zerolog | hlog/hlog.go | RequestHandler | func RequestHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey,... | go | func RequestHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolog.Context) zerolog.Context {
return c.Str(fieldKey,... | [
"func",
"RequestHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"Ha... | // RequestHandler adds the request method and URL as a field to the context's logger
// using fieldKey as field key. | [
"RequestHandler",
"adds",
"the",
"request",
"method",
"and",
"URL",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L65-L75 |
25,423 | rs/zerolog | hlog/hlog.go | RemoteAddrHandler | func RemoteAddrHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
log := zerolog.Ctx(r.Context())
log.UpdateCon... | go | func RemoteAddrHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if host, _, err := net.SplitHostPort(r.RemoteAddr); err == nil {
log := zerolog.Ctx(r.Context())
log.UpdateCon... | [
"func",
"RemoteAddrHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
... | // RemoteAddrHandler adds the request's remote address as a field to the context's logger
// using fieldKey as field key. | [
"RemoteAddrHandler",
"adds",
"the",
"request",
"s",
"remote",
"address",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L79-L91 |
25,424 | rs/zerolog | hlog/hlog.go | UserAgentHandler | func UserAgentHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ua := r.Header.Get("User-Agent"); ua != "" {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolo... | go | func UserAgentHandler(fieldKey string) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if ua := r.Header.Get("User-Agent"); ua != "" {
log := zerolog.Ctx(r.Context())
log.UpdateContext(func(c zerolo... | [
"func",
"UserAgentHandler",
"(",
"fieldKey",
"string",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
"return",
"http",
".",
"... | // UserAgentHandler adds the request's user-agent as a field to the context's logger
// using fieldKey as field key. | [
"UserAgentHandler",
"adds",
"the",
"request",
"s",
"user",
"-",
"agent",
"as",
"a",
"field",
"to",
"the",
"context",
"s",
"logger",
"using",
"fieldKey",
"as",
"field",
"key",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L95-L107 |
25,425 | rs/zerolog | hlog/hlog.go | IDFromRequest | func IDFromRequest(r *http.Request) (id xid.ID, ok bool) {
if r == nil {
return
}
return IDFromCtx(r.Context())
} | go | func IDFromRequest(r *http.Request) (id xid.ID, ok bool) {
if r == nil {
return
}
return IDFromCtx(r.Context())
} | [
"func",
"IDFromRequest",
"(",
"r",
"*",
"http",
".",
"Request",
")",
"(",
"id",
"xid",
".",
"ID",
",",
"ok",
"bool",
")",
"{",
"if",
"r",
"==",
"nil",
"{",
"return",
"\n",
"}",
"\n",
"return",
"IDFromCtx",
"(",
"r",
".",
"Context",
"(",
")",
")... | // IDFromRequest returns the unique id associated to the request if any. | [
"IDFromRequest",
"returns",
"the",
"unique",
"id",
"associated",
"to",
"the",
"request",
"if",
"any",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L128-L133 |
25,426 | rs/zerolog | hlog/hlog.go | AccessHandler | func AccessHandler(f func(r *http.Request, status, size int, duration time.Duration)) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lw := mutil.WrapWriter(w)
next.ServeHTTP(lw, r... | go | func AccessHandler(f func(r *http.Request, status, size int, duration time.Duration)) func(next http.Handler) http.Handler {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
start := time.Now()
lw := mutil.WrapWriter(w)
next.ServeHTTP(lw, r... | [
"func",
"AccessHandler",
"(",
"f",
"func",
"(",
"r",
"*",
"http",
".",
"Request",
",",
"status",
",",
"size",
"int",
",",
"duration",
"time",
".",
"Duration",
")",
")",
"func",
"(",
"next",
"http",
".",
"Handler",
")",
"http",
".",
"Handler",
"{",
... | // AccessHandler returns a handler that call f after each request. | [
"AccessHandler",
"returns",
"a",
"handler",
"that",
"call",
"f",
"after",
"each",
"request",
"."
] | acf3980132bfcdc48638724e6e3d9e5749b85999 | https://github.com/rs/zerolog/blob/acf3980132bfcdc48638724e6e3d9e5749b85999/hlog/hlog.go#L175-L184 |
25,427 | rebuy-de/aws-nuke | cmd/queue.go | List | func (i *Item) List() ([]resources.Resource, error) {
listers := resources.GetListers()
return listers[i.Type](i.Region.Session)
} | go | func (i *Item) List() ([]resources.Resource, error) {
listers := resources.GetListers()
return listers[i.Type](i.Region.Session)
} | [
"func",
"(",
"i",
"*",
"Item",
")",
"List",
"(",
")",
"(",
"[",
"]",
"resources",
".",
"Resource",
",",
"error",
")",
"{",
"listers",
":=",
"resources",
".",
"GetListers",
"(",
")",
"\n",
"return",
"listers",
"[",
"i",
".",
"Type",
"]",
"(",
"i",... | // List gets all resource items of the same resource type like the Item. | [
"List",
"gets",
"all",
"resource",
"items",
"of",
"the",
"same",
"resource",
"type",
"like",
"the",
"Item",
"."
] | 21582790b6806fd775aba073b0bbc27a111a15f0 | https://github.com/rebuy-de/aws-nuke/blob/21582790b6806fd775aba073b0bbc27a111a15f0/cmd/queue.go#L51-L54 |
25,428 | wcharczuk/go-chart | util/math.go | Max | func (m mathUtil) Max(values ...float64) float64 {
if len(values) == 0 {
return 0
}
max := values[0]
for _, v := range values {
if max < v {
max = v
}
}
return max
} | go | func (m mathUtil) Max(values ...float64) float64 {
if len(values) == 0 {
return 0
}
max := values[0]
for _, v := range values {
if max < v {
max = v
}
}
return max
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Max",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"max",
":=",
"values",
"[",
"0",
"]",
"\n",
"for",
"_",
",",
"v",
... | // Max returns the maximum value of a group of floats. | [
"Max",
"returns",
"the",
"maximum",
"value",
"of",
"a",
"group",
"of",
"floats",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L29-L40 |
25,429 | wcharczuk/go-chart | util/math.go | MinAndMax | func (m mathUtil) MinAndMax(values ...float64) (min float64, max float64) {
if len(values) == 0 {
return
}
min = values[0]
max = values[0]
for _, v := range values[1:] {
if max < v {
max = v
}
if min > v {
min = v
}
}
return
} | go | func (m mathUtil) MinAndMax(values ...float64) (min float64, max float64) {
if len(values) == 0 {
return
}
min = values[0]
max = values[0]
for _, v := range values[1:] {
if max < v {
max = v
}
if min > v {
min = v
}
}
return
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MinAndMax",
"(",
"values",
"...",
"float64",
")",
"(",
"min",
"float64",
",",
"max",
"float64",
")",
"{",
"if",
"len",
"(",
"values",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"min",
"=",
"values",
"[",
"... | // MinAndMax returns both the min and max in one pass. | [
"MinAndMax",
"returns",
"both",
"the",
"min",
"and",
"max",
"in",
"one",
"pass",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L43-L58 |
25,430 | wcharczuk/go-chart | util/math.go | GetRoundToForDelta | func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
startingDeltaBound := math.Pow(10.0, 10.0)
for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
if delta > cursor {
return cursor / 10.0
}
}
return 0.0
} | go | func (m mathUtil) GetRoundToForDelta(delta float64) float64 {
startingDeltaBound := math.Pow(10.0, 10.0)
for cursor := startingDeltaBound; cursor > 0; cursor /= 10.0 {
if delta > cursor {
return cursor / 10.0
}
}
return 0.0
} | [
"func",
"(",
"m",
"mathUtil",
")",
"GetRoundToForDelta",
"(",
"delta",
"float64",
")",
"float64",
"{",
"startingDeltaBound",
":=",
"math",
".",
"Pow",
"(",
"10.0",
",",
"10.0",
")",
"\n",
"for",
"cursor",
":=",
"startingDeltaBound",
";",
"cursor",
">",
"0"... | // GetRoundToForDelta returns a `roundTo` value for a given delta. | [
"GetRoundToForDelta",
"returns",
"a",
"roundTo",
"value",
"for",
"a",
"given",
"delta",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L61-L70 |
25,431 | wcharczuk/go-chart | util/math.go | RoundUp | func (m mathUtil) RoundUp(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Ceil(value / roundTo)
return d1 * roundTo
} | go | func (m mathUtil) RoundUp(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Ceil(value / roundTo)
return d1 * roundTo
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RoundUp",
"(",
"value",
",",
"roundTo",
"float64",
")",
"float64",
"{",
"if",
"roundTo",
"<",
"0.000000000000001",
"{",
"return",
"value",
"\n",
"}",
"\n",
"d1",
":=",
"math",
".",
"Ceil",
"(",
"value",
"/",
"roundTo... | // RoundUp rounds up to a given roundTo value. | [
"RoundUp",
"rounds",
"up",
"to",
"a",
"given",
"roundTo",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L73-L79 |
25,432 | wcharczuk/go-chart | util/math.go | RoundDown | func (m mathUtil) RoundDown(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Floor(value / roundTo)
return d1 * roundTo
} | go | func (m mathUtil) RoundDown(value, roundTo float64) float64 {
if roundTo < 0.000000000000001 {
return value
}
d1 := math.Floor(value / roundTo)
return d1 * roundTo
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RoundDown",
"(",
"value",
",",
"roundTo",
"float64",
")",
"float64",
"{",
"if",
"roundTo",
"<",
"0.000000000000001",
"{",
"return",
"value",
"\n",
"}",
"\n",
"d1",
":=",
"math",
".",
"Floor",
"(",
"value",
"/",
"roun... | // RoundDown rounds down to a given roundTo value. | [
"RoundDown",
"rounds",
"down",
"to",
"a",
"given",
"roundTo",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L82-L88 |
25,433 | wcharczuk/go-chart | util/math.go | MinInt | func (m mathUtil) MinInt(values ...int) int {
min := math.MaxInt32
for _, v := range values {
if v < min {
min = v
}
}
return min
} | go | func (m mathUtil) MinInt(values ...int) int {
min := math.MaxInt32
for _, v := range values {
if v < min {
min = v
}
}
return min
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MinInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"min",
":=",
"math",
".",
"MaxInt32",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"if",
"v",
"<",
"min",
"{",
"min",
"=",
"v",
"\n",
"}",
... | // MinInt returns the minimum of a set of integers. | [
"MinInt",
"returns",
"the",
"minimum",
"of",
"a",
"set",
"of",
"integers",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L106-L114 |
25,434 | wcharczuk/go-chart | util/math.go | MaxInt | func (m mathUtil) MaxInt(values ...int) int {
max := math.MinInt32
for _, v := range values {
if v > max {
max = v
}
}
return max
} | go | func (m mathUtil) MaxInt(values ...int) int {
max := math.MinInt32
for _, v := range values {
if v > max {
max = v
}
}
return max
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MaxInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"max",
":=",
"math",
".",
"MinInt32",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"if",
"v",
">",
"max",
"{",
"max",
"=",
"v",
"\n",
"}",
... | // MaxInt returns the maximum of a set of integers. | [
"MaxInt",
"returns",
"the",
"maximum",
"of",
"a",
"set",
"of",
"integers",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L117-L125 |
25,435 | wcharczuk/go-chart | util/math.go | Mean | func (m mathUtil) Mean(values ...float64) float64 {
return m.Sum(values...) / float64(len(values))
} | go | func (m mathUtil) Mean(values ...float64) float64 {
return m.Sum(values...) / float64(len(values))
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Mean",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"return",
"m",
".",
"Sum",
"(",
"values",
"...",
")",
"/",
"float64",
"(",
"len",
"(",
"values",
")",
")",
"\n",
"}"
] | // Mean returns the mean of a set of values | [
"Mean",
"returns",
"the",
"mean",
"of",
"a",
"set",
"of",
"values"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L144-L146 |
25,436 | wcharczuk/go-chart | util/math.go | MeanInt | func (m mathUtil) MeanInt(values ...int) int {
return m.SumInt(values...) / len(values)
} | go | func (m mathUtil) MeanInt(values ...int) int {
return m.SumInt(values...) / len(values)
} | [
"func",
"(",
"m",
"mathUtil",
")",
"MeanInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"return",
"m",
".",
"SumInt",
"(",
"values",
"...",
")",
"/",
"len",
"(",
"values",
")",
"\n",
"}"
] | // MeanInt returns the mean of a set of integer values. | [
"MeanInt",
"returns",
"the",
"mean",
"of",
"a",
"set",
"of",
"integer",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L149-L151 |
25,437 | wcharczuk/go-chart | util/math.go | Sum | func (m mathUtil) Sum(values ...float64) float64 {
var total float64
for _, v := range values {
total += v
}
return total
} | go | func (m mathUtil) Sum(values ...float64) float64 {
var total float64
for _, v := range values {
total += v
}
return total
} | [
"func",
"(",
"m",
"mathUtil",
")",
"Sum",
"(",
"values",
"...",
"float64",
")",
"float64",
"{",
"var",
"total",
"float64",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"total",
"+=",
"v",
"\n",
"}",
"\n",
"return",
"total",
"\n",
"}"
] | // Sum sums a set of values. | [
"Sum",
"sums",
"a",
"set",
"of",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L154-L160 |
25,438 | wcharczuk/go-chart | util/math.go | SumInt | func (m mathUtil) SumInt(values ...int) int {
var total int
for _, v := range values {
total += v
}
return total
} | go | func (m mathUtil) SumInt(values ...int) int {
var total int
for _, v := range values {
total += v
}
return total
} | [
"func",
"(",
"m",
"mathUtil",
")",
"SumInt",
"(",
"values",
"...",
"int",
")",
"int",
"{",
"var",
"total",
"int",
"\n",
"for",
"_",
",",
"v",
":=",
"range",
"values",
"{",
"total",
"+=",
"v",
"\n",
"}",
"\n",
"return",
"total",
"\n",
"}"
] | // SumInt sums a set of values. | [
"SumInt",
"sums",
"a",
"set",
"of",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L163-L169 |
25,439 | wcharczuk/go-chart | util/math.go | RadiansToDegrees | func (m mathUtil) RadiansToDegrees(value float64) float64 {
return math.Mod(value, _2pi) * _r2d
} | go | func (m mathUtil) RadiansToDegrees(value float64) float64 {
return math.Mod(value, _2pi) * _r2d
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RadiansToDegrees",
"(",
"value",
"float64",
")",
"float64",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
",",
"_2pi",
")",
"*",
"_r2d",
"\n",
"}"
] | // RadiansToDegrees translates a radian value to a degree value. | [
"RadiansToDegrees",
"translates",
"a",
"radian",
"value",
"to",
"a",
"degree",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L186-L188 |
25,440 | wcharczuk/go-chart | util/math.go | RadianAdd | func (m mathUtil) RadianAdd(base, delta float64) float64 {
value := base + delta
if value > _2pi {
return math.Mod(value, _2pi)
} else if value < 0 {
return math.Mod(_2pi+value, _2pi)
}
return value
} | go | func (m mathUtil) RadianAdd(base, delta float64) float64 {
value := base + delta
if value > _2pi {
return math.Mod(value, _2pi)
} else if value < 0 {
return math.Mod(_2pi+value, _2pi)
}
return value
} | [
"func",
"(",
"m",
"mathUtil",
")",
"RadianAdd",
"(",
"base",
",",
"delta",
"float64",
")",
"float64",
"{",
"value",
":=",
"base",
"+",
"delta",
"\n",
"if",
"value",
">",
"_2pi",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
",",
"_2pi",
")",
"\n... | // RadianAdd adds a delta to a base in radians. | [
"RadianAdd",
"adds",
"a",
"delta",
"to",
"a",
"base",
"in",
"radians",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L196-L204 |
25,441 | wcharczuk/go-chart | util/math.go | DegreesAdd | func (m mathUtil) DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
value := baseDegrees + deltaDegrees
if value > _2pi {
return math.Mod(value, 360.0)
} else if value < 0 {
return math.Mod(360.0+value, 360.0)
}
return value
} | go | func (m mathUtil) DegreesAdd(baseDegrees, deltaDegrees float64) float64 {
value := baseDegrees + deltaDegrees
if value > _2pi {
return math.Mod(value, 360.0)
} else if value < 0 {
return math.Mod(360.0+value, 360.0)
}
return value
} | [
"func",
"(",
"m",
"mathUtil",
")",
"DegreesAdd",
"(",
"baseDegrees",
",",
"deltaDegrees",
"float64",
")",
"float64",
"{",
"value",
":=",
"baseDegrees",
"+",
"deltaDegrees",
"\n",
"if",
"value",
">",
"_2pi",
"{",
"return",
"math",
".",
"Mod",
"(",
"value",
... | // DegreesAdd adds a delta to a base in radians. | [
"DegreesAdd",
"adds",
"a",
"delta",
"to",
"a",
"base",
"in",
"radians",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L207-L215 |
25,442 | wcharczuk/go-chart | util/math.go | CirclePoint | func (m mathUtil) CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
x = cx + int(radius*math.Sin(thetaRadians))
y = cy - int(radius*math.Cos(thetaRadians))
return
} | go | func (m mathUtil) CirclePoint(cx, cy int, radius, thetaRadians float64) (x, y int) {
x = cx + int(radius*math.Sin(thetaRadians))
y = cy - int(radius*math.Cos(thetaRadians))
return
} | [
"func",
"(",
"m",
"mathUtil",
")",
"CirclePoint",
"(",
"cx",
",",
"cy",
"int",
",",
"radius",
",",
"thetaRadians",
"float64",
")",
"(",
"x",
",",
"y",
"int",
")",
"{",
"x",
"=",
"cx",
"+",
"int",
"(",
"radius",
"*",
"math",
".",
"Sin",
"(",
"th... | // CirclePoint returns the absolute position of a circle diameter point given
// by the radius and the theta. | [
"CirclePoint",
"returns",
"the",
"absolute",
"position",
"of",
"a",
"circle",
"diameter",
"point",
"given",
"by",
"the",
"radius",
"and",
"the",
"theta",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/util/math.go#L224-L228 |
25,443 | wcharczuk/go-chart | seq/seq.go | Array | func (s Seq) Array() (output []float64) {
if s.Len() == 0 {
return
}
output = make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
output[i] = s.GetValue(i)
}
return
} | go | func (s Seq) Array() (output []float64) {
if s.Len() == 0 {
return
}
output = make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
output[i] = s.GetValue(i)
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Array",
"(",
")",
"(",
"output",
"[",
"]",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"output",
"=",
"make",
"(",
"[",
"]",
"float64",
",",
"s",
".",
"Le... | // Array enumerates the seq into a slice. | [
"Array",
"enumerates",
"the",
"seq",
"into",
"a",
"slice",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L30-L40 |
25,444 | wcharczuk/go-chart | seq/seq.go | Each | func (s Seq) Each(mapfn func(int, float64)) {
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
} | go | func (s Seq) Each(mapfn func(int, float64)) {
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
} | [
"func",
"(",
"s",
"Seq",
")",
"Each",
"(",
"mapfn",
"func",
"(",
"int",
",",
"float64",
")",
")",
"{",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"Len",
"(",
")",
";",
"i",
"++",
"{",
"mapfn",
"(",
"i",
",",
"s",
".",
"GetValue",
"("... | // Each applies the `mapfn` to all values in the value provider. | [
"Each",
"applies",
"the",
"mapfn",
"to",
"all",
"values",
"in",
"the",
"value",
"provider",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L43-L47 |
25,445 | wcharczuk/go-chart | seq/seq.go | Map | func (s Seq) Map(mapfn func(i int, v float64) float64) Seq {
output := make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
return Seq{Array(output)}
} | go | func (s Seq) Map(mapfn func(i int, v float64) float64) Seq {
output := make([]float64, s.Len())
for i := 0; i < s.Len(); i++ {
mapfn(i, s.GetValue(i))
}
return Seq{Array(output)}
} | [
"func",
"(",
"s",
"Seq",
")",
"Map",
"(",
"mapfn",
"func",
"(",
"i",
"int",
",",
"v",
"float64",
")",
"float64",
")",
"Seq",
"{",
"output",
":=",
"make",
"(",
"[",
"]",
"float64",
",",
"s",
".",
"Len",
"(",
")",
")",
"\n",
"for",
"i",
":=",
... | // Map applies the `mapfn` to all values in the value provider,
// returning a new seq. | [
"Map",
"applies",
"the",
"mapfn",
"to",
"all",
"values",
"in",
"the",
"value",
"provider",
"returning",
"a",
"new",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L51-L57 |
25,446 | wcharczuk/go-chart | seq/seq.go | FoldRight | func (s Seq) FoldRight(mapfn func(i int, v0, v float64) float64) (v0 float64) {
if s.Len() == 0 {
return 0
}
if s.Len() == 1 {
return s.GetValue(0)
}
v0 = s.GetValue(s.Len() - 1)
for i := s.Len() - 2; i >= 0; i-- {
v0 = mapfn(i, v0, s.GetValue(i))
}
return
} | go | func (s Seq) FoldRight(mapfn func(i int, v0, v float64) float64) (v0 float64) {
if s.Len() == 0 {
return 0
}
if s.Len() == 1 {
return s.GetValue(0)
}
v0 = s.GetValue(s.Len() - 1)
for i := s.Len() - 2; i >= 0; i-- {
v0 = mapfn(i, v0, s.GetValue(i))
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"FoldRight",
"(",
"mapfn",
"func",
"(",
"i",
"int",
",",
"v0",
",",
"v",
"float64",
")",
"float64",
")",
"(",
"v0",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
... | // FoldRight collapses a seq from right to left. | [
"FoldRight",
"collapses",
"a",
"seq",
"from",
"right",
"to",
"left",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L77-L91 |
25,447 | wcharczuk/go-chart | seq/seq.go | Min | func (s Seq) Min() float64 {
if s.Len() == 0 {
return 0
}
min := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
}
return min
} | go | func (s Seq) Min() float64 {
if s.Len() == 0 {
return 0
}
min := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
}
return min
} | [
"func",
"(",
"s",
"Seq",
")",
"Min",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"min",
":=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"var",
"value",
"float64",
"\n",
"for",
... | // Min returns the minimum value in the seq. | [
"Min",
"returns",
"the",
"minimum",
"value",
"in",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L94-L107 |
25,448 | wcharczuk/go-chart | seq/seq.go | Max | func (s Seq) Max() float64 {
if s.Len() == 0 {
return 0
}
max := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value > max {
max = value
}
}
return max
} | go | func (s Seq) Max() float64 {
if s.Len() == 0 {
return 0
}
max := s.GetValue(0)
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value > max {
max = value
}
}
return max
} | [
"func",
"(",
"s",
"Seq",
")",
"Max",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n",
"max",
":=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"var",
"value",
"float64",
"\n",
"for",
... | // Max returns the maximum value in the seq. | [
"Max",
"returns",
"the",
"maximum",
"value",
"in",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L110-L123 |
25,449 | wcharczuk/go-chart | seq/seq.go | MinMax | func (s Seq) MinMax() (min, max float64) {
if s.Len() == 0 {
return
}
min = s.GetValue(0)
max = min
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
if value > max {
max = value
}
}
return
} | go | func (s Seq) MinMax() (min, max float64) {
if s.Len() == 0 {
return
}
min = s.GetValue(0)
max = min
var value float64
for i := 1; i < s.Len(); i++ {
value = s.GetValue(i)
if value < min {
min = value
}
if value > max {
max = value
}
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"MinMax",
"(",
")",
"(",
"min",
",",
"max",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n",
"min",
"=",
"s",
".",
"GetValue",
"(",
"0",
")",
"\n",
"max",
"=",
... | // MinMax returns the minimum and the maximum in one pass. | [
"MinMax",
"returns",
"the",
"minimum",
"and",
"the",
"maximum",
"in",
"one",
"pass",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L126-L143 |
25,450 | wcharczuk/go-chart | seq/seq.go | Sort | func (s Seq) Sort() Seq {
if s.Len() == 0 {
return s
}
values := s.Array()
sort.Float64s(values)
return Seq{Provider: Array(values)}
} | go | func (s Seq) Sort() Seq {
if s.Len() == 0 {
return s
}
values := s.Array()
sort.Float64s(values)
return Seq{Provider: Array(values)}
} | [
"func",
"(",
"s",
"Seq",
")",
"Sort",
"(",
")",
"Seq",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"s",
"\n",
"}",
"\n",
"values",
":=",
"s",
".",
"Array",
"(",
")",
"\n",
"sort",
".",
"Float64s",
"(",
"values",
")",
"\n... | // Sort returns the seq sorted in ascending order.
// This fully enumerates the seq. | [
"Sort",
"returns",
"the",
"seq",
"sorted",
"in",
"ascending",
"order",
".",
"This",
"fully",
"enumerates",
"the",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L147-L154 |
25,451 | wcharczuk/go-chart | seq/seq.go | Median | func (s Seq) Median() (median float64) {
l := s.Len()
if l == 0 {
return
}
sorted := s.Sort()
if l%2 == 0 {
v0 := sorted.GetValue(l/2 - 1)
v1 := sorted.GetValue(l/2 + 1)
median = (v0 + v1) / 2
} else {
median = float64(sorted.GetValue(l << 1))
}
return
} | go | func (s Seq) Median() (median float64) {
l := s.Len()
if l == 0 {
return
}
sorted := s.Sort()
if l%2 == 0 {
v0 := sorted.GetValue(l/2 - 1)
v1 := sorted.GetValue(l/2 + 1)
median = (v0 + v1) / 2
} else {
median = float64(sorted.GetValue(l << 1))
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Median",
"(",
")",
"(",
"median",
"float64",
")",
"{",
"l",
":=",
"s",
".",
"Len",
"(",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"\n",
"}",
"\n\n",
"sorted",
":=",
"s",
".",
"Sort",
"(",
")",
"\n",
"if"... | // Median returns the median or middle value in the sorted seq. | [
"Median",
"returns",
"the",
"median",
"or",
"middle",
"value",
"in",
"the",
"sorted",
"seq",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L157-L173 |
25,452 | wcharczuk/go-chart | seq/seq.go | Sum | func (s Seq) Sum() (accum float64) {
if s.Len() == 0 {
return 0
}
for i := 0; i < s.Len(); i++ {
accum += s.GetValue(i)
}
return
} | go | func (s Seq) Sum() (accum float64) {
if s.Len() == 0 {
return 0
}
for i := 0; i < s.Len(); i++ {
accum += s.GetValue(i)
}
return
} | [
"func",
"(",
"s",
"Seq",
")",
"Sum",
"(",
")",
"(",
"accum",
"float64",
")",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"s",
".",
"Len",
"(",
")",
";",
"... | // Sum adds all the elements of a series together. | [
"Sum",
"adds",
"all",
"the",
"elements",
"of",
"a",
"series",
"together",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L176-L185 |
25,453 | wcharczuk/go-chart | seq/seq.go | Average | func (s Seq) Average() float64 {
if s.Len() == 0 {
return 0
}
return s.Sum() / float64(s.Len())
} | go | func (s Seq) Average() float64 {
if s.Len() == 0 {
return 0
}
return s.Sum() / float64(s.Len())
} | [
"func",
"(",
"s",
"Seq",
")",
"Average",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"return",
"s",
".",
"Sum",
"(",
")",
"/",
"float64",
"(",
"s",
".",
"Len",
"(",
")",
")",
... | // Average returns the float average of the values in the buffer. | [
"Average",
"returns",
"the",
"float",
"average",
"of",
"the",
"values",
"in",
"the",
"buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L188-L194 |
25,454 | wcharczuk/go-chart | seq/seq.go | Variance | func (s Seq) Variance() float64 {
if s.Len() == 0 {
return 0
}
m := s.Average()
var variance, v float64
for i := 0; i < s.Len(); i++ {
v = s.GetValue(i)
variance += (v - m) * (v - m)
}
return variance / float64(s.Len())
} | go | func (s Seq) Variance() float64 {
if s.Len() == 0 {
return 0
}
m := s.Average()
var variance, v float64
for i := 0; i < s.Len(); i++ {
v = s.GetValue(i)
variance += (v - m) * (v - m)
}
return variance / float64(s.Len())
} | [
"func",
"(",
"s",
"Seq",
")",
"Variance",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"m",
":=",
"s",
".",
"Average",
"(",
")",
"\n",
"var",
"variance",
",",
"v",
"float64",
"\n... | // Variance computes the variance of the buffer. | [
"Variance",
"computes",
"the",
"variance",
"of",
"the",
"buffer",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L197-L210 |
25,455 | wcharczuk/go-chart | seq/seq.go | StdDev | func (s Seq) StdDev() float64 {
if s.Len() == 0 {
return 0
}
return math.Pow(s.Variance(), 0.5)
} | go | func (s Seq) StdDev() float64 {
if s.Len() == 0 {
return 0
}
return math.Pow(s.Variance(), 0.5)
} | [
"func",
"(",
"s",
"Seq",
")",
"StdDev",
"(",
")",
"float64",
"{",
"if",
"s",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"return",
"math",
".",
"Pow",
"(",
"s",
".",
"Variance",
"(",
")",
",",
"0.5",
")",
"\n",
"... | // StdDev returns the standard deviation. | [
"StdDev",
"returns",
"the",
"standard",
"deviation",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L213-L219 |
25,456 | wcharczuk/go-chart | seq/seq.go | Percentile | func (s Seq) Percentile(percent float64) (percentile float64) {
l := s.Len()
if l == 0 {
return 0
}
if percent < 0 || percent > 1.0 {
panic("percent out of range [0.0, 1.0)")
}
sorted := s.Sort()
index := percent * float64(l)
if index == float64(int64(index)) {
i := f64i(index)
ci := sorted.GetValue(i... | go | func (s Seq) Percentile(percent float64) (percentile float64) {
l := s.Len()
if l == 0 {
return 0
}
if percent < 0 || percent > 1.0 {
panic("percent out of range [0.0, 1.0)")
}
sorted := s.Sort()
index := percent * float64(l)
if index == float64(int64(index)) {
i := f64i(index)
ci := sorted.GetValue(i... | [
"func",
"(",
"s",
"Seq",
")",
"Percentile",
"(",
"percent",
"float64",
")",
"(",
"percentile",
"float64",
")",
"{",
"l",
":=",
"s",
".",
"Len",
"(",
")",
"\n",
"if",
"l",
"==",
"0",
"{",
"return",
"0",
"\n",
"}",
"\n\n",
"if",
"percent",
"<",
"... | //Percentile finds the relative standing in a slice of floats.
// `percent` should be given on the interval [0,1.0). | [
"Percentile",
"finds",
"the",
"relative",
"standing",
"in",
"a",
"slice",
"of",
"floats",
".",
"percent",
"should",
"be",
"given",
"on",
"the",
"interval",
"[",
"0",
"1",
".",
"0",
")",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/seq/seq.go#L223-L246 |
25,457 | wcharczuk/go-chart | polynomial_regression_series.go | GetValues | func (prs *PolynomialRegressionSeries) GetValues(index int) (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
offset := prs.GetOffset()
effectiveIndex... | go | func (prs *PolynomialRegressionSeries) GetValues(index int) (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
offset := prs.GetOffset()
effectiveIndex... | [
"func",
"(",
"prs",
"*",
"PolynomialRegressionSeries",
")",
"GetValues",
"(",
"index",
"int",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"prs",
".",
"InnerSeries",
"==",
"nil",
"||",
"prs",
".",
"InnerSeries",
".",
"Len",
"(",
")",
"==",
"0"... | // GetValues returns the series value for a given index. | [
"GetValues",
"returns",
"the",
"series",
"value",
"for",
"a",
"given",
"index",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/polynomial_regression_series.go#L91-L109 |
25,458 | wcharczuk/go-chart | polynomial_regression_series.go | GetFirstValues | func (prs *PolynomialRegressionSeries) GetFirstValues() (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
x, y = prs.InnerSeries.GetValues(0)
y = prs.ap... | go | func (prs *PolynomialRegressionSeries) GetFirstValues() (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
x, y = prs.InnerSeries.GetValues(0)
y = prs.ap... | [
"func",
"(",
"prs",
"*",
"PolynomialRegressionSeries",
")",
"GetFirstValues",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"prs",
".",
"InnerSeries",
"==",
"nil",
"||",
"prs",
".",
"InnerSeries",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"ret... | // GetFirstValues computes the first poly regression value. | [
"GetFirstValues",
"computes",
"the",
"first",
"poly",
"regression",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/polynomial_regression_series.go#L112-L126 |
25,459 | wcharczuk/go-chart | polynomial_regression_series.go | GetLastValues | func (prs *PolynomialRegressionSeries) GetLastValues() (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
endIndex := prs.GetEndIndex()
x, y = prs.InnerS... | go | func (prs *PolynomialRegressionSeries) GetLastValues() (x, y float64) {
if prs.InnerSeries == nil || prs.InnerSeries.Len() == 0 {
return
}
if prs.coeffs == nil {
coeffs, err := prs.computeCoefficients()
if err != nil {
panic(err)
}
prs.coeffs = coeffs
}
endIndex := prs.GetEndIndex()
x, y = prs.InnerS... | [
"func",
"(",
"prs",
"*",
"PolynomialRegressionSeries",
")",
"GetLastValues",
"(",
")",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"prs",
".",
"InnerSeries",
"==",
"nil",
"||",
"prs",
".",
"InnerSeries",
".",
"Len",
"(",
")",
"==",
"0",
"{",
"retu... | // GetLastValues computes the last poly regression value. | [
"GetLastValues",
"computes",
"the",
"last",
"poly",
"regression",
"value",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/polynomial_regression_series.go#L129-L144 |
25,460 | wcharczuk/go-chart | jet.go | Jet | func Jet(v, vmin, vmax float64) drawing.Color {
c := drawing.Color{R: 0xff, G: 0xff, B: 0xff, A: 0xff} // white
var dv float64
if v < vmin {
v = vmin
}
if v > vmax {
v = vmax
}
dv = vmax - vmin
if v < (vmin + 0.25*dv) {
c.R = 0
c.G = drawing.ColorChannelFromFloat(4 * (v - vmin) / dv)
} else if v < (v... | go | func Jet(v, vmin, vmax float64) drawing.Color {
c := drawing.Color{R: 0xff, G: 0xff, B: 0xff, A: 0xff} // white
var dv float64
if v < vmin {
v = vmin
}
if v > vmax {
v = vmax
}
dv = vmax - vmin
if v < (vmin + 0.25*dv) {
c.R = 0
c.G = drawing.ColorChannelFromFloat(4 * (v - vmin) / dv)
} else if v < (v... | [
"func",
"Jet",
"(",
"v",
",",
"vmin",
",",
"vmax",
"float64",
")",
"drawing",
".",
"Color",
"{",
"c",
":=",
"drawing",
".",
"Color",
"{",
"R",
":",
"0xff",
",",
"G",
":",
"0xff",
",",
"B",
":",
"0xff",
",",
"A",
":",
"0xff",
"}",
"// white",
... | // Jet is a color map provider based on matlab's jet color map. | [
"Jet",
"is",
"a",
"color",
"map",
"provider",
"based",
"on",
"matlab",
"s",
"jet",
"color",
"map",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/jet.go#L6-L33 |
25,461 | wcharczuk/go-chart | drawing/color.go | ColorFromHex | func ColorFromHex(hex string) Color {
var c Color
if len(hex) == 3 {
c.R = parseHex(string(hex[0])) * 0x11
c.G = parseHex(string(hex[1])) * 0x11
c.B = parseHex(string(hex[2])) * 0x11
} else {
c.R = parseHex(string(hex[0:2]))
c.G = parseHex(string(hex[2:4]))
c.B = parseHex(string(hex[4:6]))
}
c.A = 255
... | go | func ColorFromHex(hex string) Color {
var c Color
if len(hex) == 3 {
c.R = parseHex(string(hex[0])) * 0x11
c.G = parseHex(string(hex[1])) * 0x11
c.B = parseHex(string(hex[2])) * 0x11
} else {
c.R = parseHex(string(hex[0:2]))
c.G = parseHex(string(hex[2:4]))
c.B = parseHex(string(hex[4:6]))
}
c.A = 255
... | [
"func",
"ColorFromHex",
"(",
"hex",
"string",
")",
"Color",
"{",
"var",
"c",
"Color",
"\n",
"if",
"len",
"(",
"hex",
")",
"==",
"3",
"{",
"c",
".",
"R",
"=",
"parseHex",
"(",
"string",
"(",
"hex",
"[",
"0",
"]",
")",
")",
"*",
"0x11",
"\n",
"... | // ColorFromHex returns a color from a css hex code. | [
"ColorFromHex",
"returns",
"a",
"color",
"from",
"a",
"css",
"hex",
"code",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L34-L47 |
25,462 | wcharczuk/go-chart | drawing/color.go | ColorFromAlphaMixedRGBA | func ColorFromAlphaMixedRGBA(r, g, b, a uint32) Color {
fa := float64(a) / 255.0
var c Color
c.R = uint8(float64(r) / fa)
c.G = uint8(float64(g) / fa)
c.B = uint8(float64(b) / fa)
c.A = uint8(a | (a >> 8))
return c
} | go | func ColorFromAlphaMixedRGBA(r, g, b, a uint32) Color {
fa := float64(a) / 255.0
var c Color
c.R = uint8(float64(r) / fa)
c.G = uint8(float64(g) / fa)
c.B = uint8(float64(b) / fa)
c.A = uint8(a | (a >> 8))
return c
} | [
"func",
"ColorFromAlphaMixedRGBA",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"uint32",
")",
"Color",
"{",
"fa",
":=",
"float64",
"(",
"a",
")",
"/",
"255.0",
"\n",
"var",
"c",
"Color",
"\n",
"c",
".",
"R",
"=",
"uint8",
"(",
"float64",
"(",
"r",
... | // ColorFromAlphaMixedRGBA returns the system alpha mixed rgba values. | [
"ColorFromAlphaMixedRGBA",
"returns",
"the",
"system",
"alpha",
"mixed",
"rgba",
"values",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L50-L58 |
25,463 | wcharczuk/go-chart | drawing/color.go | RGBA | func (c Color) RGBA() (r, g, b, a uint32) {
fa := float64(c.A) / 255.0
r = uint32(float64(uint32(c.R)) * fa)
r |= r << 8
g = uint32(float64(uint32(c.G)) * fa)
g |= g << 8
b = uint32(float64(uint32(c.B)) * fa)
b |= b << 8
a = uint32(c.A)
a |= a << 8
return
} | go | func (c Color) RGBA() (r, g, b, a uint32) {
fa := float64(c.A) / 255.0
r = uint32(float64(uint32(c.R)) * fa)
r |= r << 8
g = uint32(float64(uint32(c.G)) * fa)
g |= g << 8
b = uint32(float64(uint32(c.B)) * fa)
b |= b << 8
a = uint32(c.A)
a |= a << 8
return
} | [
"func",
"(",
"c",
"Color",
")",
"RGBA",
"(",
")",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"uint32",
")",
"{",
"fa",
":=",
"float64",
"(",
"c",
".",
"A",
")",
"/",
"255.0",
"\n",
"r",
"=",
"uint32",
"(",
"float64",
"(",
"uint32",
"(",
"c",
... | // RGBA returns the color as a pre-alpha mixed color set. | [
"RGBA",
"returns",
"the",
"color",
"as",
"a",
"pre",
"-",
"alpha",
"mixed",
"color",
"set",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L71-L82 |
25,464 | wcharczuk/go-chart | drawing/color.go | IsZero | func (c Color) IsZero() bool {
return c.R == 0 && c.G == 0 && c.B == 0 && c.A == 0
} | go | func (c Color) IsZero() bool {
return c.R == 0 && c.G == 0 && c.B == 0 && c.A == 0
} | [
"func",
"(",
"c",
"Color",
")",
"IsZero",
"(",
")",
"bool",
"{",
"return",
"c",
".",
"R",
"==",
"0",
"&&",
"c",
".",
"G",
"==",
"0",
"&&",
"c",
".",
"B",
"==",
"0",
"&&",
"c",
".",
"A",
"==",
"0",
"\n",
"}"
] | // IsZero returns if the color has been set or not. | [
"IsZero",
"returns",
"if",
"the",
"color",
"has",
"been",
"set",
"or",
"not",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L85-L87 |
25,465 | wcharczuk/go-chart | drawing/color.go | WithAlpha | func (c Color) WithAlpha(a uint8) Color {
return Color{
R: c.R,
G: c.G,
B: c.B,
A: a,
}
} | go | func (c Color) WithAlpha(a uint8) Color {
return Color{
R: c.R,
G: c.G,
B: c.B,
A: a,
}
} | [
"func",
"(",
"c",
"Color",
")",
"WithAlpha",
"(",
"a",
"uint8",
")",
"Color",
"{",
"return",
"Color",
"{",
"R",
":",
"c",
".",
"R",
",",
"G",
":",
"c",
".",
"G",
",",
"B",
":",
"c",
".",
"B",
",",
"A",
":",
"a",
",",
"}",
"\n",
"}"
] | // WithAlpha returns a copy of the color with a given alpha. | [
"WithAlpha",
"returns",
"a",
"copy",
"of",
"the",
"color",
"with",
"a",
"given",
"alpha",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L95-L102 |
25,466 | wcharczuk/go-chart | drawing/color.go | Equals | func (c Color) Equals(other Color) bool {
return c.R == other.R &&
c.G == other.G &&
c.B == other.B &&
c.A == other.A
} | go | func (c Color) Equals(other Color) bool {
return c.R == other.R &&
c.G == other.G &&
c.B == other.B &&
c.A == other.A
} | [
"func",
"(",
"c",
"Color",
")",
"Equals",
"(",
"other",
"Color",
")",
"bool",
"{",
"return",
"c",
".",
"R",
"==",
"other",
".",
"R",
"&&",
"c",
".",
"G",
"==",
"other",
".",
"G",
"&&",
"c",
".",
"B",
"==",
"other",
".",
"B",
"&&",
"c",
".",... | // Equals returns true if the color equals another. | [
"Equals",
"returns",
"true",
"if",
"the",
"color",
"equals",
"another",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L105-L110 |
25,467 | wcharczuk/go-chart | drawing/color.go | AverageWith | func (c Color) AverageWith(other Color) Color {
return Color{
R: (c.R + other.R) >> 1,
G: (c.G + other.G) >> 1,
B: (c.B + other.B) >> 1,
A: c.A,
}
} | go | func (c Color) AverageWith(other Color) Color {
return Color{
R: (c.R + other.R) >> 1,
G: (c.G + other.G) >> 1,
B: (c.B + other.B) >> 1,
A: c.A,
}
} | [
"func",
"(",
"c",
"Color",
")",
"AverageWith",
"(",
"other",
"Color",
")",
"Color",
"{",
"return",
"Color",
"{",
"R",
":",
"(",
"c",
".",
"R",
"+",
"other",
".",
"R",
")",
">>",
"1",
",",
"G",
":",
"(",
"c",
".",
"G",
"+",
"other",
".",
"G"... | // AverageWith averages two colors. | [
"AverageWith",
"averages",
"two",
"colors",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L113-L120 |
25,468 | wcharczuk/go-chart | drawing/color.go | String | func (c Color) String() string {
fa := float64(c.A) / float64(255)
return fmt.Sprintf("rgba(%v,%v,%v,%.1f)", c.R, c.G, c.B, fa)
} | go | func (c Color) String() string {
fa := float64(c.A) / float64(255)
return fmt.Sprintf("rgba(%v,%v,%v,%.1f)", c.R, c.G, c.B, fa)
} | [
"func",
"(",
"c",
"Color",
")",
"String",
"(",
")",
"string",
"{",
"fa",
":=",
"float64",
"(",
"c",
".",
"A",
")",
"/",
"float64",
"(",
"255",
")",
"\n",
"return",
"fmt",
".",
"Sprintf",
"(",
"\"",
"\"",
",",
"c",
".",
"R",
",",
"c",
".",
"... | // String returns a css string representation of the color. | [
"String",
"returns",
"a",
"css",
"string",
"representation",
"of",
"the",
"color",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/color.go#L123-L126 |
25,469 | wcharczuk/go-chart | annotation_series.go | Measure | func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) Box {
box := Box{
Top: math.MaxInt32,
Left: math.MaxInt32,
Right: 0,
Bottom: 0,
}
if as.Style.IsZero() || as.Style.Show {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for... | go | func (as AnnotationSeries) Measure(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) Box {
box := Box{
Top: math.MaxInt32,
Left: math.MaxInt32,
Right: 0,
Bottom: 0,
}
if as.Style.IsZero() || as.Style.Show {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for... | [
"func",
"(",
"as",
"AnnotationSeries",
")",
"Measure",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"xrange",
",",
"yrange",
"Range",
",",
"defaults",
"Style",
")",
"Box",
"{",
"box",
":=",
"Box",
"{",
"Top",
":",
"math",
".",
"MaxInt32",
",",
... | // Measure returns a bounds box of the series. | [
"Measure",
"returns",
"a",
"bounds",
"box",
"of",
"the",
"series",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/annotation_series.go#L51-L72 |
25,470 | wcharczuk/go-chart | annotation_series.go | Render | func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
if as.Style.IsZero() || as.Style.Show {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for _, a := range as.Annotations {
style := a.Style.InheritFrom(seriesStyle)
lx := canvasBox.L... | go | func (as AnnotationSeries) Render(r Renderer, canvasBox Box, xrange, yrange Range, defaults Style) {
if as.Style.IsZero() || as.Style.Show {
seriesStyle := as.Style.InheritFrom(as.annotationStyleDefaults(defaults))
for _, a := range as.Annotations {
style := a.Style.InheritFrom(seriesStyle)
lx := canvasBox.L... | [
"func",
"(",
"as",
"AnnotationSeries",
")",
"Render",
"(",
"r",
"Renderer",
",",
"canvasBox",
"Box",
",",
"xrange",
",",
"yrange",
"Range",
",",
"defaults",
"Style",
")",
"{",
"if",
"as",
".",
"Style",
".",
"IsZero",
"(",
")",
"||",
"as",
".",
"Style... | // Render draws the series. | [
"Render",
"draws",
"the",
"series",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/annotation_series.go#L75-L85 |
25,471 | wcharczuk/go-chart | drawing/line.go | PolylineBresenham | func PolylineBresenham(img draw.Image, c color.Color, s ...float64) {
for i := 2; i < len(s); i += 2 {
Bresenham(img, c, int(s[i-2]+0.5), int(s[i-1]+0.5), int(s[i]+0.5), int(s[i+1]+0.5))
}
} | go | func PolylineBresenham(img draw.Image, c color.Color, s ...float64) {
for i := 2; i < len(s); i += 2 {
Bresenham(img, c, int(s[i-2]+0.5), int(s[i-1]+0.5), int(s[i]+0.5), int(s[i+1]+0.5))
}
} | [
"func",
"PolylineBresenham",
"(",
"img",
"draw",
".",
"Image",
",",
"c",
"color",
".",
"Color",
",",
"s",
"...",
"float64",
")",
"{",
"for",
"i",
":=",
"2",
";",
"i",
"<",
"len",
"(",
"s",
")",
";",
"i",
"+=",
"2",
"{",
"Bresenham",
"(",
"img",... | // PolylineBresenham draws a polyline to an image | [
"PolylineBresenham",
"draws",
"a",
"polyline",
"to",
"an",
"image"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/line.go#L9-L13 |
25,472 | wcharczuk/go-chart | drawing/matrix.go | Transform | func (tr Matrix) Transform(points []float64) {
for i, j := 0, 1; j < len(points); i, j = i+2, j+2 {
x := points[i]
y := points[j]
points[i] = x*tr[0] + y*tr[2] + tr[4]
points[j] = x*tr[1] + y*tr[3] + tr[5]
}
} | go | func (tr Matrix) Transform(points []float64) {
for i, j := 0, 1; j < len(points); i, j = i+2, j+2 {
x := points[i]
y := points[j]
points[i] = x*tr[0] + y*tr[2] + tr[4]
points[j] = x*tr[1] + y*tr[3] + tr[5]
}
} | [
"func",
"(",
"tr",
"Matrix",
")",
"Transform",
"(",
"points",
"[",
"]",
"float64",
")",
"{",
"for",
"i",
",",
"j",
":=",
"0",
",",
"1",
";",
"j",
"<",
"len",
"(",
"points",
")",
";",
"i",
",",
"j",
"=",
"i",
"+",
"2",
",",
"j",
"+",
"2",
... | // Transform applies the transformation matrix to points. It modify the points passed in parameter. | [
"Transform",
"applies",
"the",
"transformation",
"matrix",
"to",
"points",
".",
"It",
"modify",
"the",
"points",
"passed",
"in",
"parameter",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L20-L27 |
25,473 | wcharczuk/go-chart | drawing/matrix.go | TransformPoint | func (tr Matrix) TransformPoint(x, y float64) (xres, yres float64) {
xres = x*tr[0] + y*tr[2] + tr[4]
yres = x*tr[1] + y*tr[3] + tr[5]
return xres, yres
} | go | func (tr Matrix) TransformPoint(x, y float64) (xres, yres float64) {
xres = x*tr[0] + y*tr[2] + tr[4]
yres = x*tr[1] + y*tr[3] + tr[5]
return xres, yres
} | [
"func",
"(",
"tr",
"Matrix",
")",
"TransformPoint",
"(",
"x",
",",
"y",
"float64",
")",
"(",
"xres",
",",
"yres",
"float64",
")",
"{",
"xres",
"=",
"x",
"*",
"tr",
"[",
"0",
"]",
"+",
"y",
"*",
"tr",
"[",
"2",
"]",
"+",
"tr",
"[",
"4",
"]",... | // TransformPoint applies the transformation matrix to point. It returns the point the transformed point. | [
"TransformPoint",
"applies",
"the",
"transformation",
"matrix",
"to",
"point",
".",
"It",
"returns",
"the",
"point",
"the",
"transformed",
"point",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L30-L34 |
25,474 | wcharczuk/go-chart | drawing/matrix.go | TransformRectangle | func (tr Matrix) TransformRectangle(x0, y0, x2, y2 float64) (nx0, ny0, nx2, ny2 float64) {
points := []float64{x0, y0, x2, y0, x2, y2, x0, y2}
tr.Transform(points)
points[0], points[2] = minMax(points[0], points[2])
points[4], points[6] = minMax(points[4], points[6])
points[1], points[3] = minMax(points[1], points... | go | func (tr Matrix) TransformRectangle(x0, y0, x2, y2 float64) (nx0, ny0, nx2, ny2 float64) {
points := []float64{x0, y0, x2, y0, x2, y2, x0, y2}
tr.Transform(points)
points[0], points[2] = minMax(points[0], points[2])
points[4], points[6] = minMax(points[4], points[6])
points[1], points[3] = minMax(points[1], points... | [
"func",
"(",
"tr",
"Matrix",
")",
"TransformRectangle",
"(",
"x0",
",",
"y0",
",",
"x2",
",",
"y2",
"float64",
")",
"(",
"nx0",
",",
"ny0",
",",
"nx2",
",",
"ny2",
"float64",
")",
"{",
"points",
":=",
"[",
"]",
"float64",
"{",
"x0",
",",
"y0",
... | // TransformRectangle applies the transformation matrix to the rectangle represented by the min and the max point of the rectangle | [
"TransformRectangle",
"applies",
"the",
"transformation",
"matrix",
"to",
"the",
"rectangle",
"represented",
"by",
"the",
"min",
"and",
"the",
"max",
"point",
"of",
"the",
"rectangle"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L44-L57 |
25,475 | wcharczuk/go-chart | drawing/matrix.go | InverseTransform | func (tr Matrix) InverseTransform(points []float64) {
d := tr.Determinant() // matrix determinant
for i, j := 0, 1; j < len(points); i, j = i+2, j+2 {
x := points[i]
y := points[j]
points[i] = ((x-tr[4])*tr[3] - (y-tr[5])*tr[2]) / d
points[j] = ((y-tr[5])*tr[0] - (x-tr[4])*tr[1]) / d
}
} | go | func (tr Matrix) InverseTransform(points []float64) {
d := tr.Determinant() // matrix determinant
for i, j := 0, 1; j < len(points); i, j = i+2, j+2 {
x := points[i]
y := points[j]
points[i] = ((x-tr[4])*tr[3] - (y-tr[5])*tr[2]) / d
points[j] = ((y-tr[5])*tr[0] - (x-tr[4])*tr[1]) / d
}
} | [
"func",
"(",
"tr",
"Matrix",
")",
"InverseTransform",
"(",
"points",
"[",
"]",
"float64",
")",
"{",
"d",
":=",
"tr",
".",
"Determinant",
"(",
")",
"// matrix determinant",
"\n",
"for",
"i",
",",
"j",
":=",
"0",
",",
"1",
";",
"j",
"<",
"len",
"(",
... | // InverseTransform applies the transformation inverse matrix to the rectangle represented by the min and the max point of the rectangle | [
"InverseTransform",
"applies",
"the",
"transformation",
"inverse",
"matrix",
"to",
"the",
"rectangle",
"represented",
"by",
"the",
"min",
"and",
"the",
"max",
"point",
"of",
"the",
"rectangle"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L60-L68 |
25,476 | wcharczuk/go-chart | drawing/matrix.go | InverseTransformPoint | func (tr Matrix) InverseTransformPoint(x, y float64) (xres, yres float64) {
d := tr.Determinant() // matrix determinant
xres = ((x-tr[4])*tr[3] - (y-tr[5])*tr[2]) / d
yres = ((y-tr[5])*tr[0] - (x-tr[4])*tr[1]) / d
return xres, yres
} | go | func (tr Matrix) InverseTransformPoint(x, y float64) (xres, yres float64) {
d := tr.Determinant() // matrix determinant
xres = ((x-tr[4])*tr[3] - (y-tr[5])*tr[2]) / d
yres = ((y-tr[5])*tr[0] - (x-tr[4])*tr[1]) / d
return xres, yres
} | [
"func",
"(",
"tr",
"Matrix",
")",
"InverseTransformPoint",
"(",
"x",
",",
"y",
"float64",
")",
"(",
"xres",
",",
"yres",
"float64",
")",
"{",
"d",
":=",
"tr",
".",
"Determinant",
"(",
")",
"// matrix determinant",
"\n",
"xres",
"=",
"(",
"(",
"x",
"-... | // InverseTransformPoint applies the transformation inverse matrix to point. It returns the point the transformed point. | [
"InverseTransformPoint",
"applies",
"the",
"transformation",
"inverse",
"matrix",
"to",
"point",
".",
"It",
"returns",
"the",
"point",
"the",
"transformed",
"point",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L71-L76 |
25,477 | wcharczuk/go-chart | drawing/matrix.go | NewRotationMatrix | func NewRotationMatrix(angle float64) Matrix {
c := math.Cos(angle)
s := math.Sin(angle)
return Matrix{c, s, -s, c, 0, 0}
} | go | func NewRotationMatrix(angle float64) Matrix {
c := math.Cos(angle)
s := math.Sin(angle)
return Matrix{c, s, -s, c, 0, 0}
} | [
"func",
"NewRotationMatrix",
"(",
"angle",
"float64",
")",
"Matrix",
"{",
"c",
":=",
"math",
".",
"Cos",
"(",
"angle",
")",
"\n",
"s",
":=",
"math",
".",
"Sin",
"(",
"angle",
")",
"\n",
"return",
"Matrix",
"{",
"c",
",",
"s",
",",
"-",
"s",
",",
... | // NewRotationMatrix creates a rotation transformation matrix. angle is in radian | [
"NewRotationMatrix",
"creates",
"a",
"rotation",
"transformation",
"matrix",
".",
"angle",
"is",
"in",
"radian"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L105-L109 |
25,478 | wcharczuk/go-chart | drawing/matrix.go | NewMatrixFromRects | func NewMatrixFromRects(rectangle1, rectangle2 [4]float64) Matrix {
xScale := (rectangle2[2] - rectangle2[0]) / (rectangle1[2] - rectangle1[0])
yScale := (rectangle2[3] - rectangle2[1]) / (rectangle1[3] - rectangle1[1])
xOffset := rectangle2[0] - (rectangle1[0] * xScale)
yOffset := rectangle2[1] - (rectangle1[1] * ... | go | func NewMatrixFromRects(rectangle1, rectangle2 [4]float64) Matrix {
xScale := (rectangle2[2] - rectangle2[0]) / (rectangle1[2] - rectangle1[0])
yScale := (rectangle2[3] - rectangle2[1]) / (rectangle1[3] - rectangle1[1])
xOffset := rectangle2[0] - (rectangle1[0] * xScale)
yOffset := rectangle2[1] - (rectangle1[1] * ... | [
"func",
"NewMatrixFromRects",
"(",
"rectangle1",
",",
"rectangle2",
"[",
"4",
"]",
"float64",
")",
"Matrix",
"{",
"xScale",
":=",
"(",
"rectangle2",
"[",
"2",
"]",
"-",
"rectangle2",
"[",
"0",
"]",
")",
"/",
"(",
"rectangle1",
"[",
"2",
"]",
"-",
"re... | // NewMatrixFromRects creates a transformation matrix, combining a scale and a translation, that transform rectangle1 into rectangle2. | [
"NewMatrixFromRects",
"creates",
"a",
"transformation",
"matrix",
"combining",
"a",
"scale",
"and",
"a",
"translation",
"that",
"transform",
"rectangle1",
"into",
"rectangle2",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L112-L118 |
25,479 | wcharczuk/go-chart | drawing/matrix.go | Inverse | func (tr *Matrix) Inverse() {
d := tr.Determinant() // matrix determinant
tr0, tr1, tr2, tr3, tr4, tr5 := tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]
tr[0] = tr3 / d
tr[1] = -tr1 / d
tr[2] = -tr2 / d
tr[3] = tr0 / d
tr[4] = (tr2*tr5 - tr3*tr4) / d
tr[5] = (tr1*tr4 - tr0*tr5) / d
} | go | func (tr *Matrix) Inverse() {
d := tr.Determinant() // matrix determinant
tr0, tr1, tr2, tr3, tr4, tr5 := tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]
tr[0] = tr3 / d
tr[1] = -tr1 / d
tr[2] = -tr2 / d
tr[3] = tr0 / d
tr[4] = (tr2*tr5 - tr3*tr4) / d
tr[5] = (tr1*tr4 - tr0*tr5) / d
} | [
"func",
"(",
"tr",
"*",
"Matrix",
")",
"Inverse",
"(",
")",
"{",
"d",
":=",
"tr",
".",
"Determinant",
"(",
")",
"// matrix determinant",
"\n",
"tr0",
",",
"tr1",
",",
"tr2",
",",
"tr3",
",",
"tr4",
",",
"tr5",
":=",
"tr",
"[",
"0",
"]",
",",
"t... | // Inverse computes the inverse matrix | [
"Inverse",
"computes",
"the",
"inverse",
"matrix"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L121-L130 |
25,480 | wcharczuk/go-chart | drawing/matrix.go | Copy | func (tr Matrix) Copy() Matrix {
var result Matrix
copy(result[:], tr[:])
return result
} | go | func (tr Matrix) Copy() Matrix {
var result Matrix
copy(result[:], tr[:])
return result
} | [
"func",
"(",
"tr",
"Matrix",
")",
"Copy",
"(",
")",
"Matrix",
"{",
"var",
"result",
"Matrix",
"\n",
"copy",
"(",
"result",
"[",
":",
"]",
",",
"tr",
"[",
":",
"]",
")",
"\n",
"return",
"result",
"\n",
"}"
] | // Copy copies the matrix. | [
"Copy",
"copies",
"the",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L133-L137 |
25,481 | wcharczuk/go-chart | drawing/matrix.go | Compose | func (tr *Matrix) Compose(trToCompose Matrix) {
tr0, tr1, tr2, tr3, tr4, tr5 := tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]
tr[0] = trToCompose[0]*tr0 + trToCompose[1]*tr2
tr[1] = trToCompose[1]*tr3 + trToCompose[0]*tr1
tr[2] = trToCompose[2]*tr0 + trToCompose[3]*tr2
tr[3] = trToCompose[3]*tr3 + trToCompose[2]*tr1
t... | go | func (tr *Matrix) Compose(trToCompose Matrix) {
tr0, tr1, tr2, tr3, tr4, tr5 := tr[0], tr[1], tr[2], tr[3], tr[4], tr[5]
tr[0] = trToCompose[0]*tr0 + trToCompose[1]*tr2
tr[1] = trToCompose[1]*tr3 + trToCompose[0]*tr1
tr[2] = trToCompose[2]*tr0 + trToCompose[3]*tr2
tr[3] = trToCompose[3]*tr3 + trToCompose[2]*tr1
t... | [
"func",
"(",
"tr",
"*",
"Matrix",
")",
"Compose",
"(",
"trToCompose",
"Matrix",
")",
"{",
"tr0",
",",
"tr1",
",",
"tr2",
",",
"tr3",
",",
"tr4",
",",
"tr5",
":=",
"tr",
"[",
"0",
"]",
",",
"tr",
"[",
"1",
"]",
",",
"tr",
"[",
"2",
"]",
",",... | // Compose multiplies trToConcat x tr | [
"Compose",
"multiplies",
"trToConcat",
"x",
"tr"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L140-L148 |
25,482 | wcharczuk/go-chart | drawing/matrix.go | Scale | func (tr *Matrix) Scale(sx, sy float64) {
tr[0] = sx * tr[0]
tr[1] = sx * tr[1]
tr[2] = sy * tr[2]
tr[3] = sy * tr[3]
} | go | func (tr *Matrix) Scale(sx, sy float64) {
tr[0] = sx * tr[0]
tr[1] = sx * tr[1]
tr[2] = sy * tr[2]
tr[3] = sy * tr[3]
} | [
"func",
"(",
"tr",
"*",
"Matrix",
")",
"Scale",
"(",
"sx",
",",
"sy",
"float64",
")",
"{",
"tr",
"[",
"0",
"]",
"=",
"sx",
"*",
"tr",
"[",
"0",
"]",
"\n",
"tr",
"[",
"1",
"]",
"=",
"sx",
"*",
"tr",
"[",
"1",
"]",
"\n",
"tr",
"[",
"2",
... | // Scale adds a scale to the matrix | [
"Scale",
"adds",
"a",
"scale",
"to",
"the",
"matrix"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L151-L156 |
25,483 | wcharczuk/go-chart | drawing/matrix.go | Translate | func (tr *Matrix) Translate(tx, ty float64) {
tr[4] = tx*tr[0] + ty*tr[2] + tr[4]
tr[5] = ty*tr[3] + tx*tr[1] + tr[5]
} | go | func (tr *Matrix) Translate(tx, ty float64) {
tr[4] = tx*tr[0] + ty*tr[2] + tr[4]
tr[5] = ty*tr[3] + tx*tr[1] + tr[5]
} | [
"func",
"(",
"tr",
"*",
"Matrix",
")",
"Translate",
"(",
"tx",
",",
"ty",
"float64",
")",
"{",
"tr",
"[",
"4",
"]",
"=",
"tx",
"*",
"tr",
"[",
"0",
"]",
"+",
"ty",
"*",
"tr",
"[",
"2",
"]",
"+",
"tr",
"[",
"4",
"]",
"\n",
"tr",
"[",
"5"... | // Translate adds a translation to the matrix | [
"Translate",
"adds",
"a",
"translation",
"to",
"the",
"matrix"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L159-L162 |
25,484 | wcharczuk/go-chart | drawing/matrix.go | Rotate | func (tr *Matrix) Rotate(radians float64) {
c := math.Cos(radians)
s := math.Sin(radians)
t0 := c*tr[0] + s*tr[2]
t1 := s*tr[3] + c*tr[1]
t2 := c*tr[2] - s*tr[0]
t3 := c*tr[3] - s*tr[1]
tr[0] = t0
tr[1] = t1
tr[2] = t2
tr[3] = t3
} | go | func (tr *Matrix) Rotate(radians float64) {
c := math.Cos(radians)
s := math.Sin(radians)
t0 := c*tr[0] + s*tr[2]
t1 := s*tr[3] + c*tr[1]
t2 := c*tr[2] - s*tr[0]
t3 := c*tr[3] - s*tr[1]
tr[0] = t0
tr[1] = t1
tr[2] = t2
tr[3] = t3
} | [
"func",
"(",
"tr",
"*",
"Matrix",
")",
"Rotate",
"(",
"radians",
"float64",
")",
"{",
"c",
":=",
"math",
".",
"Cos",
"(",
"radians",
")",
"\n",
"s",
":=",
"math",
".",
"Sin",
"(",
"radians",
")",
"\n",
"t0",
":=",
"c",
"*",
"tr",
"[",
"0",
"]... | // Rotate adds a rotation to the matrix. | [
"Rotate",
"adds",
"a",
"rotation",
"to",
"the",
"matrix",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L165-L176 |
25,485 | wcharczuk/go-chart | drawing/matrix.go | GetScale | func (tr Matrix) GetScale() float64 {
x := 0.707106781*tr[0] + 0.707106781*tr[1]
y := 0.707106781*tr[2] + 0.707106781*tr[3]
return math.Sqrt(x*x + y*y)
} | go | func (tr Matrix) GetScale() float64 {
x := 0.707106781*tr[0] + 0.707106781*tr[1]
y := 0.707106781*tr[2] + 0.707106781*tr[3]
return math.Sqrt(x*x + y*y)
} | [
"func",
"(",
"tr",
"Matrix",
")",
"GetScale",
"(",
")",
"float64",
"{",
"x",
":=",
"0.707106781",
"*",
"tr",
"[",
"0",
"]",
"+",
"0.707106781",
"*",
"tr",
"[",
"1",
"]",
"\n",
"y",
":=",
"0.707106781",
"*",
"tr",
"[",
"2",
"]",
"+",
"0.707106781"... | // GetScale computes a scale for the matrix | [
"GetScale",
"computes",
"a",
"scale",
"for",
"the",
"matrix"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L189-L193 |
25,486 | wcharczuk/go-chart | drawing/matrix.go | IsIdentity | func (tr Matrix) IsIdentity() bool {
return fequals(tr[4], 0) && fequals(tr[5], 0) && tr.IsTranslation()
} | go | func (tr Matrix) IsIdentity() bool {
return fequals(tr[4], 0) && fequals(tr[5], 0) && tr.IsTranslation()
} | [
"func",
"(",
"tr",
"Matrix",
")",
"IsIdentity",
"(",
")",
"bool",
"{",
"return",
"fequals",
"(",
"tr",
"[",
"4",
"]",
",",
"0",
")",
"&&",
"fequals",
"(",
"tr",
"[",
"5",
"]",
",",
"0",
")",
"&&",
"tr",
".",
"IsTranslation",
"(",
")",
"\n",
"... | // IsIdentity tests if a transformation is the identity transformation. A tolerance is applied when comparing matrix elements. | [
"IsIdentity",
"tests",
"if",
"a",
"transformation",
"is",
"the",
"identity",
"transformation",
".",
"A",
"tolerance",
"is",
"applied",
"when",
"comparing",
"matrix",
"elements",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L208-L210 |
25,487 | wcharczuk/go-chart | drawing/matrix.go | IsTranslation | func (tr Matrix) IsTranslation() bool {
return fequals(tr[0], 1) && fequals(tr[1], 0) && fequals(tr[2], 0) && fequals(tr[3], 1)
} | go | func (tr Matrix) IsTranslation() bool {
return fequals(tr[0], 1) && fequals(tr[1], 0) && fequals(tr[2], 0) && fequals(tr[3], 1)
} | [
"func",
"(",
"tr",
"Matrix",
")",
"IsTranslation",
"(",
")",
"bool",
"{",
"return",
"fequals",
"(",
"tr",
"[",
"0",
"]",
",",
"1",
")",
"&&",
"fequals",
"(",
"tr",
"[",
"1",
"]",
",",
"0",
")",
"&&",
"fequals",
"(",
"tr",
"[",
"2",
"]",
",",
... | // IsTranslation tests if a transformation is is a pure translation. A tolerance is applied when comparing matrix elements. | [
"IsTranslation",
"tests",
"if",
"a",
"transformation",
"is",
"is",
"a",
"pure",
"translation",
".",
"A",
"tolerance",
"is",
"applied",
"when",
"comparing",
"matrix",
"elements",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L213-L215 |
25,488 | wcharczuk/go-chart | drawing/matrix.go | fequals | func fequals(float1, float2 float64) bool {
return math.Abs(float1-float2) <= epsilon
} | go | func fequals(float1, float2 float64) bool {
return math.Abs(float1-float2) <= epsilon
} | [
"func",
"fequals",
"(",
"float1",
",",
"float2",
"float64",
")",
"bool",
"{",
"return",
"math",
".",
"Abs",
"(",
"float1",
"-",
"float2",
")",
"<=",
"epsilon",
"\n",
"}"
] | // fequals compares two floats. return true if the distance between the two floats is less than epsilon, false otherwise | [
"fequals",
"compares",
"two",
"floats",
".",
"return",
"true",
"if",
"the",
"distance",
"between",
"the",
"two",
"floats",
"is",
"less",
"than",
"epsilon",
"false",
"otherwise"
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/drawing/matrix.go#L218-L220 |
25,489 | wcharczuk/go-chart | raster_renderer.go | LineTo | func (rr *rasterRenderer) LineTo(x, y int) {
rr.gc.LineTo(float64(x), float64(y))
} | go | func (rr *rasterRenderer) LineTo(x, y int) {
rr.gc.LineTo(float64(x), float64(y))
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"LineTo",
"(",
"x",
",",
"y",
"int",
")",
"{",
"rr",
".",
"gc",
".",
"LineTo",
"(",
"float64",
"(",
"x",
")",
",",
"float64",
"(",
"y",
")",
")",
"\n",
"}"
] | // LineTo implements the interface method. | [
"LineTo",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L82-L84 |
25,490 | wcharczuk/go-chart | raster_renderer.go | QuadCurveTo | func (rr *rasterRenderer) QuadCurveTo(cx, cy, x, y int) {
rr.gc.QuadCurveTo(float64(cx), float64(cy), float64(x), float64(y))
} | go | func (rr *rasterRenderer) QuadCurveTo(cx, cy, x, y int) {
rr.gc.QuadCurveTo(float64(cx), float64(cy), float64(x), float64(y))
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"QuadCurveTo",
"(",
"cx",
",",
"cy",
",",
"x",
",",
"y",
"int",
")",
"{",
"rr",
".",
"gc",
".",
"QuadCurveTo",
"(",
"float64",
"(",
"cx",
")",
",",
"float64",
"(",
"cy",
")",
",",
"float64",
"(",
"... | // QuadCurveTo implements the interface method. | [
"QuadCurveTo",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L87-L89 |
25,491 | wcharczuk/go-chart | raster_renderer.go | ArcTo | func (rr *rasterRenderer) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) {
rr.gc.ArcTo(float64(cx), float64(cy), rx, ry, startAngle, delta)
} | go | func (rr *rasterRenderer) ArcTo(cx, cy int, rx, ry, startAngle, delta float64) {
rr.gc.ArcTo(float64(cx), float64(cy), rx, ry, startAngle, delta)
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"ArcTo",
"(",
"cx",
",",
"cy",
"int",
",",
"rx",
",",
"ry",
",",
"startAngle",
",",
"delta",
"float64",
")",
"{",
"rr",
".",
"gc",
".",
"ArcTo",
"(",
"float64",
"(",
"cx",
")",
",",
"float64",
"(",
... | // ArcTo implements the interface method. | [
"ArcTo",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L92-L94 |
25,492 | wcharczuk/go-chart | raster_renderer.go | Stroke | func (rr *rasterRenderer) Stroke() {
rr.gc.SetStrokeColor(rr.s.StrokeColor)
rr.gc.SetLineWidth(rr.s.StrokeWidth)
rr.gc.SetLineDash(rr.s.StrokeDashArray, 0)
rr.gc.Stroke()
} | go | func (rr *rasterRenderer) Stroke() {
rr.gc.SetStrokeColor(rr.s.StrokeColor)
rr.gc.SetLineWidth(rr.s.StrokeWidth)
rr.gc.SetLineDash(rr.s.StrokeDashArray, 0)
rr.gc.Stroke()
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"Stroke",
"(",
")",
"{",
"rr",
".",
"gc",
".",
"SetStrokeColor",
"(",
"rr",
".",
"s",
".",
"StrokeColor",
")",
"\n",
"rr",
".",
"gc",
".",
"SetLineWidth",
"(",
"rr",
".",
"s",
".",
"StrokeWidth",
")",
... | // Stroke implements the interface method. | [
"Stroke",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L102-L107 |
25,493 | wcharczuk/go-chart | raster_renderer.go | Fill | func (rr *rasterRenderer) Fill() {
rr.gc.SetFillColor(rr.s.FillColor)
rr.gc.Fill()
} | go | func (rr *rasterRenderer) Fill() {
rr.gc.SetFillColor(rr.s.FillColor)
rr.gc.Fill()
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"Fill",
"(",
")",
"{",
"rr",
".",
"gc",
".",
"SetFillColor",
"(",
"rr",
".",
"s",
".",
"FillColor",
")",
"\n",
"rr",
".",
"gc",
".",
"Fill",
"(",
")",
"\n",
"}"
] | // Fill implements the interface method. | [
"Fill",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L110-L113 |
25,494 | wcharczuk/go-chart | raster_renderer.go | FillStroke | func (rr *rasterRenderer) FillStroke() {
rr.gc.SetFillColor(rr.s.FillColor)
rr.gc.SetStrokeColor(rr.s.StrokeColor)
rr.gc.SetLineWidth(rr.s.StrokeWidth)
rr.gc.SetLineDash(rr.s.StrokeDashArray, 0)
rr.gc.FillStroke()
} | go | func (rr *rasterRenderer) FillStroke() {
rr.gc.SetFillColor(rr.s.FillColor)
rr.gc.SetStrokeColor(rr.s.StrokeColor)
rr.gc.SetLineWidth(rr.s.StrokeWidth)
rr.gc.SetLineDash(rr.s.StrokeDashArray, 0)
rr.gc.FillStroke()
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"FillStroke",
"(",
")",
"{",
"rr",
".",
"gc",
".",
"SetFillColor",
"(",
"rr",
".",
"s",
".",
"FillColor",
")",
"\n",
"rr",
".",
"gc",
".",
"SetStrokeColor",
"(",
"rr",
".",
"s",
".",
"StrokeColor",
")"... | // FillStroke implements the interface method. | [
"FillStroke",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L116-L122 |
25,495 | wcharczuk/go-chart | raster_renderer.go | Circle | func (rr *rasterRenderer) Circle(radius float64, x, y int) {
xf := float64(x)
yf := float64(y)
rr.gc.MoveTo(xf-radius, yf) //9
rr.gc.QuadCurveTo(xf-radius, yf-radius, xf, yf-radius) //12
rr.gc.QuadCurveTo(xf+radius, yf-radius, xf+radius, yf) //3
rr.gc.QuadCurveTo(xf+radius, yf+radius, ... | go | func (rr *rasterRenderer) Circle(radius float64, x, y int) {
xf := float64(x)
yf := float64(y)
rr.gc.MoveTo(xf-radius, yf) //9
rr.gc.QuadCurveTo(xf-radius, yf-radius, xf, yf-radius) //12
rr.gc.QuadCurveTo(xf+radius, yf-radius, xf+radius, yf) //3
rr.gc.QuadCurveTo(xf+radius, yf+radius, ... | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"Circle",
"(",
"radius",
"float64",
",",
"x",
",",
"y",
"int",
")",
"{",
"xf",
":=",
"float64",
"(",
"x",
")",
"\n",
"yf",
":=",
"float64",
"(",
"y",
")",
"\n\n",
"rr",
".",
"gc",
".",
"MoveTo",
"(... | // Circle fully draws a circle at a given point but does not apply the fill or stroke. | [
"Circle",
"fully",
"draws",
"a",
"circle",
"at",
"a",
"given",
"point",
"but",
"does",
"not",
"apply",
"the",
"fill",
"or",
"stroke",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L125-L134 |
25,496 | wcharczuk/go-chart | raster_renderer.go | Text | func (rr *rasterRenderer) Text(body string, x, y int) {
xf, yf := rr.getCoords(x, y)
rr.gc.SetFont(rr.s.Font)
rr.gc.SetFontSize(rr.s.FontSize)
rr.gc.SetFillColor(rr.s.FontColor)
rr.gc.CreateStringPath(body, float64(xf), float64(yf))
rr.gc.Fill()
} | go | func (rr *rasterRenderer) Text(body string, x, y int) {
xf, yf := rr.getCoords(x, y)
rr.gc.SetFont(rr.s.Font)
rr.gc.SetFontSize(rr.s.FontSize)
rr.gc.SetFillColor(rr.s.FontColor)
rr.gc.CreateStringPath(body, float64(xf), float64(yf))
rr.gc.Fill()
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"Text",
"(",
"body",
"string",
",",
"x",
",",
"y",
"int",
")",
"{",
"xf",
",",
"yf",
":=",
"rr",
".",
"getCoords",
"(",
"x",
",",
"y",
")",
"\n",
"rr",
".",
"gc",
".",
"SetFont",
"(",
"rr",
".",
... | // Text implements the interface method. | [
"Text",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L152-L159 |
25,497 | wcharczuk/go-chart | raster_renderer.go | MeasureText | func (rr *rasterRenderer) MeasureText(body string) Box {
rr.gc.SetFont(rr.s.Font)
rr.gc.SetFontSize(rr.s.FontSize)
rr.gc.SetFillColor(rr.s.FontColor)
l, t, r, b, err := rr.gc.GetStringBounds(body)
if err != nil {
return Box{}
}
if l < 0 {
r = r - l // equivalent to r+(-1*l)
l = 0
}
if t < 0 {
b = b - t... | go | func (rr *rasterRenderer) MeasureText(body string) Box {
rr.gc.SetFont(rr.s.Font)
rr.gc.SetFontSize(rr.s.FontSize)
rr.gc.SetFillColor(rr.s.FontColor)
l, t, r, b, err := rr.gc.GetStringBounds(body)
if err != nil {
return Box{}
}
if l < 0 {
r = r - l // equivalent to r+(-1*l)
l = 0
}
if t < 0 {
b = b - t... | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"MeasureText",
"(",
"body",
"string",
")",
"Box",
"{",
"rr",
".",
"gc",
".",
"SetFont",
"(",
"rr",
".",
"s",
".",
"Font",
")",
"\n",
"rr",
".",
"gc",
".",
"SetFontSize",
"(",
"rr",
".",
"s",
".",
"... | // MeasureText returns the height and width in pixels of a string. | [
"MeasureText",
"returns",
"the",
"height",
"and",
"width",
"in",
"pixels",
"of",
"a",
"string",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L162-L200 |
25,498 | wcharczuk/go-chart | raster_renderer.go | ClearTextRotation | func (rr *rasterRenderer) ClearTextRotation() {
rr.gc.SetMatrixTransform(drawing.NewIdentityMatrix())
rr.rotateRadians = nil
} | go | func (rr *rasterRenderer) ClearTextRotation() {
rr.gc.SetMatrixTransform(drawing.NewIdentityMatrix())
rr.rotateRadians = nil
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"ClearTextRotation",
"(",
")",
"{",
"rr",
".",
"gc",
".",
"SetMatrixTransform",
"(",
"drawing",
".",
"NewIdentityMatrix",
"(",
")",
")",
"\n",
"rr",
".",
"rotateRadians",
"=",
"nil",
"\n",
"}"
] | // ClearTextRotation clears text rotation. | [
"ClearTextRotation",
"clears",
"text",
"rotation",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L220-L223 |
25,499 | wcharczuk/go-chart | raster_renderer.go | Save | func (rr *rasterRenderer) Save(w io.Writer) error {
if typed, isTyped := w.(RGBACollector); isTyped {
typed.SetRGBA(rr.i)
return nil
}
return png.Encode(w, rr.i)
} | go | func (rr *rasterRenderer) Save(w io.Writer) error {
if typed, isTyped := w.(RGBACollector); isTyped {
typed.SetRGBA(rr.i)
return nil
}
return png.Encode(w, rr.i)
} | [
"func",
"(",
"rr",
"*",
"rasterRenderer",
")",
"Save",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"if",
"typed",
",",
"isTyped",
":=",
"w",
".",
"(",
"RGBACollector",
")",
";",
"isTyped",
"{",
"typed",
".",
"SetRGBA",
"(",
"rr",
".",
"i",
... | // Save implements the interface method. | [
"Save",
"implements",
"the",
"interface",
"method",
"."
] | 9852fce5a172598e72d16f4306f0f17a53d94eb4 | https://github.com/wcharczuk/go-chart/blob/9852fce5a172598e72d16f4306f0f17a53d94eb4/raster_renderer.go#L226-L232 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.