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
sequence | docstring
stringlengths 6
2.61k
| docstring_tokens
sequence | sha
stringlengths 40
40
| url
stringlengths 85
252
| partition
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|
mailru/easyjson | jlexer/lexer.go | consume | func (r *Lexer) consume() {
r.token.kind = tokenUndef
r.token.delimValue = 0
} | go | func (r *Lexer) consume() {
r.token.kind = tokenUndef
r.token.delimValue = 0
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"consume",
"(",
")",
"{",
"r",
".",
"token",
".",
"kind",
"=",
"tokenUndef",
"\n",
"r",
".",
"token",
".",
"delimValue",
"=",
"0",
"\n",
"}"
] | // consume resets the current token to allow scanning the next one. | [
"consume",
"resets",
"the",
"current",
"token",
"to",
"allow",
"scanning",
"the",
"next",
"one",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L394-L397 | train |
mailru/easyjson | jlexer/lexer.go | Delim | func (r *Lexer) Delim(c byte) {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.delimValue != c {
r.consume() // errInvalidToken can change token if UseMultipleErrors is enabled.
r.errInvalidToken(string([]byte{c}))
} else {
r.consume()
}
} | go | func (r *Lexer) Delim(c byte) {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.delimValue != c {
r.consume() // errInvalidToken can change token if UseMultipleErrors is enabled.
r.errInvalidToken(string([]byte{c}))
} else {
r.consume()
}
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Delim",
"(",
"c",
"byte",
")",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"delimValue",
"!=",
"c",
"{",
"r",
".",
"consume",
"(",
")",
"// errInvalidToken can change token if UseMultipleErrors is enabled.",
"\n",
"r",
".",
"errInvalidToken",
"(",
"string",
"(",
"[",
"]",
"byte",
"{",
"c",
"}",
")",
")",
"\n",
"}",
"else",
"{",
"r",
".",
"consume",
"(",
")",
"\n",
"}",
"\n",
"}"
] | // Delim consumes a token and verifies that it is the given delimiter. | [
"Delim",
"consumes",
"a",
"token",
"and",
"verifies",
"that",
"it",
"is",
"the",
"given",
"delimiter",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L468-L479 | train |
mailru/easyjson | jlexer/lexer.go | IsDelim | func (r *Lexer) IsDelim(c byte) bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
return !r.Ok() || r.token.delimValue == c
} | go | func (r *Lexer) IsDelim(c byte) bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
return !r.Ok() || r.token.delimValue == c
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"IsDelim",
"(",
"c",
"byte",
")",
"bool",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"return",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"delimValue",
"==",
"c",
"\n",
"}"
] | // IsDelim returns true if there was no scanning error and next token is the given delimiter. | [
"IsDelim",
"returns",
"true",
"if",
"there",
"was",
"no",
"scanning",
"error",
"and",
"next",
"token",
"is",
"the",
"given",
"delimiter",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L482-L487 | train |
mailru/easyjson | jlexer/lexer.go | Null | func (r *Lexer) Null() {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenNull {
r.errInvalidToken("null")
}
r.consume()
} | go | func (r *Lexer) Null() {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenNull {
r.errInvalidToken("null")
}
r.consume()
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Null",
"(",
")",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"kind",
"!=",
"tokenNull",
"{",
"r",
".",
"errInvalidToken",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"r",
".",
"consume",
"(",
")",
"\n",
"}"
] | // Null verifies that the next token is null and consumes it. | [
"Null",
"verifies",
"that",
"the",
"next",
"token",
"is",
"null",
"and",
"consumes",
"it",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L490-L498 | train |
mailru/easyjson | jlexer/lexer.go | IsNull | func (r *Lexer) IsNull() bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
return r.Ok() && r.token.kind == tokenNull
} | go | func (r *Lexer) IsNull() bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
return r.Ok() && r.token.kind == tokenNull
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"IsNull",
"(",
")",
"bool",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"return",
"r",
".",
"Ok",
"(",
")",
"&&",
"r",
".",
"token",
".",
"kind",
"==",
"tokenNull",
"\n",
"}"
] | // IsNull returns true if the next token is a null keyword. | [
"IsNull",
"returns",
"true",
"if",
"the",
"next",
"token",
"is",
"a",
"null",
"keyword",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L501-L506 | train |
mailru/easyjson | jlexer/lexer.go | Skip | func (r *Lexer) Skip() {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
r.consume()
} | go | func (r *Lexer) Skip() {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
r.consume()
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Skip",
"(",
")",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"r",
".",
"consume",
"(",
")",
"\n",
"}"
] | // Skip skips a single token. | [
"Skip",
"skips",
"a",
"single",
"token",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L509-L514 | train |
mailru/easyjson | jlexer/lexer.go | Raw | func (r *Lexer) Raw() []byte {
r.SkipRecursive()
if !r.Ok() {
return nil
}
return r.Data[r.start:r.pos]
} | go | func (r *Lexer) Raw() []byte {
r.SkipRecursive()
if !r.Ok() {
return nil
}
return r.Data[r.start:r.pos]
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Raw",
"(",
")",
"[",
"]",
"byte",
"{",
"r",
".",
"SkipRecursive",
"(",
")",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"r",
".",
"Data",
"[",
"r",
".",
"start",
":",
"r",
".",
"pos",
"]",
"\n",
"}"
] | // Raw fetches the next item recursively as a data slice | [
"Raw",
"fetches",
"the",
"next",
"item",
"recursively",
"as",
"a",
"data",
"slice"
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L569-L575 | train |
mailru/easyjson | jlexer/lexer.go | Consumed | func (r *Lexer) Consumed() {
if r.pos > len(r.Data) || !r.Ok() {
return
}
for _, c := range r.Data[r.pos:] {
if c != ' ' && c != '\t' && c != '\r' && c != '\n' {
r.AddError(&LexerError{
Reason: "invalid character '" + string(c) + "' after top-level value",
Offset: r.pos,
Data: string(r.Data[r.pos:]),
})
return
}
r.pos++
r.start++
}
} | go | func (r *Lexer) Consumed() {
if r.pos > len(r.Data) || !r.Ok() {
return
}
for _, c := range r.Data[r.pos:] {
if c != ' ' && c != '\t' && c != '\r' && c != '\n' {
r.AddError(&LexerError{
Reason: "invalid character '" + string(c) + "' after top-level value",
Offset: r.pos,
Data: string(r.Data[r.pos:]),
})
return
}
r.pos++
r.start++
}
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Consumed",
"(",
")",
"{",
"if",
"r",
".",
"pos",
">",
"len",
"(",
"r",
".",
"Data",
")",
"||",
"!",
"r",
".",
"Ok",
"(",
")",
"{",
"return",
"\n",
"}",
"\n\n",
"for",
"_",
",",
"c",
":=",
"range",
"r",
".",
"Data",
"[",
"r",
".",
"pos",
":",
"]",
"{",
"if",
"c",
"!=",
"' '",
"&&",
"c",
"!=",
"'\\t'",
"&&",
"c",
"!=",
"'\\r'",
"&&",
"c",
"!=",
"'\\n'",
"{",
"r",
".",
"AddError",
"(",
"&",
"LexerError",
"{",
"Reason",
":",
"\"",
"\"",
"+",
"string",
"(",
"c",
")",
"+",
"\"",
"\"",
",",
"Offset",
":",
"r",
".",
"pos",
",",
"Data",
":",
"string",
"(",
"r",
".",
"Data",
"[",
"r",
".",
"pos",
":",
"]",
")",
",",
"}",
")",
"\n",
"return",
"\n",
"}",
"\n\n",
"r",
".",
"pos",
"++",
"\n",
"r",
".",
"start",
"++",
"\n",
"}",
"\n",
"}"
] | // Consumed reads all remaining bytes from the input, publishing an error if
// there is anything but whitespace remaining. | [
"Consumed",
"reads",
"all",
"remaining",
"bytes",
"from",
"the",
"input",
"publishing",
"an",
"error",
"if",
"there",
"is",
"anything",
"but",
"whitespace",
"remaining",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L585-L603 | train |
mailru/easyjson | jlexer/lexer.go | String | func (r *Lexer) String() string {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenString {
r.errInvalidToken("string")
return ""
}
ret := string(r.token.byteValue)
r.consume()
return ret
} | go | func (r *Lexer) String() string {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenString {
r.errInvalidToken("string")
return ""
}
ret := string(r.token.byteValue)
r.consume()
return ret
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"String",
"(",
")",
"string",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"kind",
"!=",
"tokenString",
"{",
"r",
".",
"errInvalidToken",
"(",
"\"",
"\"",
")",
"\n",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"ret",
":=",
"string",
"(",
"r",
".",
"token",
".",
"byteValue",
")",
"\n",
"r",
".",
"consume",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // String reads a string literal. | [
"String",
"reads",
"a",
"string",
"literal",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L635-L646 | train |
mailru/easyjson | jlexer/lexer.go | Bytes | func (r *Lexer) Bytes() []byte {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenString {
r.errInvalidToken("string")
return nil
}
ret := make([]byte, base64.StdEncoding.DecodedLen(len(r.token.byteValue)))
n, err := base64.StdEncoding.Decode(ret, r.token.byteValue)
if err != nil {
r.fatalError = &LexerError{
Reason: err.Error(),
}
return nil
}
r.consume()
return ret[:n]
} | go | func (r *Lexer) Bytes() []byte {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenString {
r.errInvalidToken("string")
return nil
}
ret := make([]byte, base64.StdEncoding.DecodedLen(len(r.token.byteValue)))
n, err := base64.StdEncoding.Decode(ret, r.token.byteValue)
if err != nil {
r.fatalError = &LexerError{
Reason: err.Error(),
}
return nil
}
r.consume()
return ret[:n]
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Bytes",
"(",
")",
"[",
"]",
"byte",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"kind",
"!=",
"tokenString",
"{",
"r",
".",
"errInvalidToken",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
"\n",
"}",
"\n",
"ret",
":=",
"make",
"(",
"[",
"]",
"byte",
",",
"base64",
".",
"StdEncoding",
".",
"DecodedLen",
"(",
"len",
"(",
"r",
".",
"token",
".",
"byteValue",
")",
")",
")",
"\n",
"n",
",",
"err",
":=",
"base64",
".",
"StdEncoding",
".",
"Decode",
"(",
"ret",
",",
"r",
".",
"token",
".",
"byteValue",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"r",
".",
"fatalError",
"=",
"&",
"LexerError",
"{",
"Reason",
":",
"err",
".",
"Error",
"(",
")",
",",
"}",
"\n",
"return",
"nil",
"\n",
"}",
"\n\n",
"r",
".",
"consume",
"(",
")",
"\n",
"return",
"ret",
"[",
":",
"n",
"]",
"\n",
"}"
] | // Bytes reads a string literal and base64 decodes it into a byte slice. | [
"Bytes",
"reads",
"a",
"string",
"literal",
"and",
"base64",
"decodes",
"it",
"into",
"a",
"byte",
"slice",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L649-L668 | train |
mailru/easyjson | jlexer/lexer.go | Bool | func (r *Lexer) Bool() bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenBool {
r.errInvalidToken("bool")
return false
}
ret := r.token.boolValue
r.consume()
return ret
} | go | func (r *Lexer) Bool() bool {
if r.token.kind == tokenUndef && r.Ok() {
r.FetchToken()
}
if !r.Ok() || r.token.kind != tokenBool {
r.errInvalidToken("bool")
return false
}
ret := r.token.boolValue
r.consume()
return ret
} | [
"func",
"(",
"r",
"*",
"Lexer",
")",
"Bool",
"(",
")",
"bool",
"{",
"if",
"r",
".",
"token",
".",
"kind",
"==",
"tokenUndef",
"&&",
"r",
".",
"Ok",
"(",
")",
"{",
"r",
".",
"FetchToken",
"(",
")",
"\n",
"}",
"\n",
"if",
"!",
"r",
".",
"Ok",
"(",
")",
"||",
"r",
".",
"token",
".",
"kind",
"!=",
"tokenBool",
"{",
"r",
".",
"errInvalidToken",
"(",
"\"",
"\"",
")",
"\n",
"return",
"false",
"\n",
"}",
"\n",
"ret",
":=",
"r",
".",
"token",
".",
"boolValue",
"\n",
"r",
".",
"consume",
"(",
")",
"\n",
"return",
"ret",
"\n",
"}"
] | // Bool reads a true or false boolean keyword. | [
"Bool",
"reads",
"a",
"true",
"or",
"false",
"boolean",
"keyword",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/jlexer/lexer.go#L671-L682 | train |
mailru/easyjson | helpers.go | Marshal | func Marshal(v Marshaler) ([]byte, error) {
w := jwriter.Writer{}
v.MarshalEasyJSON(&w)
return w.BuildBytes()
} | go | func Marshal(v Marshaler) ([]byte, error) {
w := jwriter.Writer{}
v.MarshalEasyJSON(&w)
return w.BuildBytes()
} | [
"func",
"Marshal",
"(",
"v",
"Marshaler",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"w",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"v",
".",
"MarshalEasyJSON",
"(",
"&",
"w",
")",
"\n",
"return",
"w",
".",
"BuildBytes",
"(",
")",
"\n",
"}"
] | // Marshal returns data as a single byte slice. Method is suboptimal as the data is likely to be copied
// from a chain of smaller chunks. | [
"Marshal",
"returns",
"data",
"as",
"a",
"single",
"byte",
"slice",
".",
"Method",
"is",
"suboptimal",
"as",
"the",
"data",
"is",
"likely",
"to",
"be",
"copied",
"from",
"a",
"chain",
"of",
"smaller",
"chunks",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L31-L35 | train |
mailru/easyjson | helpers.go | MarshalToWriter | func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) {
jw := jwriter.Writer{}
v.MarshalEasyJSON(&jw)
return jw.DumpTo(w)
} | go | func MarshalToWriter(v Marshaler, w io.Writer) (written int, err error) {
jw := jwriter.Writer{}
v.MarshalEasyJSON(&jw)
return jw.DumpTo(w)
} | [
"func",
"MarshalToWriter",
"(",
"v",
"Marshaler",
",",
"w",
"io",
".",
"Writer",
")",
"(",
"written",
"int",
",",
"err",
"error",
")",
"{",
"jw",
":=",
"jwriter",
".",
"Writer",
"{",
"}",
"\n",
"v",
".",
"MarshalEasyJSON",
"(",
"&",
"jw",
")",
"\n",
"return",
"jw",
".",
"DumpTo",
"(",
"w",
")",
"\n",
"}"
] | // MarshalToWriter marshals the data to an io.Writer. | [
"MarshalToWriter",
"marshals",
"the",
"data",
"to",
"an",
"io",
".",
"Writer",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L38-L42 | train |
mailru/easyjson | helpers.go | Unmarshal | func Unmarshal(data []byte, v Unmarshaler) error {
l := jlexer.Lexer{Data: data}
v.UnmarshalEasyJSON(&l)
return l.Error()
} | go | func Unmarshal(data []byte, v Unmarshaler) error {
l := jlexer.Lexer{Data: data}
v.UnmarshalEasyJSON(&l)
return l.Error()
} | [
"func",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"Unmarshaler",
")",
"error",
"{",
"l",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"v",
".",
"UnmarshalEasyJSON",
"(",
"&",
"l",
")",
"\n",
"return",
"l",
".",
"Error",
"(",
")",
"\n",
"}"
] | // Unmarshal decodes the JSON in data into the object. | [
"Unmarshal",
"decodes",
"the",
"JSON",
"in",
"data",
"into",
"the",
"object",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L63-L67 | train |
mailru/easyjson | helpers.go | UnmarshalFromReader | func UnmarshalFromReader(r io.Reader, v Unmarshaler) error {
data, err := ioutil.ReadAll(r)
if err != nil {
return err
}
l := jlexer.Lexer{Data: data}
v.UnmarshalEasyJSON(&l)
return l.Error()
} | go | func UnmarshalFromReader(r io.Reader, v Unmarshaler) error {
data, err := ioutil.ReadAll(r)
if err != nil {
return err
}
l := jlexer.Lexer{Data: data}
v.UnmarshalEasyJSON(&l)
return l.Error()
} | [
"func",
"UnmarshalFromReader",
"(",
"r",
"io",
".",
"Reader",
",",
"v",
"Unmarshaler",
")",
"error",
"{",
"data",
",",
"err",
":=",
"ioutil",
".",
"ReadAll",
"(",
"r",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n",
"l",
":=",
"jlexer",
".",
"Lexer",
"{",
"Data",
":",
"data",
"}",
"\n",
"v",
".",
"UnmarshalEasyJSON",
"(",
"&",
"l",
")",
"\n",
"return",
"l",
".",
"Error",
"(",
")",
"\n",
"}"
] | // UnmarshalFromReader reads all the data in the reader and decodes as JSON into the object. | [
"UnmarshalFromReader",
"reads",
"all",
"the",
"data",
"in",
"the",
"reader",
"and",
"decodes",
"as",
"JSON",
"into",
"the",
"object",
"."
] | 1ea4449da9834f4d333f1cc461c374aea217d249 | https://github.com/mailru/easyjson/blob/1ea4449da9834f4d333f1cc461c374aea217d249/helpers.go#L70-L78 | train |
fogleman/gg | gradient.go | Less | func (s stops) Less(i, j int) bool {
return s[i].pos < s[j].pos
} | go | func (s stops) Less(i, j int) bool {
return s[i].pos < s[j].pos
} | [
"func",
"(",
"s",
"stops",
")",
"Less",
"(",
"i",
",",
"j",
"int",
")",
"bool",
"{",
"return",
"s",
"[",
"i",
"]",
".",
"pos",
"<",
"s",
"[",
"j",
"]",
".",
"pos",
"\n",
"}"
] | // Less satisfies the Sort interface. | [
"Less",
"satisfies",
"the",
"Sort",
"interface",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/gradient.go#L22-L24 | train |
fogleman/gg | gradient.go | Swap | func (s stops) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | go | func (s stops) Swap(i, j int) {
s[i], s[j] = s[j], s[i]
} | [
"func",
"(",
"s",
"stops",
")",
"Swap",
"(",
"i",
",",
"j",
"int",
")",
"{",
"s",
"[",
"i",
"]",
",",
"s",
"[",
"j",
"]",
"=",
"s",
"[",
"j",
"]",
",",
"s",
"[",
"i",
"]",
"\n",
"}"
] | // Swap satisfies the Sort interface. | [
"Swap",
"satisfies",
"the",
"Sort",
"interface",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/gradient.go#L27-L29 | train |
fogleman/gg | util.go | LoadFontFace | func LoadFontFace(path string, points float64) (font.Face, error) {
fontBytes, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
f, err := truetype.Parse(fontBytes)
if err != nil {
return nil, err
}
face := truetype.NewFace(f, &truetype.Options{
Size: points,
// Hinting: font.HintingFull,
})
return face, nil
} | go | func LoadFontFace(path string, points float64) (font.Face, error) {
fontBytes, err := ioutil.ReadFile(path)
if err != nil {
return nil, err
}
f, err := truetype.Parse(fontBytes)
if err != nil {
return nil, err
}
face := truetype.NewFace(f, &truetype.Options{
Size: points,
// Hinting: font.HintingFull,
})
return face, nil
} | [
"func",
"LoadFontFace",
"(",
"path",
"string",
",",
"points",
"float64",
")",
"(",
"font",
".",
"Face",
",",
"error",
")",
"{",
"fontBytes",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"path",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"f",
",",
"err",
":=",
"truetype",
".",
"Parse",
"(",
"fontBytes",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"nil",
",",
"err",
"\n",
"}",
"\n",
"face",
":=",
"truetype",
".",
"NewFace",
"(",
"f",
",",
"&",
"truetype",
".",
"Options",
"{",
"Size",
":",
"points",
",",
"// Hinting: font.HintingFull,",
"}",
")",
"\n",
"return",
"face",
",",
"nil",
"\n",
"}"
] | // LoadFontFace is a helper function to load the specified font file with
// the specified point size. Note that the returned `font.Face` objects
// are not thread safe and cannot be used in parallel across goroutines.
// You can usually just use the Context.LoadFontFace function instead of
// this package-level function. | [
"LoadFontFace",
"is",
"a",
"helper",
"function",
"to",
"load",
"the",
"specified",
"font",
"file",
"with",
"the",
"specified",
"point",
"size",
".",
"Note",
"that",
"the",
"returned",
"font",
".",
"Face",
"objects",
"are",
"not",
"thread",
"safe",
"and",
"cannot",
"be",
"used",
"in",
"parallel",
"across",
"goroutines",
".",
"You",
"can",
"usually",
"just",
"use",
"the",
"Context",
".",
"LoadFontFace",
"function",
"instead",
"of",
"this",
"package",
"-",
"level",
"function",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/util.go#L132-L146 | train |
fogleman/gg | context.go | NewContext | func NewContext(width, height int) *Context {
return NewContextForRGBA(image.NewRGBA(image.Rect(0, 0, width, height)))
} | go | func NewContext(width, height int) *Context {
return NewContextForRGBA(image.NewRGBA(image.Rect(0, 0, width, height)))
} | [
"func",
"NewContext",
"(",
"width",
",",
"height",
"int",
")",
"*",
"Context",
"{",
"return",
"NewContextForRGBA",
"(",
"image",
".",
"NewRGBA",
"(",
"image",
".",
"Rect",
"(",
"0",
",",
"0",
",",
"width",
",",
"height",
")",
")",
")",
"\n",
"}"
] | // NewContext creates a new image.RGBA with the specified width and height
// and prepares a context for rendering onto that image. | [
"NewContext",
"creates",
"a",
"new",
"image",
".",
"RGBA",
"with",
"the",
"specified",
"width",
"and",
"height",
"and",
"prepares",
"a",
"context",
"for",
"rendering",
"onto",
"that",
"image",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L83-L85 | train |
fogleman/gg | context.go | NewContextForRGBA | func NewContextForRGBA(im *image.RGBA) *Context {
w := im.Bounds().Size().X
h := im.Bounds().Size().Y
return &Context{
width: w,
height: h,
rasterizer: raster.NewRasterizer(w, h),
im: im,
color: color.Transparent,
fillPattern: defaultFillStyle,
strokePattern: defaultStrokeStyle,
lineWidth: 1,
fillRule: FillRuleWinding,
fontFace: basicfont.Face7x13,
fontHeight: 13,
matrix: Identity(),
}
} | go | func NewContextForRGBA(im *image.RGBA) *Context {
w := im.Bounds().Size().X
h := im.Bounds().Size().Y
return &Context{
width: w,
height: h,
rasterizer: raster.NewRasterizer(w, h),
im: im,
color: color.Transparent,
fillPattern: defaultFillStyle,
strokePattern: defaultStrokeStyle,
lineWidth: 1,
fillRule: FillRuleWinding,
fontFace: basicfont.Face7x13,
fontHeight: 13,
matrix: Identity(),
}
} | [
"func",
"NewContextForRGBA",
"(",
"im",
"*",
"image",
".",
"RGBA",
")",
"*",
"Context",
"{",
"w",
":=",
"im",
".",
"Bounds",
"(",
")",
".",
"Size",
"(",
")",
".",
"X",
"\n",
"h",
":=",
"im",
".",
"Bounds",
"(",
")",
".",
"Size",
"(",
")",
".",
"Y",
"\n",
"return",
"&",
"Context",
"{",
"width",
":",
"w",
",",
"height",
":",
"h",
",",
"rasterizer",
":",
"raster",
".",
"NewRasterizer",
"(",
"w",
",",
"h",
")",
",",
"im",
":",
"im",
",",
"color",
":",
"color",
".",
"Transparent",
",",
"fillPattern",
":",
"defaultFillStyle",
",",
"strokePattern",
":",
"defaultStrokeStyle",
",",
"lineWidth",
":",
"1",
",",
"fillRule",
":",
"FillRuleWinding",
",",
"fontFace",
":",
"basicfont",
".",
"Face7x13",
",",
"fontHeight",
":",
"13",
",",
"matrix",
":",
"Identity",
"(",
")",
",",
"}",
"\n",
"}"
] | // NewContextForRGBA prepares a context for rendering onto the specified image.
// No copy is made. | [
"NewContextForRGBA",
"prepares",
"a",
"context",
"for",
"rendering",
"onto",
"the",
"specified",
"image",
".",
"No",
"copy",
"is",
"made",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L95-L112 | train |
fogleman/gg | context.go | GetCurrentPoint | func (dc *Context) GetCurrentPoint() (Point, bool) {
if dc.hasCurrent {
return dc.current, true
}
return Point{}, false
} | go | func (dc *Context) GetCurrentPoint() (Point, bool) {
if dc.hasCurrent {
return dc.current, true
}
return Point{}, false
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"GetCurrentPoint",
"(",
")",
"(",
"Point",
",",
"bool",
")",
"{",
"if",
"dc",
".",
"hasCurrent",
"{",
"return",
"dc",
".",
"current",
",",
"true",
"\n",
"}",
"\n",
"return",
"Point",
"{",
"}",
",",
"false",
"\n",
"}"
] | // GetCurrentPoint will return the current point and if there is a current point.
// The point will have been transformed by the context's transformation matrix. | [
"GetCurrentPoint",
"will",
"return",
"the",
"current",
"point",
"and",
"if",
"there",
"is",
"a",
"current",
"point",
".",
"The",
"point",
"will",
"have",
"been",
"transformed",
"by",
"the",
"context",
"s",
"transformation",
"matrix",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L116-L121 | train |
fogleman/gg | context.go | SavePNG | func (dc *Context) SavePNG(path string) error {
return SavePNG(path, dc.im)
} | go | func (dc *Context) SavePNG(path string) error {
return SavePNG(path, dc.im)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SavePNG",
"(",
"path",
"string",
")",
"error",
"{",
"return",
"SavePNG",
"(",
"path",
",",
"dc",
".",
"im",
")",
"\n",
"}"
] | // SavePNG encodes the image as a PNG and writes it to disk. | [
"SavePNG",
"encodes",
"the",
"image",
"as",
"a",
"PNG",
"and",
"writes",
"it",
"to",
"disk",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L139-L141 | train |
fogleman/gg | context.go | SaveJPG | func (dc *Context) SaveJPG(path string, quality int) error {
return SaveJPG(path, dc.im, quality)
} | go | func (dc *Context) SaveJPG(path string, quality int) error {
return SaveJPG(path, dc.im, quality)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SaveJPG",
"(",
"path",
"string",
",",
"quality",
"int",
")",
"error",
"{",
"return",
"SaveJPG",
"(",
"path",
",",
"dc",
".",
"im",
",",
"quality",
")",
"\n",
"}"
] | // SaveJPG encodes the image as a JPG and writes it to disk. | [
"SaveJPG",
"encodes",
"the",
"image",
"as",
"a",
"JPG",
"and",
"writes",
"it",
"to",
"disk",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L144-L146 | train |
fogleman/gg | context.go | EncodePNG | func (dc *Context) EncodePNG(w io.Writer) error {
return png.Encode(w, dc.im)
} | go | func (dc *Context) EncodePNG(w io.Writer) error {
return png.Encode(w, dc.im)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"EncodePNG",
"(",
"w",
"io",
".",
"Writer",
")",
"error",
"{",
"return",
"png",
".",
"Encode",
"(",
"w",
",",
"dc",
".",
"im",
")",
"\n",
"}"
] | // EncodePNG encodes the image as a PNG and writes it to the provided io.Writer. | [
"EncodePNG",
"encodes",
"the",
"image",
"as",
"a",
"PNG",
"and",
"writes",
"it",
"to",
"the",
"provided",
"io",
".",
"Writer",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L149-L151 | train |
fogleman/gg | context.go | SetFillStyle | func (dc *Context) SetFillStyle(pattern Pattern) {
// if pattern is SolidPattern, also change dc.color(for dc.Clear, dc.drawString)
if fillStyle, ok := pattern.(*solidPattern); ok {
dc.color = fillStyle.color
}
dc.fillPattern = pattern
} | go | func (dc *Context) SetFillStyle(pattern Pattern) {
// if pattern is SolidPattern, also change dc.color(for dc.Clear, dc.drawString)
if fillStyle, ok := pattern.(*solidPattern); ok {
dc.color = fillStyle.color
}
dc.fillPattern = pattern
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SetFillStyle",
"(",
"pattern",
"Pattern",
")",
"{",
"// if pattern is SolidPattern, also change dc.color(for dc.Clear, dc.drawString)",
"if",
"fillStyle",
",",
"ok",
":=",
"pattern",
".",
"(",
"*",
"solidPattern",
")",
";",
"ok",
"{",
"dc",
".",
"color",
"=",
"fillStyle",
".",
"color",
"\n",
"}",
"\n",
"dc",
".",
"fillPattern",
"=",
"pattern",
"\n",
"}"
] | // SetFillStyle sets current fill style | [
"SetFillStyle",
"sets",
"current",
"fill",
"style"
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L219-L225 | train |
fogleman/gg | context.go | SetRGBA255 | func (dc *Context) SetRGBA255(r, g, b, a int) {
dc.color = color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)}
dc.setFillAndStrokeColor(dc.color)
} | go | func (dc *Context) SetRGBA255(r, g, b, a int) {
dc.color = color.NRGBA{uint8(r), uint8(g), uint8(b), uint8(a)}
dc.setFillAndStrokeColor(dc.color)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SetRGBA255",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"int",
")",
"{",
"dc",
".",
"color",
"=",
"color",
".",
"NRGBA",
"{",
"uint8",
"(",
"r",
")",
",",
"uint8",
"(",
"g",
")",
",",
"uint8",
"(",
"b",
")",
",",
"uint8",
"(",
"a",
")",
"}",
"\n",
"dc",
".",
"setFillAndStrokeColor",
"(",
"dc",
".",
"color",
")",
"\n",
"}"
] | // SetRGBA255 sets the current color. r, g, b, a values should be between 0 and
// 255, inclusive. | [
"SetRGBA255",
"sets",
"the",
"current",
"color",
".",
"r",
"g",
"b",
"a",
"values",
"should",
"be",
"between",
"0",
"and",
"255",
"inclusive",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L247-L250 | train |
fogleman/gg | context.go | SetRGBA | func (dc *Context) SetRGBA(r, g, b, a float64) {
dc.color = color.NRGBA{
uint8(r * 255),
uint8(g * 255),
uint8(b * 255),
uint8(a * 255),
}
dc.setFillAndStrokeColor(dc.color)
} | go | func (dc *Context) SetRGBA(r, g, b, a float64) {
dc.color = color.NRGBA{
uint8(r * 255),
uint8(g * 255),
uint8(b * 255),
uint8(a * 255),
}
dc.setFillAndStrokeColor(dc.color)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SetRGBA",
"(",
"r",
",",
"g",
",",
"b",
",",
"a",
"float64",
")",
"{",
"dc",
".",
"color",
"=",
"color",
".",
"NRGBA",
"{",
"uint8",
"(",
"r",
"*",
"255",
")",
",",
"uint8",
"(",
"g",
"*",
"255",
")",
",",
"uint8",
"(",
"b",
"*",
"255",
")",
",",
"uint8",
"(",
"a",
"*",
"255",
")",
",",
"}",
"\n",
"dc",
".",
"setFillAndStrokeColor",
"(",
"dc",
".",
"color",
")",
"\n",
"}"
] | // SetRGBA sets the current color. r, g, b, a values should be between 0 and 1,
// inclusive. | [
"SetRGBA",
"sets",
"the",
"current",
"color",
".",
"r",
"g",
"b",
"a",
"values",
"should",
"be",
"between",
"0",
"and",
"1",
"inclusive",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L260-L268 | train |
fogleman/gg | context.go | MoveTo | func (dc *Context) MoveTo(x, y float64) {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
x, y = dc.TransformPoint(x, y)
p := Point{x, y}
dc.strokePath.Start(p.Fixed())
dc.fillPath.Start(p.Fixed())
dc.start = p
dc.current = p
dc.hasCurrent = true
} | go | func (dc *Context) MoveTo(x, y float64) {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
x, y = dc.TransformPoint(x, y)
p := Point{x, y}
dc.strokePath.Start(p.Fixed())
dc.fillPath.Start(p.Fixed())
dc.start = p
dc.current = p
dc.hasCurrent = true
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"MoveTo",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"if",
"dc",
".",
"hasCurrent",
"{",
"dc",
".",
"fillPath",
".",
"Add1",
"(",
"dc",
".",
"start",
".",
"Fixed",
"(",
")",
")",
"\n",
"}",
"\n",
"x",
",",
"y",
"=",
"dc",
".",
"TransformPoint",
"(",
"x",
",",
"y",
")",
"\n",
"p",
":=",
"Point",
"{",
"x",
",",
"y",
"}",
"\n",
"dc",
".",
"strokePath",
".",
"Start",
"(",
"p",
".",
"Fixed",
"(",
")",
")",
"\n",
"dc",
".",
"fillPath",
".",
"Start",
"(",
"p",
".",
"Fixed",
"(",
")",
")",
"\n",
"dc",
".",
"start",
"=",
"p",
"\n",
"dc",
".",
"current",
"=",
"p",
"\n",
"dc",
".",
"hasCurrent",
"=",
"true",
"\n",
"}"
] | // Path Manipulation
// MoveTo starts a new subpath within the current path starting at the
// specified point. | [
"Path",
"Manipulation",
"MoveTo",
"starts",
"a",
"new",
"subpath",
"within",
"the",
"current",
"path",
"starting",
"at",
"the",
"specified",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L280-L291 | train |
fogleman/gg | context.go | ClosePath | func (dc *Context) ClosePath() {
if dc.hasCurrent {
dc.strokePath.Add1(dc.start.Fixed())
dc.fillPath.Add1(dc.start.Fixed())
dc.current = dc.start
}
} | go | func (dc *Context) ClosePath() {
if dc.hasCurrent {
dc.strokePath.Add1(dc.start.Fixed())
dc.fillPath.Add1(dc.start.Fixed())
dc.current = dc.start
}
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"ClosePath",
"(",
")",
"{",
"if",
"dc",
".",
"hasCurrent",
"{",
"dc",
".",
"strokePath",
".",
"Add1",
"(",
"dc",
".",
"start",
".",
"Fixed",
"(",
")",
")",
"\n",
"dc",
".",
"fillPath",
".",
"Add1",
"(",
"dc",
".",
"start",
".",
"Fixed",
"(",
")",
")",
"\n",
"dc",
".",
"current",
"=",
"dc",
".",
"start",
"\n",
"}",
"\n",
"}"
] | // ClosePath adds a line segment from the current point to the beginning
// of the current subpath. If there is no current point, this is a no-op. | [
"ClosePath",
"adds",
"a",
"line",
"segment",
"from",
"the",
"current",
"point",
"to",
"the",
"beginning",
"of",
"the",
"current",
"subpath",
".",
"If",
"there",
"is",
"no",
"current",
"point",
"this",
"is",
"a",
"no",
"-",
"op",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L352-L358 | train |
fogleman/gg | context.go | ClearPath | func (dc *Context) ClearPath() {
dc.strokePath.Clear()
dc.fillPath.Clear()
dc.hasCurrent = false
} | go | func (dc *Context) ClearPath() {
dc.strokePath.Clear()
dc.fillPath.Clear()
dc.hasCurrent = false
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"ClearPath",
"(",
")",
"{",
"dc",
".",
"strokePath",
".",
"Clear",
"(",
")",
"\n",
"dc",
".",
"fillPath",
".",
"Clear",
"(",
")",
"\n",
"dc",
".",
"hasCurrent",
"=",
"false",
"\n",
"}"
] | // ClearPath clears the current path. There is no current point after this
// operation. | [
"ClearPath",
"clears",
"the",
"current",
"path",
".",
"There",
"is",
"no",
"current",
"point",
"after",
"this",
"operation",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L362-L366 | train |
fogleman/gg | context.go | NewSubPath | func (dc *Context) NewSubPath() {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
dc.hasCurrent = false
} | go | func (dc *Context) NewSubPath() {
if dc.hasCurrent {
dc.fillPath.Add1(dc.start.Fixed())
}
dc.hasCurrent = false
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"NewSubPath",
"(",
")",
"{",
"if",
"dc",
".",
"hasCurrent",
"{",
"dc",
".",
"fillPath",
".",
"Add1",
"(",
"dc",
".",
"start",
".",
"Fixed",
"(",
")",
")",
"\n",
"}",
"\n",
"dc",
".",
"hasCurrent",
"=",
"false",
"\n",
"}"
] | // NewSubPath starts a new subpath within the current path. There is no current
// point after this operation. | [
"NewSubPath",
"starts",
"a",
"new",
"subpath",
"within",
"the",
"current",
"path",
".",
"There",
"is",
"no",
"current",
"point",
"after",
"this",
"operation",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L370-L375 | train |
fogleman/gg | context.go | StrokePreserve | func (dc *Context) StrokePreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.strokePattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter(dc.im)
p.SetColor(pattern.color)
painter = p
}
}
if painter == nil {
painter = newPatternPainter(dc.im, dc.mask, dc.strokePattern)
}
dc.stroke(painter)
} | go | func (dc *Context) StrokePreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.strokePattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter(dc.im)
p.SetColor(pattern.color)
painter = p
}
}
if painter == nil {
painter = newPatternPainter(dc.im, dc.mask, dc.strokePattern)
}
dc.stroke(painter)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"StrokePreserve",
"(",
")",
"{",
"var",
"painter",
"raster",
".",
"Painter",
"\n",
"if",
"dc",
".",
"mask",
"==",
"nil",
"{",
"if",
"pattern",
",",
"ok",
":=",
"dc",
".",
"strokePattern",
".",
"(",
"*",
"solidPattern",
")",
";",
"ok",
"{",
"// with a nil mask and a solid color pattern, we can be more efficient",
"// TODO: refactor so we don't have to do this type assertion stuff?",
"p",
":=",
"raster",
".",
"NewRGBAPainter",
"(",
"dc",
".",
"im",
")",
"\n",
"p",
".",
"SetColor",
"(",
"pattern",
".",
"color",
")",
"\n",
"painter",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"painter",
"==",
"nil",
"{",
"painter",
"=",
"newPatternPainter",
"(",
"dc",
".",
"im",
",",
"dc",
".",
"mask",
",",
"dc",
".",
"strokePattern",
")",
"\n",
"}",
"\n",
"dc",
".",
"stroke",
"(",
"painter",
")",
"\n",
"}"
] | // StrokePreserve strokes the current path with the current color, line width,
// line cap, line join and dash settings. The path is preserved after this
// operation. | [
"StrokePreserve",
"strokes",
"the",
"current",
"path",
"with",
"the",
"current",
"color",
"line",
"width",
"line",
"cap",
"line",
"join",
"and",
"dash",
"settings",
".",
"The",
"path",
"is",
"preserved",
"after",
"this",
"operation",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L434-L449 | train |
fogleman/gg | context.go | FillPreserve | func (dc *Context) FillPreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.fillPattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter(dc.im)
p.SetColor(pattern.color)
painter = p
}
}
if painter == nil {
painter = newPatternPainter(dc.im, dc.mask, dc.fillPattern)
}
dc.fill(painter)
} | go | func (dc *Context) FillPreserve() {
var painter raster.Painter
if dc.mask == nil {
if pattern, ok := dc.fillPattern.(*solidPattern); ok {
// with a nil mask and a solid color pattern, we can be more efficient
// TODO: refactor so we don't have to do this type assertion stuff?
p := raster.NewRGBAPainter(dc.im)
p.SetColor(pattern.color)
painter = p
}
}
if painter == nil {
painter = newPatternPainter(dc.im, dc.mask, dc.fillPattern)
}
dc.fill(painter)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"FillPreserve",
"(",
")",
"{",
"var",
"painter",
"raster",
".",
"Painter",
"\n",
"if",
"dc",
".",
"mask",
"==",
"nil",
"{",
"if",
"pattern",
",",
"ok",
":=",
"dc",
".",
"fillPattern",
".",
"(",
"*",
"solidPattern",
")",
";",
"ok",
"{",
"// with a nil mask and a solid color pattern, we can be more efficient",
"// TODO: refactor so we don't have to do this type assertion stuff?",
"p",
":=",
"raster",
".",
"NewRGBAPainter",
"(",
"dc",
".",
"im",
")",
"\n",
"p",
".",
"SetColor",
"(",
"pattern",
".",
"color",
")",
"\n",
"painter",
"=",
"p",
"\n",
"}",
"\n",
"}",
"\n",
"if",
"painter",
"==",
"nil",
"{",
"painter",
"=",
"newPatternPainter",
"(",
"dc",
".",
"im",
",",
"dc",
".",
"mask",
",",
"dc",
".",
"fillPattern",
")",
"\n",
"}",
"\n",
"dc",
".",
"fill",
"(",
"painter",
")",
"\n",
"}"
] | // FillPreserve fills the current path with the current color. Open subpaths
// are implicity closed. The path is preserved after this operation. | [
"FillPreserve",
"fills",
"the",
"current",
"path",
"with",
"the",
"current",
"color",
".",
"Open",
"subpaths",
"are",
"implicity",
"closed",
".",
"The",
"path",
"is",
"preserved",
"after",
"this",
"operation",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L461-L476 | train |
fogleman/gg | context.go | InvertMask | func (dc *Context) InvertMask() {
if dc.mask == nil {
dc.mask = image.NewAlpha(dc.im.Bounds())
} else {
for i, a := range dc.mask.Pix {
dc.mask.Pix[i] = 255 - a
}
}
} | go | func (dc *Context) InvertMask() {
if dc.mask == nil {
dc.mask = image.NewAlpha(dc.im.Bounds())
} else {
for i, a := range dc.mask.Pix {
dc.mask.Pix[i] = 255 - a
}
}
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"InvertMask",
"(",
")",
"{",
"if",
"dc",
".",
"mask",
"==",
"nil",
"{",
"dc",
".",
"mask",
"=",
"image",
".",
"NewAlpha",
"(",
"dc",
".",
"im",
".",
"Bounds",
"(",
")",
")",
"\n",
"}",
"else",
"{",
"for",
"i",
",",
"a",
":=",
"range",
"dc",
".",
"mask",
".",
"Pix",
"{",
"dc",
".",
"mask",
".",
"Pix",
"[",
"i",
"]",
"=",
"255",
"-",
"a",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // InvertMask inverts the alpha values in the current clipping mask such that
// a fully transparent region becomes fully opaque and vice versa. | [
"InvertMask",
"inverts",
"the",
"alpha",
"values",
"in",
"the",
"current",
"clipping",
"mask",
"such",
"that",
"a",
"fully",
"transparent",
"region",
"becomes",
"fully",
"opaque",
"and",
"vice",
"versa",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L523-L531 | train |
fogleman/gg | context.go | Clear | func (dc *Context) Clear() {
src := image.NewUniform(dc.color)
draw.Draw(dc.im, dc.im.Bounds(), src, image.ZP, draw.Src)
} | go | func (dc *Context) Clear() {
src := image.NewUniform(dc.color)
draw.Draw(dc.im, dc.im.Bounds(), src, image.ZP, draw.Src)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Clear",
"(",
")",
"{",
"src",
":=",
"image",
".",
"NewUniform",
"(",
"dc",
".",
"color",
")",
"\n",
"draw",
".",
"Draw",
"(",
"dc",
".",
"im",
",",
"dc",
".",
"im",
".",
"Bounds",
"(",
")",
",",
"src",
",",
"image",
".",
"ZP",
",",
"draw",
".",
"Src",
")",
"\n",
"}"
] | // Convenient Drawing Functions
// Clear fills the entire image with the current color. | [
"Convenient",
"Drawing",
"Functions",
"Clear",
"fills",
"the",
"entire",
"image",
"with",
"the",
"current",
"color",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L549-L552 | train |
fogleman/gg | context.go | SetPixel | func (dc *Context) SetPixel(x, y int) {
dc.im.Set(x, y, dc.color)
} | go | func (dc *Context) SetPixel(x, y int) {
dc.im.Set(x, y, dc.color)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"SetPixel",
"(",
"x",
",",
"y",
"int",
")",
"{",
"dc",
".",
"im",
".",
"Set",
"(",
"x",
",",
"y",
",",
"dc",
".",
"color",
")",
"\n",
"}"
] | // SetPixel sets the color of the specified pixel using the current color. | [
"SetPixel",
"sets",
"the",
"color",
"of",
"the",
"specified",
"pixel",
"using",
"the",
"current",
"color",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L555-L557 | train |
fogleman/gg | context.go | DrawPoint | func (dc *Context) DrawPoint(x, y, r float64) {
dc.Push()
tx, ty := dc.TransformPoint(x, y)
dc.Identity()
dc.DrawCircle(tx, ty, r)
dc.Pop()
} | go | func (dc *Context) DrawPoint(x, y, r float64) {
dc.Push()
tx, ty := dc.TransformPoint(x, y)
dc.Identity()
dc.DrawCircle(tx, ty, r)
dc.Pop()
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"DrawPoint",
"(",
"x",
",",
"y",
",",
"r",
"float64",
")",
"{",
"dc",
".",
"Push",
"(",
")",
"\n",
"tx",
",",
"ty",
":=",
"dc",
".",
"TransformPoint",
"(",
"x",
",",
"y",
")",
"\n",
"dc",
".",
"Identity",
"(",
")",
"\n",
"dc",
".",
"DrawCircle",
"(",
"tx",
",",
"ty",
",",
"r",
")",
"\n",
"dc",
".",
"Pop",
"(",
")",
"\n",
"}"
] | // DrawPoint is like DrawCircle but ensures that a circle of the specified
// size is drawn regardless of the current transformation matrix. The position
// is still transformed, but not the shape of the point. | [
"DrawPoint",
"is",
"like",
"DrawCircle",
"but",
"ensures",
"that",
"a",
"circle",
"of",
"the",
"specified",
"size",
"is",
"drawn",
"regardless",
"of",
"the",
"current",
"transformation",
"matrix",
".",
"The",
"position",
"is",
"still",
"transformed",
"but",
"not",
"the",
"shape",
"of",
"the",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L562-L568 | train |
fogleman/gg | context.go | DrawImage | func (dc *Context) DrawImage(im image.Image, x, y int) {
dc.DrawImageAnchored(im, x, y, 0, 0)
} | go | func (dc *Context) DrawImage(im image.Image, x, y int) {
dc.DrawImageAnchored(im, x, y, 0, 0)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"DrawImage",
"(",
"im",
"image",
".",
"Image",
",",
"x",
",",
"y",
"int",
")",
"{",
"dc",
".",
"DrawImageAnchored",
"(",
"im",
",",
"x",
",",
"y",
",",
"0",
",",
"0",
")",
"\n",
"}"
] | // DrawImage draws the specified image at the specified point. | [
"DrawImage",
"draws",
"the",
"specified",
"image",
"at",
"the",
"specified",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L657-L659 | train |
fogleman/gg | context.go | DrawString | func (dc *Context) DrawString(s string, x, y float64) {
dc.DrawStringAnchored(s, x, y, 0, 0)
} | go | func (dc *Context) DrawString(s string, x, y float64) {
dc.DrawStringAnchored(s, x, y, 0, 0)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"DrawString",
"(",
"s",
"string",
",",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"DrawStringAnchored",
"(",
"s",
",",
"x",
",",
"y",
",",
"0",
",",
"0",
")",
"\n",
"}"
] | // DrawString draws the specified text at the specified point. | [
"DrawString",
"draws",
"the",
"specified",
"text",
"at",
"the",
"specified",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L737-L739 | train |
fogleman/gg | context.go | DrawStringWrapped | func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) {
lines := dc.WordWrap(s, width)
// sync h formula with MeasureMultilineString
h := float64(len(lines)) * dc.fontHeight * lineSpacing
h -= (lineSpacing - 1) * dc.fontHeight
x -= ax * width
y -= ay * h
switch align {
case AlignLeft:
ax = 0
case AlignCenter:
ax = 0.5
x += width / 2
case AlignRight:
ax = 1
x += width
}
ay = 1
for _, line := range lines {
dc.DrawStringAnchored(line, x, y, ax, ay)
y += dc.fontHeight * lineSpacing
}
} | go | func (dc *Context) DrawStringWrapped(s string, x, y, ax, ay, width, lineSpacing float64, align Align) {
lines := dc.WordWrap(s, width)
// sync h formula with MeasureMultilineString
h := float64(len(lines)) * dc.fontHeight * lineSpacing
h -= (lineSpacing - 1) * dc.fontHeight
x -= ax * width
y -= ay * h
switch align {
case AlignLeft:
ax = 0
case AlignCenter:
ax = 0.5
x += width / 2
case AlignRight:
ax = 1
x += width
}
ay = 1
for _, line := range lines {
dc.DrawStringAnchored(line, x, y, ax, ay)
y += dc.fontHeight * lineSpacing
}
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"DrawStringWrapped",
"(",
"s",
"string",
",",
"x",
",",
"y",
",",
"ax",
",",
"ay",
",",
"width",
",",
"lineSpacing",
"float64",
",",
"align",
"Align",
")",
"{",
"lines",
":=",
"dc",
".",
"WordWrap",
"(",
"s",
",",
"width",
")",
"\n\n",
"// sync h formula with MeasureMultilineString",
"h",
":=",
"float64",
"(",
"len",
"(",
"lines",
")",
")",
"*",
"dc",
".",
"fontHeight",
"*",
"lineSpacing",
"\n",
"h",
"-=",
"(",
"lineSpacing",
"-",
"1",
")",
"*",
"dc",
".",
"fontHeight",
"\n\n",
"x",
"-=",
"ax",
"*",
"width",
"\n",
"y",
"-=",
"ay",
"*",
"h",
"\n",
"switch",
"align",
"{",
"case",
"AlignLeft",
":",
"ax",
"=",
"0",
"\n",
"case",
"AlignCenter",
":",
"ax",
"=",
"0.5",
"\n",
"x",
"+=",
"width",
"/",
"2",
"\n",
"case",
"AlignRight",
":",
"ax",
"=",
"1",
"\n",
"x",
"+=",
"width",
"\n",
"}",
"\n",
"ay",
"=",
"1",
"\n",
"for",
"_",
",",
"line",
":=",
"range",
"lines",
"{",
"dc",
".",
"DrawStringAnchored",
"(",
"line",
",",
"x",
",",
"y",
",",
"ax",
",",
"ay",
")",
"\n",
"y",
"+=",
"dc",
".",
"fontHeight",
"*",
"lineSpacing",
"\n",
"}",
"\n",
"}"
] | // DrawStringWrapped word-wraps the specified string to the given max width
// and then draws it at the specified anchor point using the given line
// spacing and text alignment. | [
"DrawStringWrapped",
"word",
"-",
"wraps",
"the",
"specified",
"string",
"to",
"the",
"given",
"max",
"width",
"and",
"then",
"draws",
"it",
"at",
"the",
"specified",
"anchor",
"point",
"using",
"the",
"given",
"line",
"spacing",
"and",
"text",
"alignment",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L760-L784 | train |
fogleman/gg | context.go | MeasureString | func (dc *Context) MeasureString(s string) (w, h float64) {
d := &font.Drawer{
Face: dc.fontFace,
}
a := d.MeasureString(s)
return float64(a >> 6), dc.fontHeight
} | go | func (dc *Context) MeasureString(s string) (w, h float64) {
d := &font.Drawer{
Face: dc.fontFace,
}
a := d.MeasureString(s)
return float64(a >> 6), dc.fontHeight
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"MeasureString",
"(",
"s",
"string",
")",
"(",
"w",
",",
"h",
"float64",
")",
"{",
"d",
":=",
"&",
"font",
".",
"Drawer",
"{",
"Face",
":",
"dc",
".",
"fontFace",
",",
"}",
"\n",
"a",
":=",
"d",
".",
"MeasureString",
"(",
"s",
")",
"\n",
"return",
"float64",
"(",
"a",
">>",
"6",
")",
",",
"dc",
".",
"fontHeight",
"\n",
"}"
] | // MeasureString returns the rendered width and height of the specified text
// given the current font face. | [
"MeasureString",
"returns",
"the",
"rendered",
"width",
"and",
"height",
"of",
"the",
"specified",
"text",
"given",
"the",
"current",
"font",
"face",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L811-L817 | train |
fogleman/gg | context.go | WordWrap | func (dc *Context) WordWrap(s string, w float64) []string {
return wordWrap(dc, s, w)
} | go | func (dc *Context) WordWrap(s string, w float64) []string {
return wordWrap(dc, s, w)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"WordWrap",
"(",
"s",
"string",
",",
"w",
"float64",
")",
"[",
"]",
"string",
"{",
"return",
"wordWrap",
"(",
"dc",
",",
"s",
",",
"w",
")",
"\n",
"}"
] | // WordWrap wraps the specified string to the given max width and current
// font face. | [
"WordWrap",
"wraps",
"the",
"specified",
"string",
"to",
"the",
"given",
"max",
"width",
"and",
"current",
"font",
"face",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L821-L823 | train |
fogleman/gg | context.go | Translate | func (dc *Context) Translate(x, y float64) {
dc.matrix = dc.matrix.Translate(x, y)
} | go | func (dc *Context) Translate(x, y float64) {
dc.matrix = dc.matrix.Translate(x, y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Translate",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"matrix",
"=",
"dc",
".",
"matrix",
".",
"Translate",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // Translate updates the current matrix with a translation. | [
"Translate",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"translation",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L834-L836 | train |
fogleman/gg | context.go | Scale | func (dc *Context) Scale(x, y float64) {
dc.matrix = dc.matrix.Scale(x, y)
} | go | func (dc *Context) Scale(x, y float64) {
dc.matrix = dc.matrix.Scale(x, y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Scale",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"matrix",
"=",
"dc",
".",
"matrix",
".",
"Scale",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // Scale updates the current matrix with a scaling factor.
// Scaling occurs about the origin. | [
"Scale",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"scaling",
"factor",
".",
"Scaling",
"occurs",
"about",
"the",
"origin",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L840-L842 | train |
fogleman/gg | context.go | ScaleAbout | func (dc *Context) ScaleAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Scale(sx, sy)
dc.Translate(-x, -y)
} | go | func (dc *Context) ScaleAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Scale(sx, sy)
dc.Translate(-x, -y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"ScaleAbout",
"(",
"sx",
",",
"sy",
",",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"Translate",
"(",
"x",
",",
"y",
")",
"\n",
"dc",
".",
"Scale",
"(",
"sx",
",",
"sy",
")",
"\n",
"dc",
".",
"Translate",
"(",
"-",
"x",
",",
"-",
"y",
")",
"\n",
"}"
] | // ScaleAbout updates the current matrix with a scaling factor.
// Scaling occurs about the specified point. | [
"ScaleAbout",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"scaling",
"factor",
".",
"Scaling",
"occurs",
"about",
"the",
"specified",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L846-L850 | train |
fogleman/gg | context.go | Rotate | func (dc *Context) Rotate(angle float64) {
dc.matrix = dc.matrix.Rotate(angle)
} | go | func (dc *Context) Rotate(angle float64) {
dc.matrix = dc.matrix.Rotate(angle)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Rotate",
"(",
"angle",
"float64",
")",
"{",
"dc",
".",
"matrix",
"=",
"dc",
".",
"matrix",
".",
"Rotate",
"(",
"angle",
")",
"\n",
"}"
] | // Rotate updates the current matrix with a clockwise rotation.
// Rotation occurs about the origin. Angle is specified in radians. | [
"Rotate",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"clockwise",
"rotation",
".",
"Rotation",
"occurs",
"about",
"the",
"origin",
".",
"Angle",
"is",
"specified",
"in",
"radians",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L854-L856 | train |
fogleman/gg | context.go | RotateAbout | func (dc *Context) RotateAbout(angle, x, y float64) {
dc.Translate(x, y)
dc.Rotate(angle)
dc.Translate(-x, -y)
} | go | func (dc *Context) RotateAbout(angle, x, y float64) {
dc.Translate(x, y)
dc.Rotate(angle)
dc.Translate(-x, -y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"RotateAbout",
"(",
"angle",
",",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"Translate",
"(",
"x",
",",
"y",
")",
"\n",
"dc",
".",
"Rotate",
"(",
"angle",
")",
"\n",
"dc",
".",
"Translate",
"(",
"-",
"x",
",",
"-",
"y",
")",
"\n",
"}"
] | // RotateAbout updates the current matrix with a clockwise rotation.
// Rotation occurs about the specified point. Angle is specified in radians. | [
"RotateAbout",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"clockwise",
"rotation",
".",
"Rotation",
"occurs",
"about",
"the",
"specified",
"point",
".",
"Angle",
"is",
"specified",
"in",
"radians",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L860-L864 | train |
fogleman/gg | context.go | Shear | func (dc *Context) Shear(x, y float64) {
dc.matrix = dc.matrix.Shear(x, y)
} | go | func (dc *Context) Shear(x, y float64) {
dc.matrix = dc.matrix.Shear(x, y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Shear",
"(",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"matrix",
"=",
"dc",
".",
"matrix",
".",
"Shear",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // Shear updates the current matrix with a shearing angle.
// Shearing occurs about the origin. | [
"Shear",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"shearing",
"angle",
".",
"Shearing",
"occurs",
"about",
"the",
"origin",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L868-L870 | train |
fogleman/gg | context.go | ShearAbout | func (dc *Context) ShearAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Shear(sx, sy)
dc.Translate(-x, -y)
} | go | func (dc *Context) ShearAbout(sx, sy, x, y float64) {
dc.Translate(x, y)
dc.Shear(sx, sy)
dc.Translate(-x, -y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"ShearAbout",
"(",
"sx",
",",
"sy",
",",
"x",
",",
"y",
"float64",
")",
"{",
"dc",
".",
"Translate",
"(",
"x",
",",
"y",
")",
"\n",
"dc",
".",
"Shear",
"(",
"sx",
",",
"sy",
")",
"\n",
"dc",
".",
"Translate",
"(",
"-",
"x",
",",
"-",
"y",
")",
"\n",
"}"
] | // ShearAbout updates the current matrix with a shearing angle.
// Shearing occurs about the specified point. | [
"ShearAbout",
"updates",
"the",
"current",
"matrix",
"with",
"a",
"shearing",
"angle",
".",
"Shearing",
"occurs",
"about",
"the",
"specified",
"point",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L874-L878 | train |
fogleman/gg | context.go | TransformPoint | func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
return dc.matrix.TransformPoint(x, y)
} | go | func (dc *Context) TransformPoint(x, y float64) (tx, ty float64) {
return dc.matrix.TransformPoint(x, y)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"TransformPoint",
"(",
"x",
",",
"y",
"float64",
")",
"(",
"tx",
",",
"ty",
"float64",
")",
"{",
"return",
"dc",
".",
"matrix",
".",
"TransformPoint",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // TransformPoint multiplies the specified point by the current matrix,
// returning a transformed position. | [
"TransformPoint",
"multiplies",
"the",
"specified",
"point",
"by",
"the",
"current",
"matrix",
"returning",
"a",
"transformed",
"position",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L882-L884 | train |
fogleman/gg | context.go | InvertY | func (dc *Context) InvertY() {
dc.Translate(0, float64(dc.height))
dc.Scale(1, -1)
} | go | func (dc *Context) InvertY() {
dc.Translate(0, float64(dc.height))
dc.Scale(1, -1)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"InvertY",
"(",
")",
"{",
"dc",
".",
"Translate",
"(",
"0",
",",
"float64",
"(",
"dc",
".",
"height",
")",
")",
"\n",
"dc",
".",
"Scale",
"(",
"1",
",",
"-",
"1",
")",
"\n",
"}"
] | // InvertY flips the Y axis so that Y grows from bottom to top and Y=0 is at
// the bottom of the image. | [
"InvertY",
"flips",
"the",
"Y",
"axis",
"so",
"that",
"Y",
"grows",
"from",
"bottom",
"to",
"top",
"and",
"Y",
"=",
"0",
"is",
"at",
"the",
"bottom",
"of",
"the",
"image",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L888-L891 | train |
fogleman/gg | context.go | Push | func (dc *Context) Push() {
x := *dc
dc.stack = append(dc.stack, &x)
} | go | func (dc *Context) Push() {
x := *dc
dc.stack = append(dc.stack, &x)
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Push",
"(",
")",
"{",
"x",
":=",
"*",
"dc",
"\n",
"dc",
".",
"stack",
"=",
"append",
"(",
"dc",
".",
"stack",
",",
"&",
"x",
")",
"\n",
"}"
] | // Stack
// Push saves the current state of the context for later retrieval. These
// can be nested. | [
"Stack",
"Push",
"saves",
"the",
"current",
"state",
"of",
"the",
"context",
"for",
"later",
"retrieval",
".",
"These",
"can",
"be",
"nested",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L897-L900 | train |
fogleman/gg | context.go | Pop | func (dc *Context) Pop() {
before := *dc
s := dc.stack
x, s := s[len(s)-1], s[:len(s)-1]
*dc = *x
dc.mask = before.mask
dc.strokePath = before.strokePath
dc.fillPath = before.fillPath
dc.start = before.start
dc.current = before.current
dc.hasCurrent = before.hasCurrent
} | go | func (dc *Context) Pop() {
before := *dc
s := dc.stack
x, s := s[len(s)-1], s[:len(s)-1]
*dc = *x
dc.mask = before.mask
dc.strokePath = before.strokePath
dc.fillPath = before.fillPath
dc.start = before.start
dc.current = before.current
dc.hasCurrent = before.hasCurrent
} | [
"func",
"(",
"dc",
"*",
"Context",
")",
"Pop",
"(",
")",
"{",
"before",
":=",
"*",
"dc",
"\n",
"s",
":=",
"dc",
".",
"stack",
"\n",
"x",
",",
"s",
":=",
"s",
"[",
"len",
"(",
"s",
")",
"-",
"1",
"]",
",",
"s",
"[",
":",
"len",
"(",
"s",
")",
"-",
"1",
"]",
"\n",
"*",
"dc",
"=",
"*",
"x",
"\n",
"dc",
".",
"mask",
"=",
"before",
".",
"mask",
"\n",
"dc",
".",
"strokePath",
"=",
"before",
".",
"strokePath",
"\n",
"dc",
".",
"fillPath",
"=",
"before",
".",
"fillPath",
"\n",
"dc",
".",
"start",
"=",
"before",
".",
"start",
"\n",
"dc",
".",
"current",
"=",
"before",
".",
"current",
"\n",
"dc",
".",
"hasCurrent",
"=",
"before",
".",
"hasCurrent",
"\n",
"}"
] | // Pop restores the last saved context state from the stack. | [
"Pop",
"restores",
"the",
"last",
"saved",
"context",
"state",
"from",
"the",
"stack",
"."
] | 72436a171bf31757dc87fb8fa9f7485307350307 | https://github.com/fogleman/gg/blob/72436a171bf31757dc87fb8fa9f7485307350307/context.go#L903-L914 | train |
faiface/pixel | imdraw/imdraw.go | New | func New(pic pixel.Picture) *IMDraw {
tri := &pixel.TrianglesData{}
im := &IMDraw{
tri: tri,
batch: pixel.NewBatch(tri, pic),
}
im.SetMatrix(pixel.IM)
im.SetColorMask(pixel.Alpha(1))
im.Reset()
return im
} | go | func New(pic pixel.Picture) *IMDraw {
tri := &pixel.TrianglesData{}
im := &IMDraw{
tri: tri,
batch: pixel.NewBatch(tri, pic),
}
im.SetMatrix(pixel.IM)
im.SetColorMask(pixel.Alpha(1))
im.Reset()
return im
} | [
"func",
"New",
"(",
"pic",
"pixel",
".",
"Picture",
")",
"*",
"IMDraw",
"{",
"tri",
":=",
"&",
"pixel",
".",
"TrianglesData",
"{",
"}",
"\n",
"im",
":=",
"&",
"IMDraw",
"{",
"tri",
":",
"tri",
",",
"batch",
":",
"pixel",
".",
"NewBatch",
"(",
"tri",
",",
"pic",
")",
",",
"}",
"\n",
"im",
".",
"SetMatrix",
"(",
"pixel",
".",
"IM",
")",
"\n",
"im",
".",
"SetColorMask",
"(",
"pixel",
".",
"Alpha",
"(",
"1",
")",
")",
"\n",
"im",
".",
"Reset",
"(",
")",
"\n",
"return",
"im",
"\n",
"}"
] | // New creates a new empty IMDraw. An optional Picture can be used to draw with a Picture.
//
// If you just want to draw primitive shapes, pass nil as the Picture. | [
"New",
"creates",
"a",
"new",
"empty",
"IMDraw",
".",
"An",
"optional",
"Picture",
"can",
"be",
"used",
"to",
"draw",
"with",
"a",
"Picture",
".",
"If",
"you",
"just",
"want",
"to",
"draw",
"primitive",
"shapes",
"pass",
"nil",
"as",
"the",
"Picture",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L91-L101 | train |
faiface/pixel | imdraw/imdraw.go | Reset | func (imd *IMDraw) Reset() {
imd.points = imd.points[:0]
imd.Color = pixel.Alpha(1)
imd.Picture = pixel.ZV
imd.Intensity = 0
imd.Precision = 64
imd.EndShape = NoEndShape
} | go | func (imd *IMDraw) Reset() {
imd.points = imd.points[:0]
imd.Color = pixel.Alpha(1)
imd.Picture = pixel.ZV
imd.Intensity = 0
imd.Precision = 64
imd.EndShape = NoEndShape
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Reset",
"(",
")",
"{",
"imd",
".",
"points",
"=",
"imd",
".",
"points",
"[",
":",
"0",
"]",
"\n",
"imd",
".",
"Color",
"=",
"pixel",
".",
"Alpha",
"(",
"1",
")",
"\n",
"imd",
".",
"Picture",
"=",
"pixel",
".",
"ZV",
"\n",
"imd",
".",
"Intensity",
"=",
"0",
"\n",
"imd",
".",
"Precision",
"=",
"64",
"\n",
"imd",
".",
"EndShape",
"=",
"NoEndShape",
"\n",
"}"
] | // Reset restores all point properties to defaults and removes all Pushed points.
//
// This does not affect matrix and color mask set by SetMatrix and SetColorMask. | [
"Reset",
"restores",
"all",
"point",
"properties",
"to",
"defaults",
"and",
"removes",
"all",
"Pushed",
"points",
".",
"This",
"does",
"not",
"affect",
"matrix",
"and",
"color",
"mask",
"set",
"by",
"SetMatrix",
"and",
"SetColorMask",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L112-L119 | train |
faiface/pixel | imdraw/imdraw.go | Draw | func (imd *IMDraw) Draw(t pixel.Target) {
imd.batch.Draw(t)
} | go | func (imd *IMDraw) Draw(t pixel.Target) {
imd.batch.Draw(t)
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Draw",
"(",
"t",
"pixel",
".",
"Target",
")",
"{",
"imd",
".",
"batch",
".",
"Draw",
"(",
"t",
")",
"\n",
"}"
] | // Draw draws all currently drawn shapes inside the IM onto another Target.
//
// Note, that IMDraw's matrix and color mask have no effect here. | [
"Draw",
"draws",
"all",
"currently",
"drawn",
"shapes",
"inside",
"the",
"IM",
"onto",
"another",
"Target",
".",
"Note",
"that",
"IMDraw",
"s",
"matrix",
"and",
"color",
"mask",
"have",
"no",
"effect",
"here",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L124-L126 | train |
faiface/pixel | imdraw/imdraw.go | Push | func (imd *IMDraw) Push(pts ...pixel.Vec) {
if _, ok := imd.Color.(pixel.RGBA); !ok {
imd.Color = pixel.ToRGBA(imd.Color)
}
opts := point{
col: imd.Color.(pixel.RGBA),
pic: imd.Picture,
in: imd.Intensity,
precision: imd.Precision,
endshape: imd.EndShape,
}
for _, pt := range pts {
imd.pushPt(pt, opts)
}
} | go | func (imd *IMDraw) Push(pts ...pixel.Vec) {
if _, ok := imd.Color.(pixel.RGBA); !ok {
imd.Color = pixel.ToRGBA(imd.Color)
}
opts := point{
col: imd.Color.(pixel.RGBA),
pic: imd.Picture,
in: imd.Intensity,
precision: imd.Precision,
endshape: imd.EndShape,
}
for _, pt := range pts {
imd.pushPt(pt, opts)
}
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Push",
"(",
"pts",
"...",
"pixel",
".",
"Vec",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"imd",
".",
"Color",
".",
"(",
"pixel",
".",
"RGBA",
")",
";",
"!",
"ok",
"{",
"imd",
".",
"Color",
"=",
"pixel",
".",
"ToRGBA",
"(",
"imd",
".",
"Color",
")",
"\n",
"}",
"\n",
"opts",
":=",
"point",
"{",
"col",
":",
"imd",
".",
"Color",
".",
"(",
"pixel",
".",
"RGBA",
")",
",",
"pic",
":",
"imd",
".",
"Picture",
",",
"in",
":",
"imd",
".",
"Intensity",
",",
"precision",
":",
"imd",
".",
"Precision",
",",
"endshape",
":",
"imd",
".",
"EndShape",
",",
"}",
"\n",
"for",
"_",
",",
"pt",
":=",
"range",
"pts",
"{",
"imd",
".",
"pushPt",
"(",
"pt",
",",
"opts",
")",
"\n",
"}",
"\n",
"}"
] | // Push adds some points to the IM queue. All Pushed points will have the same properties except for
// the position. | [
"Push",
"adds",
"some",
"points",
"to",
"the",
"IM",
"queue",
".",
"All",
"Pushed",
"points",
"will",
"have",
"the",
"same",
"properties",
"except",
"for",
"the",
"position",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L130-L144 | train |
faiface/pixel | imdraw/imdraw.go | SetMatrix | func (imd *IMDraw) SetMatrix(m pixel.Matrix) {
imd.matrix = m
imd.batch.SetMatrix(imd.matrix)
} | go | func (imd *IMDraw) SetMatrix(m pixel.Matrix) {
imd.matrix = m
imd.batch.SetMatrix(imd.matrix)
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"SetMatrix",
"(",
"m",
"pixel",
".",
"Matrix",
")",
"{",
"imd",
".",
"matrix",
"=",
"m",
"\n",
"imd",
".",
"batch",
".",
"SetMatrix",
"(",
"imd",
".",
"matrix",
")",
"\n",
"}"
] | // SetMatrix sets a Matrix that all further points will be transformed by. | [
"SetMatrix",
"sets",
"a",
"Matrix",
"that",
"all",
"further",
"points",
"will",
"be",
"transformed",
"by",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L152-L155 | train |
faiface/pixel | imdraw/imdraw.go | SetColorMask | func (imd *IMDraw) SetColorMask(color color.Color) {
imd.mask = pixel.ToRGBA(color)
imd.batch.SetColorMask(imd.mask)
} | go | func (imd *IMDraw) SetColorMask(color color.Color) {
imd.mask = pixel.ToRGBA(color)
imd.batch.SetColorMask(imd.mask)
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"SetColorMask",
"(",
"color",
"color",
".",
"Color",
")",
"{",
"imd",
".",
"mask",
"=",
"pixel",
".",
"ToRGBA",
"(",
"color",
")",
"\n",
"imd",
".",
"batch",
".",
"SetColorMask",
"(",
"imd",
".",
"mask",
")",
"\n",
"}"
] | // SetColorMask sets a color that all further point's color will be multiplied by. | [
"SetColorMask",
"sets",
"a",
"color",
"that",
"all",
"further",
"point",
"s",
"color",
"will",
"be",
"multiplied",
"by",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L158-L161 | train |
faiface/pixel | imdraw/imdraw.go | MakeTriangles | func (imd *IMDraw) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return imd.batch.MakeTriangles(t)
} | go | func (imd *IMDraw) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return imd.batch.MakeTriangles(t)
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"MakeTriangles",
"(",
"t",
"pixel",
".",
"Triangles",
")",
"pixel",
".",
"TargetTriangles",
"{",
"return",
"imd",
".",
"batch",
".",
"MakeTriangles",
"(",
"t",
")",
"\n",
"}"
] | // MakeTriangles returns a specialized copy of the provided Triangles that draws onto this IMDraw. | [
"MakeTriangles",
"returns",
"a",
"specialized",
"copy",
"of",
"the",
"provided",
"Triangles",
"that",
"draws",
"onto",
"this",
"IMDraw",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L164-L166 | train |
faiface/pixel | imdraw/imdraw.go | MakePicture | func (imd *IMDraw) MakePicture(p pixel.Picture) pixel.TargetPicture {
return imd.batch.MakePicture(p)
} | go | func (imd *IMDraw) MakePicture(p pixel.Picture) pixel.TargetPicture {
return imd.batch.MakePicture(p)
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"MakePicture",
"(",
"p",
"pixel",
".",
"Picture",
")",
"pixel",
".",
"TargetPicture",
"{",
"return",
"imd",
".",
"batch",
".",
"MakePicture",
"(",
"p",
")",
"\n",
"}"
] | // MakePicture returns a specialized copy of the provided Picture that draws onto this IMDraw. | [
"MakePicture",
"returns",
"a",
"specialized",
"copy",
"of",
"the",
"provided",
"Picture",
"that",
"draws",
"onto",
"this",
"IMDraw",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L169-L171 | train |
faiface/pixel | imdraw/imdraw.go | Rectangle | func (imd *IMDraw) Rectangle(thickness float64) {
if thickness == 0 {
imd.fillRectangle()
} else {
imd.outlineRectangle(thickness)
}
} | go | func (imd *IMDraw) Rectangle(thickness float64) {
if thickness == 0 {
imd.fillRectangle()
} else {
imd.outlineRectangle(thickness)
}
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Rectangle",
"(",
"thickness",
"float64",
")",
"{",
"if",
"thickness",
"==",
"0",
"{",
"imd",
".",
"fillRectangle",
"(",
")",
"\n",
"}",
"else",
"{",
"imd",
".",
"outlineRectangle",
"(",
"thickness",
")",
"\n",
"}",
"\n",
"}"
] | // Rectangle draws a rectangle between each two subsequent Pushed points. Drawing a rectangle
// between two points means drawing a rectangle with sides parallel to the axes of the coordinate
// system, where the two points specify it's two opposite corners.
//
// If the thickness is 0, rectangles will be filled, otherwise will be outlined with the given
// thickness. | [
"Rectangle",
"draws",
"a",
"rectangle",
"between",
"each",
"two",
"subsequent",
"Pushed",
"points",
".",
"Drawing",
"a",
"rectangle",
"between",
"two",
"points",
"means",
"drawing",
"a",
"rectangle",
"with",
"sides",
"parallel",
"to",
"the",
"axes",
"of",
"the",
"coordinate",
"system",
"where",
"the",
"two",
"points",
"specify",
"it",
"s",
"two",
"opposite",
"corners",
".",
"If",
"the",
"thickness",
"is",
"0",
"rectangles",
"will",
"be",
"filled",
"otherwise",
"will",
"be",
"outlined",
"with",
"the",
"given",
"thickness",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L184-L190 | train |
faiface/pixel | imdraw/imdraw.go | Polygon | func (imd *IMDraw) Polygon(thickness float64) {
if thickness == 0 {
imd.fillPolygon()
} else {
imd.polyline(thickness, true)
}
} | go | func (imd *IMDraw) Polygon(thickness float64) {
if thickness == 0 {
imd.fillPolygon()
} else {
imd.polyline(thickness, true)
}
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Polygon",
"(",
"thickness",
"float64",
")",
"{",
"if",
"thickness",
"==",
"0",
"{",
"imd",
".",
"fillPolygon",
"(",
")",
"\n",
"}",
"else",
"{",
"imd",
".",
"polyline",
"(",
"thickness",
",",
"true",
")",
"\n",
"}",
"\n",
"}"
] | // Polygon draws a polygon from the Pushed points. If the thickness is 0, the convex polygon will be
// filled. Otherwise, an outline of the specified thickness will be drawn. The outline does not have
// to be convex.
//
// Note, that the filled polygon does not have to be strictly convex. The way it's drawn is that a
// triangle is drawn between each two adjacent points and the first Pushed point. You can use this
// property to draw certain kinds of concave polygons. | [
"Polygon",
"draws",
"a",
"polygon",
"from",
"the",
"Pushed",
"points",
".",
"If",
"the",
"thickness",
"is",
"0",
"the",
"convex",
"polygon",
"will",
"be",
"filled",
".",
"Otherwise",
"an",
"outline",
"of",
"the",
"specified",
"thickness",
"will",
"be",
"drawn",
".",
"The",
"outline",
"does",
"not",
"have",
"to",
"be",
"convex",
".",
"Note",
"that",
"the",
"filled",
"polygon",
"does",
"not",
"have",
"to",
"be",
"strictly",
"convex",
".",
"The",
"way",
"it",
"s",
"drawn",
"is",
"that",
"a",
"triangle",
"is",
"drawn",
"between",
"each",
"two",
"adjacent",
"points",
"and",
"the",
"first",
"Pushed",
"point",
".",
"You",
"can",
"use",
"this",
"property",
"to",
"draw",
"certain",
"kinds",
"of",
"concave",
"polygons",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L199-L205 | train |
faiface/pixel | imdraw/imdraw.go | Circle | func (imd *IMDraw) Circle(radius, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi, thickness, false)
}
} | go | func (imd *IMDraw) Circle(radius, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(pixel.V(radius, radius), 0, 2*math.Pi, thickness, false)
}
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Circle",
"(",
"radius",
",",
"thickness",
"float64",
")",
"{",
"if",
"thickness",
"==",
"0",
"{",
"imd",
".",
"fillEllipseArc",
"(",
"pixel",
".",
"V",
"(",
"radius",
",",
"radius",
")",
",",
"0",
",",
"2",
"*",
"math",
".",
"Pi",
")",
"\n",
"}",
"else",
"{",
"imd",
".",
"outlineEllipseArc",
"(",
"pixel",
".",
"V",
"(",
"radius",
",",
"radius",
")",
",",
"0",
",",
"2",
"*",
"math",
".",
"Pi",
",",
"thickness",
",",
"false",
")",
"\n",
"}",
"\n",
"}"
] | // Circle draws a circle of the specified radius around each Pushed point. If the thickness is 0,
// the circle will be filled, otherwise a circle outline of the specified thickness will be drawn. | [
"Circle",
"draws",
"a",
"circle",
"of",
"the",
"specified",
"radius",
"around",
"each",
"Pushed",
"point",
".",
"If",
"the",
"thickness",
"is",
"0",
"the",
"circle",
"will",
"be",
"filled",
"otherwise",
"a",
"circle",
"outline",
"of",
"the",
"specified",
"thickness",
"will",
"be",
"drawn",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L209-L215 | train |
faiface/pixel | imdraw/imdraw.go | Ellipse | func (imd *IMDraw) Ellipse(radius pixel.Vec, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(radius, 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(radius, 0, 2*math.Pi, thickness, false)
}
} | go | func (imd *IMDraw) Ellipse(radius pixel.Vec, thickness float64) {
if thickness == 0 {
imd.fillEllipseArc(radius, 0, 2*math.Pi)
} else {
imd.outlineEllipseArc(radius, 0, 2*math.Pi, thickness, false)
}
} | [
"func",
"(",
"imd",
"*",
"IMDraw",
")",
"Ellipse",
"(",
"radius",
"pixel",
".",
"Vec",
",",
"thickness",
"float64",
")",
"{",
"if",
"thickness",
"==",
"0",
"{",
"imd",
".",
"fillEllipseArc",
"(",
"radius",
",",
"0",
",",
"2",
"*",
"math",
".",
"Pi",
")",
"\n",
"}",
"else",
"{",
"imd",
".",
"outlineEllipseArc",
"(",
"radius",
",",
"0",
",",
"2",
"*",
"math",
".",
"Pi",
",",
"thickness",
",",
"false",
")",
"\n",
"}",
"\n",
"}"
] | // Ellipse draws an ellipse of the specified radius in each axis around each Pushed points. If the
// thickness is 0, the ellipse will be filled, otherwise an ellipse outline of the specified
// thickness will be drawn. | [
"Ellipse",
"draws",
"an",
"ellipse",
"of",
"the",
"specified",
"radius",
"in",
"each",
"axis",
"around",
"each",
"Pushed",
"points",
".",
"If",
"the",
"thickness",
"is",
"0",
"the",
"ellipse",
"will",
"be",
"filled",
"otherwise",
"an",
"ellipse",
"outline",
"of",
"the",
"specified",
"thickness",
"will",
"be",
"drawn",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/imdraw/imdraw.go#L236-L242 | train |
faiface/pixel | pixelgl/input.go | Pressed | func (w *Window) Pressed(button Button) bool {
return w.currInp.buttons[button]
} | go | func (w *Window) Pressed(button Button) bool {
return w.currInp.buttons[button]
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Pressed",
"(",
"button",
"Button",
")",
"bool",
"{",
"return",
"w",
".",
"currInp",
".",
"buttons",
"[",
"button",
"]",
"\n",
"}"
] | // Pressed returns whether the Button is currently pressed down. | [
"Pressed",
"returns",
"whether",
"the",
"Button",
"is",
"currently",
"pressed",
"down",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L10-L12 | train |
faiface/pixel | pixelgl/input.go | JustPressed | func (w *Window) JustPressed(button Button) bool {
return w.currInp.buttons[button] && !w.prevInp.buttons[button]
} | go | func (w *Window) JustPressed(button Button) bool {
return w.currInp.buttons[button] && !w.prevInp.buttons[button]
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"JustPressed",
"(",
"button",
"Button",
")",
"bool",
"{",
"return",
"w",
".",
"currInp",
".",
"buttons",
"[",
"button",
"]",
"&&",
"!",
"w",
".",
"prevInp",
".",
"buttons",
"[",
"button",
"]",
"\n",
"}"
] | // JustPressed returns whether the Button has just been pressed down. | [
"JustPressed",
"returns",
"whether",
"the",
"Button",
"has",
"just",
"been",
"pressed",
"down",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L15-L17 | train |
faiface/pixel | pixelgl/input.go | Repeated | func (w *Window) Repeated(button Button) bool {
return w.currInp.repeat[button]
} | go | func (w *Window) Repeated(button Button) bool {
return w.currInp.repeat[button]
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Repeated",
"(",
"button",
"Button",
")",
"bool",
"{",
"return",
"w",
".",
"currInp",
".",
"repeat",
"[",
"button",
"]",
"\n",
"}"
] | // Repeated returns whether a repeat event has been triggered on button.
//
// Repeat event occurs repeatedly when a button is held down for some time. | [
"Repeated",
"returns",
"whether",
"a",
"repeat",
"event",
"has",
"been",
"triggered",
"on",
"button",
".",
"Repeat",
"event",
"occurs",
"repeatedly",
"when",
"a",
"button",
"is",
"held",
"down",
"for",
"some",
"time",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L27-L29 | train |
faiface/pixel | pixelgl/input.go | SetMousePosition | func (w *Window) SetMousePosition(v pixel.Vec) {
mainthread.Call(func() {
if (v.X >= 0 && v.X <= w.bounds.W()) &&
(v.Y >= 0 && v.Y <= w.bounds.H()) {
w.window.SetCursorPos(
v.X+w.bounds.Min.X,
(w.bounds.H()-v.Y)+w.bounds.Min.Y,
)
w.prevInp.mouse = v
w.currInp.mouse = v
w.tempInp.mouse = v
}
})
} | go | func (w *Window) SetMousePosition(v pixel.Vec) {
mainthread.Call(func() {
if (v.X >= 0 && v.X <= w.bounds.W()) &&
(v.Y >= 0 && v.Y <= w.bounds.H()) {
w.window.SetCursorPos(
v.X+w.bounds.Min.X,
(w.bounds.H()-v.Y)+w.bounds.Min.Y,
)
w.prevInp.mouse = v
w.currInp.mouse = v
w.tempInp.mouse = v
}
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetMousePosition",
"(",
"v",
"pixel",
".",
"Vec",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"if",
"(",
"v",
".",
"X",
">=",
"0",
"&&",
"v",
".",
"X",
"<=",
"w",
".",
"bounds",
".",
"W",
"(",
")",
")",
"&&",
"(",
"v",
".",
"Y",
">=",
"0",
"&&",
"v",
".",
"Y",
"<=",
"w",
".",
"bounds",
".",
"H",
"(",
")",
")",
"{",
"w",
".",
"window",
".",
"SetCursorPos",
"(",
"v",
".",
"X",
"+",
"w",
".",
"bounds",
".",
"Min",
".",
"X",
",",
"(",
"w",
".",
"bounds",
".",
"H",
"(",
")",
"-",
"v",
".",
"Y",
")",
"+",
"w",
".",
"bounds",
".",
"Min",
".",
"Y",
",",
")",
"\n",
"w",
".",
"prevInp",
".",
"mouse",
"=",
"v",
"\n",
"w",
".",
"currInp",
".",
"mouse",
"=",
"v",
"\n",
"w",
".",
"tempInp",
".",
"mouse",
"=",
"v",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] | // SetMousePosition positions the mouse cursor anywhere within the Window's Bounds. | [
"SetMousePosition",
"positions",
"the",
"mouse",
"cursor",
"anywhere",
"within",
"the",
"Window",
"s",
"Bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L42-L55 | train |
faiface/pixel | pixelgl/input.go | String | func (b Button) String() string {
name, ok := buttonNames[b]
if !ok {
return "Invalid"
}
return name
} | go | func (b Button) String() string {
name, ok := buttonNames[b]
if !ok {
return "Invalid"
}
return name
} | [
"func",
"(",
"b",
"Button",
")",
"String",
"(",
")",
"string",
"{",
"name",
",",
"ok",
":=",
"buttonNames",
"[",
"b",
"]",
"\n",
"if",
"!",
"ok",
"{",
"return",
"\"",
"\"",
"\n",
"}",
"\n",
"return",
"name",
"\n",
"}"
] | // String returns a human-readable string describing the Button. | [
"String",
"returns",
"a",
"human",
"-",
"readable",
"string",
"describing",
"the",
"Button",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L218-L224 | train |
faiface/pixel | pixelgl/input.go | UpdateInput | func (w *Window) UpdateInput() {
mainthread.Call(func() {
glfw.PollEvents()
})
w.prevInp = w.currInp
w.currInp = w.tempInp
w.tempInp.repeat = [KeyLast + 1]bool{}
w.tempInp.scroll = pixel.ZV
w.tempInp.typed = ""
w.updateJoystickInput()
} | go | func (w *Window) UpdateInput() {
mainthread.Call(func() {
glfw.PollEvents()
})
w.prevInp = w.currInp
w.currInp = w.tempInp
w.tempInp.repeat = [KeyLast + 1]bool{}
w.tempInp.scroll = pixel.ZV
w.tempInp.typed = ""
w.updateJoystickInput()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"UpdateInput",
"(",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"glfw",
".",
"PollEvents",
"(",
")",
"\n",
"}",
")",
"\n\n",
"w",
".",
"prevInp",
"=",
"w",
".",
"currInp",
"\n",
"w",
".",
"currInp",
"=",
"w",
".",
"tempInp",
"\n\n",
"w",
".",
"tempInp",
".",
"repeat",
"=",
"[",
"KeyLast",
"+",
"1",
"]",
"bool",
"{",
"}",
"\n",
"w",
".",
"tempInp",
".",
"scroll",
"=",
"pixel",
".",
"ZV",
"\n",
"w",
".",
"tempInp",
".",
"typed",
"=",
"\"",
"\"",
"\n\n",
"w",
".",
"updateJoystickInput",
"(",
")",
"\n",
"}"
] | // UpdateInput polls window events. Call this function to poll window events
// without swapping buffers. Note that the Update method invokes UpdateInput. | [
"UpdateInput",
"polls",
"window",
"events",
".",
"Call",
"this",
"function",
"to",
"poll",
"window",
"events",
"without",
"swapping",
"buffers",
".",
"Note",
"that",
"the",
"Update",
"method",
"invokes",
"UpdateInput",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/input.go#L407-L420 | train |
faiface/pixel | pixelgl/glshader.go | update | func (gs *glShader) update() {
gs.uf = nil
for _, u := range gs.uniforms {
gs.uf = append(gs.uf, glhf.Attr{
Name: u.Name,
Type: u.Type,
})
}
var shader *glhf.Shader
mainthread.Call(func() {
var err error
shader, err = glhf.NewShader(
gs.vf,
gs.uf,
gs.vs,
gs.fs,
)
if err != nil {
panic(errors.Wrap(err, "failed to create Canvas, there's a bug in the shader"))
}
})
gs.s = shader
} | go | func (gs *glShader) update() {
gs.uf = nil
for _, u := range gs.uniforms {
gs.uf = append(gs.uf, glhf.Attr{
Name: u.Name,
Type: u.Type,
})
}
var shader *glhf.Shader
mainthread.Call(func() {
var err error
shader, err = glhf.NewShader(
gs.vf,
gs.uf,
gs.vs,
gs.fs,
)
if err != nil {
panic(errors.Wrap(err, "failed to create Canvas, there's a bug in the shader"))
}
})
gs.s = shader
} | [
"func",
"(",
"gs",
"*",
"glShader",
")",
"update",
"(",
")",
"{",
"gs",
".",
"uf",
"=",
"nil",
"\n",
"for",
"_",
",",
"u",
":=",
"range",
"gs",
".",
"uniforms",
"{",
"gs",
".",
"uf",
"=",
"append",
"(",
"gs",
".",
"uf",
",",
"glhf",
".",
"Attr",
"{",
"Name",
":",
"u",
".",
"Name",
",",
"Type",
":",
"u",
".",
"Type",
",",
"}",
")",
"\n",
"}",
"\n",
"var",
"shader",
"*",
"glhf",
".",
"Shader",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"var",
"err",
"error",
"\n",
"shader",
",",
"err",
"=",
"glhf",
".",
"NewShader",
"(",
"gs",
".",
"vf",
",",
"gs",
".",
"uf",
",",
"gs",
".",
"vs",
",",
"gs",
".",
"fs",
",",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"panic",
"(",
"errors",
".",
"Wrap",
"(",
"err",
",",
"\"",
"\"",
")",
")",
"\n",
"}",
"\n",
"}",
")",
"\n\n",
"gs",
".",
"s",
"=",
"shader",
"\n",
"}"
] | // reinitialize GLShader data and recompile the underlying gl shader object | [
"reinitialize",
"GLShader",
"data",
"and",
"recompile",
"the",
"underlying",
"gl",
"shader",
"object"
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glshader.go#L36-L59 | train |
faiface/pixel | pixelgl/glshader.go | getUniform | func (gs *glShader) getUniform(Name string) int {
for i, u := range gs.uniforms {
if u.Name == Name {
return i
}
}
return -1
} | go | func (gs *glShader) getUniform(Name string) int {
for i, u := range gs.uniforms {
if u.Name == Name {
return i
}
}
return -1
} | [
"func",
"(",
"gs",
"*",
"glShader",
")",
"getUniform",
"(",
"Name",
"string",
")",
"int",
"{",
"for",
"i",
",",
"u",
":=",
"range",
"gs",
".",
"uniforms",
"{",
"if",
"u",
".",
"Name",
"==",
"Name",
"{",
"return",
"i",
"\n",
"}",
"\n",
"}",
"\n",
"return",
"-",
"1",
"\n",
"}"
] | // gets the uniform index from GLShader | [
"gets",
"the",
"uniform",
"index",
"from",
"GLShader"
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glshader.go#L62-L69 | train |
faiface/pixel | pixelgl/glshader.go | baseShader | func baseShader(c *Canvas) {
gs := &glShader{
vf: defaultCanvasVertexFormat,
vs: baseCanvasVertexShader,
fs: baseCanvasFragmentShader,
}
gs.setUniform("uTransform", &gs.uniformDefaults.transform)
gs.setUniform("uColorMask", &gs.uniformDefaults.colormask)
gs.setUniform("uBounds", &gs.uniformDefaults.bounds)
gs.setUniform("uTexBounds", &gs.uniformDefaults.texbounds)
c.shader = gs
} | go | func baseShader(c *Canvas) {
gs := &glShader{
vf: defaultCanvasVertexFormat,
vs: baseCanvasVertexShader,
fs: baseCanvasFragmentShader,
}
gs.setUniform("uTransform", &gs.uniformDefaults.transform)
gs.setUniform("uColorMask", &gs.uniformDefaults.colormask)
gs.setUniform("uBounds", &gs.uniformDefaults.bounds)
gs.setUniform("uTexBounds", &gs.uniformDefaults.texbounds)
c.shader = gs
} | [
"func",
"baseShader",
"(",
"c",
"*",
"Canvas",
")",
"{",
"gs",
":=",
"&",
"glShader",
"{",
"vf",
":",
"defaultCanvasVertexFormat",
",",
"vs",
":",
"baseCanvasVertexShader",
",",
"fs",
":",
"baseCanvasFragmentShader",
",",
"}",
"\n\n",
"gs",
".",
"setUniform",
"(",
"\"",
"\"",
",",
"&",
"gs",
".",
"uniformDefaults",
".",
"transform",
")",
"\n",
"gs",
".",
"setUniform",
"(",
"\"",
"\"",
",",
"&",
"gs",
".",
"uniformDefaults",
".",
"colormask",
")",
"\n",
"gs",
".",
"setUniform",
"(",
"\"",
"\"",
",",
"&",
"gs",
".",
"uniformDefaults",
".",
"bounds",
")",
"\n",
"gs",
".",
"setUniform",
"(",
"\"",
"\"",
",",
"&",
"gs",
".",
"uniformDefaults",
".",
"texbounds",
")",
"\n\n",
"c",
".",
"shader",
"=",
"gs",
"\n",
"}"
] | // Sets up a base shader with everything needed for a Pixel
// canvas to render correctly. The defaults can be overridden
// by simply using the SetUniform function. | [
"Sets",
"up",
"a",
"base",
"shader",
"with",
"everything",
"needed",
"for",
"a",
"Pixel",
"canvas",
"to",
"render",
"correctly",
".",
"The",
"defaults",
"can",
"be",
"overridden",
"by",
"simply",
"using",
"the",
"SetUniform",
"function",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glshader.go#L98-L111 | train |
faiface/pixel | pixelgl/glshader.go | Value | func (gu *gsUniformAttr) Value() interface{} {
if !gu.ispointer {
return gu.value
}
switch gu.Type {
case glhf.Vec2:
return *gu.value.(*mgl32.Vec2)
case glhf.Vec3:
return *gu.value.(*mgl32.Vec3)
case glhf.Vec4:
return *gu.value.(*mgl32.Vec4)
case glhf.Mat2:
return *gu.value.(*mgl32.Mat2)
case glhf.Mat23:
return *gu.value.(*mgl32.Mat2x3)
case glhf.Mat24:
return *gu.value.(*mgl32.Mat2x4)
case glhf.Mat3:
return *gu.value.(*mgl32.Mat3)
case glhf.Mat32:
return *gu.value.(*mgl32.Mat3x2)
case glhf.Mat34:
return *gu.value.(*mgl32.Mat3x4)
case glhf.Mat4:
return *gu.value.(*mgl32.Mat4)
case glhf.Mat42:
return *gu.value.(*mgl32.Mat4x2)
case glhf.Mat43:
return *gu.value.(*mgl32.Mat4x3)
case glhf.Int:
return *gu.value.(*int32)
case glhf.Float:
return *gu.value.(*float32)
default:
panic("invalid attrtype")
}
} | go | func (gu *gsUniformAttr) Value() interface{} {
if !gu.ispointer {
return gu.value
}
switch gu.Type {
case glhf.Vec2:
return *gu.value.(*mgl32.Vec2)
case glhf.Vec3:
return *gu.value.(*mgl32.Vec3)
case glhf.Vec4:
return *gu.value.(*mgl32.Vec4)
case glhf.Mat2:
return *gu.value.(*mgl32.Mat2)
case glhf.Mat23:
return *gu.value.(*mgl32.Mat2x3)
case glhf.Mat24:
return *gu.value.(*mgl32.Mat2x4)
case glhf.Mat3:
return *gu.value.(*mgl32.Mat3)
case glhf.Mat32:
return *gu.value.(*mgl32.Mat3x2)
case glhf.Mat34:
return *gu.value.(*mgl32.Mat3x4)
case glhf.Mat4:
return *gu.value.(*mgl32.Mat4)
case glhf.Mat42:
return *gu.value.(*mgl32.Mat4x2)
case glhf.Mat43:
return *gu.value.(*mgl32.Mat4x3)
case glhf.Int:
return *gu.value.(*int32)
case glhf.Float:
return *gu.value.(*float32)
default:
panic("invalid attrtype")
}
} | [
"func",
"(",
"gu",
"*",
"gsUniformAttr",
")",
"Value",
"(",
")",
"interface",
"{",
"}",
"{",
"if",
"!",
"gu",
".",
"ispointer",
"{",
"return",
"gu",
".",
"value",
"\n",
"}",
"\n",
"switch",
"gu",
".",
"Type",
"{",
"case",
"glhf",
".",
"Vec2",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Vec2",
")",
"\n",
"case",
"glhf",
".",
"Vec3",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Vec3",
")",
"\n",
"case",
"glhf",
".",
"Vec4",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Vec4",
")",
"\n",
"case",
"glhf",
".",
"Mat2",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat2",
")",
"\n",
"case",
"glhf",
".",
"Mat23",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat2x3",
")",
"\n",
"case",
"glhf",
".",
"Mat24",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat2x4",
")",
"\n",
"case",
"glhf",
".",
"Mat3",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat3",
")",
"\n",
"case",
"glhf",
".",
"Mat32",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat3x2",
")",
"\n",
"case",
"glhf",
".",
"Mat34",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat3x4",
")",
"\n",
"case",
"glhf",
".",
"Mat4",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat4",
")",
"\n",
"case",
"glhf",
".",
"Mat42",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat4x2",
")",
"\n",
"case",
"glhf",
".",
"Mat43",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"mgl32",
".",
"Mat4x3",
")",
"\n",
"case",
"glhf",
".",
"Int",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"int32",
")",
"\n",
"case",
"glhf",
".",
"Float",
":",
"return",
"*",
"gu",
".",
"value",
".",
"(",
"*",
"float32",
")",
"\n",
"default",
":",
"panic",
"(",
"\"",
"\"",
")",
"\n",
"}",
"\n",
"}"
] | // Value returns the attribute's concrete value. If the stored value
// is a pointer, we return the dereferenced value. | [
"Value",
"returns",
"the",
"attribute",
"s",
"concrete",
"value",
".",
"If",
"the",
"stored",
"value",
"is",
"a",
"pointer",
"we",
"return",
"the",
"dereferenced",
"value",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/glshader.go#L115-L151 | train |
faiface/pixel | pixelgl/window.go | Update | func (w *Window) Update() {
mainthread.Call(func() {
_, _, oldW, oldH := intBounds(w.bounds)
newW, newH := w.window.GetSize()
w.bounds = w.bounds.ResizedMin(w.bounds.Size().Add(pixel.V(
float64(newW-oldW),
float64(newH-oldH),
)))
})
w.canvas.SetBounds(w.bounds)
mainthread.Call(func() {
w.begin()
framebufferWidth, framebufferHeight := w.window.GetFramebufferSize()
glhf.Bounds(0, 0, framebufferWidth, framebufferHeight)
glhf.Clear(0, 0, 0, 0)
w.canvas.gf.Frame().Begin()
w.canvas.gf.Frame().Blit(
nil,
0, 0, w.canvas.Texture().Width(), w.canvas.Texture().Height(),
0, 0, framebufferWidth, framebufferHeight,
)
w.canvas.gf.Frame().End()
if w.vsync {
glfw.SwapInterval(1)
} else {
glfw.SwapInterval(0)
}
w.window.SwapBuffers()
w.end()
})
w.UpdateInput()
} | go | func (w *Window) Update() {
mainthread.Call(func() {
_, _, oldW, oldH := intBounds(w.bounds)
newW, newH := w.window.GetSize()
w.bounds = w.bounds.ResizedMin(w.bounds.Size().Add(pixel.V(
float64(newW-oldW),
float64(newH-oldH),
)))
})
w.canvas.SetBounds(w.bounds)
mainthread.Call(func() {
w.begin()
framebufferWidth, framebufferHeight := w.window.GetFramebufferSize()
glhf.Bounds(0, 0, framebufferWidth, framebufferHeight)
glhf.Clear(0, 0, 0, 0)
w.canvas.gf.Frame().Begin()
w.canvas.gf.Frame().Blit(
nil,
0, 0, w.canvas.Texture().Width(), w.canvas.Texture().Height(),
0, 0, framebufferWidth, framebufferHeight,
)
w.canvas.gf.Frame().End()
if w.vsync {
glfw.SwapInterval(1)
} else {
glfw.SwapInterval(0)
}
w.window.SwapBuffers()
w.end()
})
w.UpdateInput()
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Update",
"(",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"_",
",",
"_",
",",
"oldW",
",",
"oldH",
":=",
"intBounds",
"(",
"w",
".",
"bounds",
")",
"\n",
"newW",
",",
"newH",
":=",
"w",
".",
"window",
".",
"GetSize",
"(",
")",
"\n",
"w",
".",
"bounds",
"=",
"w",
".",
"bounds",
".",
"ResizedMin",
"(",
"w",
".",
"bounds",
".",
"Size",
"(",
")",
".",
"Add",
"(",
"pixel",
".",
"V",
"(",
"float64",
"(",
"newW",
"-",
"oldW",
")",
",",
"float64",
"(",
"newH",
"-",
"oldH",
")",
",",
")",
")",
")",
"\n",
"}",
")",
"\n\n",
"w",
".",
"canvas",
".",
"SetBounds",
"(",
"w",
".",
"bounds",
")",
"\n\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"w",
".",
"begin",
"(",
")",
"\n\n",
"framebufferWidth",
",",
"framebufferHeight",
":=",
"w",
".",
"window",
".",
"GetFramebufferSize",
"(",
")",
"\n",
"glhf",
".",
"Bounds",
"(",
"0",
",",
"0",
",",
"framebufferWidth",
",",
"framebufferHeight",
")",
"\n\n",
"glhf",
".",
"Clear",
"(",
"0",
",",
"0",
",",
"0",
",",
"0",
")",
"\n",
"w",
".",
"canvas",
".",
"gf",
".",
"Frame",
"(",
")",
".",
"Begin",
"(",
")",
"\n",
"w",
".",
"canvas",
".",
"gf",
".",
"Frame",
"(",
")",
".",
"Blit",
"(",
"nil",
",",
"0",
",",
"0",
",",
"w",
".",
"canvas",
".",
"Texture",
"(",
")",
".",
"Width",
"(",
")",
",",
"w",
".",
"canvas",
".",
"Texture",
"(",
")",
".",
"Height",
"(",
")",
",",
"0",
",",
"0",
",",
"framebufferWidth",
",",
"framebufferHeight",
",",
")",
"\n",
"w",
".",
"canvas",
".",
"gf",
".",
"Frame",
"(",
")",
".",
"End",
"(",
")",
"\n\n",
"if",
"w",
".",
"vsync",
"{",
"glfw",
".",
"SwapInterval",
"(",
"1",
")",
"\n",
"}",
"else",
"{",
"glfw",
".",
"SwapInterval",
"(",
"0",
")",
"\n",
"}",
"\n",
"w",
".",
"window",
".",
"SwapBuffers",
"(",
")",
"\n",
"w",
".",
"end",
"(",
")",
"\n",
"}",
")",
"\n\n",
"w",
".",
"UpdateInput",
"(",
")",
"\n",
"}"
] | // Update swaps buffers and polls events. Call this method at the end of each frame. | [
"Update",
"swaps",
"buffers",
"and",
"polls",
"events",
".",
"Call",
"this",
"method",
"at",
"the",
"end",
"of",
"each",
"frame",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L163-L200 | train |
faiface/pixel | pixelgl/window.go | SetClosed | func (w *Window) SetClosed(closed bool) {
mainthread.Call(func() {
w.window.SetShouldClose(closed)
})
} | go | func (w *Window) SetClosed(closed bool) {
mainthread.Call(func() {
w.window.SetShouldClose(closed)
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetClosed",
"(",
"closed",
"bool",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"w",
".",
"window",
".",
"SetShouldClose",
"(",
"closed",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SetClosed sets the closed flag of the Window.
//
// This is useful when overriding the user's attempt to close the Window, or just to close the
// Window from within the program. | [
"SetClosed",
"sets",
"the",
"closed",
"flag",
"of",
"the",
"Window",
".",
"This",
"is",
"useful",
"when",
"overriding",
"the",
"user",
"s",
"attempt",
"to",
"close",
"the",
"Window",
"or",
"just",
"to",
"close",
"the",
"Window",
"from",
"within",
"the",
"program",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L206-L210 | train |
faiface/pixel | pixelgl/window.go | Closed | func (w *Window) Closed() bool {
var closed bool
mainthread.Call(func() {
closed = w.window.ShouldClose()
})
return closed
} | go | func (w *Window) Closed() bool {
var closed bool
mainthread.Call(func() {
closed = w.window.ShouldClose()
})
return closed
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Closed",
"(",
")",
"bool",
"{",
"var",
"closed",
"bool",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"closed",
"=",
"w",
".",
"window",
".",
"ShouldClose",
"(",
")",
"\n",
"}",
")",
"\n",
"return",
"closed",
"\n",
"}"
] | // Closed returns the closed flag of the Window, which reports whether the Window should be closed.
//
// The closed flag is automatically set when a user attempts to close the Window. | [
"Closed",
"returns",
"the",
"closed",
"flag",
"of",
"the",
"Window",
"which",
"reports",
"whether",
"the",
"Window",
"should",
"be",
"closed",
".",
"The",
"closed",
"flag",
"is",
"automatically",
"set",
"when",
"a",
"user",
"attempts",
"to",
"close",
"the",
"Window",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L215-L221 | train |
faiface/pixel | pixelgl/window.go | SetTitle | func (w *Window) SetTitle(title string) {
mainthread.Call(func() {
w.window.SetTitle(title)
})
} | go | func (w *Window) SetTitle(title string) {
mainthread.Call(func() {
w.window.SetTitle(title)
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetTitle",
"(",
"title",
"string",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"w",
".",
"window",
".",
"SetTitle",
"(",
"title",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SetTitle changes the title of the Window. | [
"SetTitle",
"changes",
"the",
"title",
"of",
"the",
"Window",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L224-L228 | train |
faiface/pixel | pixelgl/window.go | SetBounds | func (w *Window) SetBounds(bounds pixel.Rect) {
w.bounds = bounds
mainthread.Call(func() {
_, _, width, height := intBounds(bounds)
w.window.SetSize(width, height)
})
} | go | func (w *Window) SetBounds(bounds pixel.Rect) {
w.bounds = bounds
mainthread.Call(func() {
_, _, width, height := intBounds(bounds)
w.window.SetSize(width, height)
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetBounds",
"(",
"bounds",
"pixel",
".",
"Rect",
")",
"{",
"w",
".",
"bounds",
"=",
"bounds",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"_",
",",
"_",
",",
"width",
",",
"height",
":=",
"intBounds",
"(",
"bounds",
")",
"\n",
"w",
".",
"window",
".",
"SetSize",
"(",
"width",
",",
"height",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SetBounds sets the bounds of the Window in pixels. Bounds can be fractional, but the actual size
// of the window will be rounded to integers. | [
"SetBounds",
"sets",
"the",
"bounds",
"of",
"the",
"Window",
"in",
"pixels",
".",
"Bounds",
"can",
"be",
"fractional",
"but",
"the",
"actual",
"size",
"of",
"the",
"window",
"will",
"be",
"rounded",
"to",
"integers",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L232-L238 | train |
faiface/pixel | pixelgl/window.go | SetPos | func (w *Window) SetPos(pos pixel.Vec) {
mainthread.Call(func() {
left, top := int(pos.X), int(pos.Y)
w.window.SetPos(left, top)
})
} | go | func (w *Window) SetPos(pos pixel.Vec) {
mainthread.Call(func() {
left, top := int(pos.X), int(pos.Y)
w.window.SetPos(left, top)
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetPos",
"(",
"pos",
"pixel",
".",
"Vec",
")",
"{",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"left",
",",
"top",
":=",
"int",
"(",
"pos",
".",
"X",
")",
",",
"int",
"(",
"pos",
".",
"Y",
")",
"\n",
"w",
".",
"window",
".",
"SetPos",
"(",
"left",
",",
"top",
")",
"\n",
"}",
")",
"\n",
"}"
] | // SetPos sets the position, in screen coordinates, of the upper-left corner
// of the client area of the window. Position can be fractional, but the actual position
// of the window will be rounded to integers.
//
// If it is a full screen window, this function does nothing. | [
"SetPos",
"sets",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
".",
"Position",
"can",
"be",
"fractional",
"but",
"the",
"actual",
"position",
"of",
"the",
"window",
"will",
"be",
"rounded",
"to",
"integers",
".",
"If",
"it",
"is",
"a",
"full",
"screen",
"window",
"this",
"function",
"does",
"nothing",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L245-L250 | train |
faiface/pixel | pixelgl/window.go | GetPos | func (w *Window) GetPos() pixel.Vec {
var v pixel.Vec
mainthread.Call(func() {
x, y := w.window.GetPos()
v = pixel.V(float64(x), float64(y))
})
return v
} | go | func (w *Window) GetPos() pixel.Vec {
var v pixel.Vec
mainthread.Call(func() {
x, y := w.window.GetPos()
v = pixel.V(float64(x), float64(y))
})
return v
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"GetPos",
"(",
")",
"pixel",
".",
"Vec",
"{",
"var",
"v",
"pixel",
".",
"Vec",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"x",
",",
"y",
":=",
"w",
".",
"window",
".",
"GetPos",
"(",
")",
"\n",
"v",
"=",
"pixel",
".",
"V",
"(",
"float64",
"(",
"x",
")",
",",
"float64",
"(",
"y",
")",
")",
"\n",
"}",
")",
"\n",
"return",
"v",
"\n",
"}"
] | // GetPos gets the position, in screen coordinates, of the upper-left corner
// of the client area of the window. The position is rounded to integers. | [
"GetPos",
"gets",
"the",
"position",
"in",
"screen",
"coordinates",
"of",
"the",
"upper",
"-",
"left",
"corner",
"of",
"the",
"client",
"area",
"of",
"the",
"window",
".",
"The",
"position",
"is",
"rounded",
"to",
"integers",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L254-L261 | train |
faiface/pixel | pixelgl/window.go | SetMonitor | func (w *Window) SetMonitor(monitor *Monitor) {
if w.Monitor() != monitor {
if monitor != nil {
w.setFullscreen(monitor)
} else {
w.setWindowed()
}
}
} | go | func (w *Window) SetMonitor(monitor *Monitor) {
if w.Monitor() != monitor {
if monitor != nil {
w.setFullscreen(monitor)
} else {
w.setWindowed()
}
}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetMonitor",
"(",
"monitor",
"*",
"Monitor",
")",
"{",
"if",
"w",
".",
"Monitor",
"(",
")",
"!=",
"monitor",
"{",
"if",
"monitor",
"!=",
"nil",
"{",
"w",
".",
"setFullscreen",
"(",
"monitor",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"setWindowed",
"(",
")",
"\n",
"}",
"\n",
"}",
"\n",
"}"
] | // SetMonitor sets the Window fullscreen on the given Monitor. If the Monitor is nil, the Window
// will be restored to windowed state instead.
//
// The Window will be automatically set to the Monitor's resolution. If you want a different
// resolution, you will need to set it manually with SetBounds method. | [
"SetMonitor",
"sets",
"the",
"Window",
"fullscreen",
"on",
"the",
"given",
"Monitor",
".",
"If",
"the",
"Monitor",
"is",
"nil",
"the",
"Window",
"will",
"be",
"restored",
"to",
"windowed",
"state",
"instead",
".",
"The",
"Window",
"will",
"be",
"automatically",
"set",
"to",
"the",
"Monitor",
"s",
"resolution",
".",
"If",
"you",
"want",
"a",
"different",
"resolution",
"you",
"will",
"need",
"to",
"set",
"it",
"manually",
"with",
"SetBounds",
"method",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L304-L312 | train |
faiface/pixel | pixelgl/window.go | Monitor | func (w *Window) Monitor() *Monitor {
var monitor *glfw.Monitor
mainthread.Call(func() {
monitor = w.window.GetMonitor()
})
if monitor == nil {
return nil
}
return &Monitor{
monitor: monitor,
}
} | go | func (w *Window) Monitor() *Monitor {
var monitor *glfw.Monitor
mainthread.Call(func() {
monitor = w.window.GetMonitor()
})
if monitor == nil {
return nil
}
return &Monitor{
monitor: monitor,
}
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Monitor",
"(",
")",
"*",
"Monitor",
"{",
"var",
"monitor",
"*",
"glfw",
".",
"Monitor",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"monitor",
"=",
"w",
".",
"window",
".",
"GetMonitor",
"(",
")",
"\n",
"}",
")",
"\n",
"if",
"monitor",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"return",
"&",
"Monitor",
"{",
"monitor",
":",
"monitor",
",",
"}",
"\n",
"}"
] | // Monitor returns a monitor the Window is fullscreen on. If the Window is not fullscreen, this
// function returns nil. | [
"Monitor",
"returns",
"a",
"monitor",
"the",
"Window",
"is",
"fullscreen",
"on",
".",
"If",
"the",
"Window",
"is",
"not",
"fullscreen",
"this",
"function",
"returns",
"nil",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L316-L327 | train |
faiface/pixel | pixelgl/window.go | Focused | func (w *Window) Focused() bool {
var focused bool
mainthread.Call(func() {
focused = w.window.GetAttrib(glfw.Focused) == glfw.True
})
return focused
} | go | func (w *Window) Focused() bool {
var focused bool
mainthread.Call(func() {
focused = w.window.GetAttrib(glfw.Focused) == glfw.True
})
return focused
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Focused",
"(",
")",
"bool",
"{",
"var",
"focused",
"bool",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"focused",
"=",
"w",
".",
"window",
".",
"GetAttrib",
"(",
"glfw",
".",
"Focused",
")",
"==",
"glfw",
".",
"True",
"\n",
"}",
")",
"\n",
"return",
"focused",
"\n",
"}"
] | // Focused returns true if the Window has input focus. | [
"Focused",
"returns",
"true",
"if",
"the",
"Window",
"has",
"input",
"focus",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L330-L336 | train |
faiface/pixel | pixelgl/window.go | SetCursorVisible | func (w *Window) SetCursorVisible(visible bool) {
w.cursorVisible = visible
mainthread.Call(func() {
if visible {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
})
} | go | func (w *Window) SetCursorVisible(visible bool) {
w.cursorVisible = visible
mainthread.Call(func() {
if visible {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorNormal)
} else {
w.window.SetInputMode(glfw.CursorMode, glfw.CursorHidden)
}
})
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetCursorVisible",
"(",
"visible",
"bool",
")",
"{",
"w",
".",
"cursorVisible",
"=",
"visible",
"\n",
"mainthread",
".",
"Call",
"(",
"func",
"(",
")",
"{",
"if",
"visible",
"{",
"w",
".",
"window",
".",
"SetInputMode",
"(",
"glfw",
".",
"CursorMode",
",",
"glfw",
".",
"CursorNormal",
")",
"\n",
"}",
"else",
"{",
"w",
".",
"window",
".",
"SetInputMode",
"(",
"glfw",
".",
"CursorMode",
",",
"glfw",
".",
"CursorHidden",
")",
"\n",
"}",
"\n",
"}",
")",
"\n",
"}"
] | // SetCursorVisible sets the visibility of the mouse cursor inside the Window client area. | [
"SetCursorVisible",
"sets",
"the",
"visibility",
"of",
"the",
"mouse",
"cursor",
"inside",
"the",
"Window",
"client",
"area",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L349-L358 | train |
faiface/pixel | pixelgl/window.go | MakeTriangles | func (w *Window) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return w.canvas.MakeTriangles(t)
} | go | func (w *Window) MakeTriangles(t pixel.Triangles) pixel.TargetTriangles {
return w.canvas.MakeTriangles(t)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"MakeTriangles",
"(",
"t",
"pixel",
".",
"Triangles",
")",
"pixel",
".",
"TargetTriangles",
"{",
"return",
"w",
".",
"canvas",
".",
"MakeTriangles",
"(",
"t",
")",
"\n",
"}"
] | // MakeTriangles generates a specialized copy of the supplied Triangles that will draw onto this
// Window.
//
// Window supports TrianglesPosition, TrianglesColor and TrianglesPicture. | [
"MakeTriangles",
"generates",
"a",
"specialized",
"copy",
"of",
"the",
"supplied",
"Triangles",
"that",
"will",
"draw",
"onto",
"this",
"Window",
".",
"Window",
"supports",
"TrianglesPosition",
"TrianglesColor",
"and",
"TrianglesPicture",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L382-L384 | train |
faiface/pixel | pixelgl/window.go | MakePicture | func (w *Window) MakePicture(p pixel.Picture) pixel.TargetPicture {
return w.canvas.MakePicture(p)
} | go | func (w *Window) MakePicture(p pixel.Picture) pixel.TargetPicture {
return w.canvas.MakePicture(p)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"MakePicture",
"(",
"p",
"pixel",
".",
"Picture",
")",
"pixel",
".",
"TargetPicture",
"{",
"return",
"w",
".",
"canvas",
".",
"MakePicture",
"(",
"p",
")",
"\n",
"}"
] | // MakePicture generates a specialized copy of the supplied Picture that will draw onto this Window.
//
// Window supports PictureColor. | [
"MakePicture",
"generates",
"a",
"specialized",
"copy",
"of",
"the",
"supplied",
"Picture",
"that",
"will",
"draw",
"onto",
"this",
"Window",
".",
"Window",
"supports",
"PictureColor",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L389-L391 | train |
faiface/pixel | pixelgl/window.go | SetColorMask | func (w *Window) SetColorMask(c color.Color) {
w.canvas.SetColorMask(c)
} | go | func (w *Window) SetColorMask(c color.Color) {
w.canvas.SetColorMask(c)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetColorMask",
"(",
"c",
"color",
".",
"Color",
")",
"{",
"w",
".",
"canvas",
".",
"SetColorMask",
"(",
"c",
")",
"\n",
"}"
] | // SetColorMask sets a global color mask for the Window. | [
"SetColorMask",
"sets",
"a",
"global",
"color",
"mask",
"for",
"the",
"Window",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L399-L401 | train |
faiface/pixel | pixelgl/window.go | SetComposeMethod | func (w *Window) SetComposeMethod(cmp pixel.ComposeMethod) {
w.canvas.SetComposeMethod(cmp)
} | go | func (w *Window) SetComposeMethod(cmp pixel.ComposeMethod) {
w.canvas.SetComposeMethod(cmp)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"SetComposeMethod",
"(",
"cmp",
"pixel",
".",
"ComposeMethod",
")",
"{",
"w",
".",
"canvas",
".",
"SetComposeMethod",
"(",
"cmp",
")",
"\n",
"}"
] | // SetComposeMethod sets a Porter-Duff composition method to be used in the following draws onto
// this Window. | [
"SetComposeMethod",
"sets",
"a",
"Porter",
"-",
"Duff",
"composition",
"method",
"to",
"be",
"used",
"in",
"the",
"following",
"draws",
"onto",
"this",
"Window",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L405-L407 | train |
faiface/pixel | pixelgl/window.go | Clear | func (w *Window) Clear(c color.Color) {
w.canvas.Clear(c)
} | go | func (w *Window) Clear(c color.Color) {
w.canvas.Clear(c)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Clear",
"(",
"c",
"color",
".",
"Color",
")",
"{",
"w",
".",
"canvas",
".",
"Clear",
"(",
"c",
")",
"\n",
"}"
] | // Clear clears the Window with a single color. | [
"Clear",
"clears",
"the",
"Window",
"with",
"a",
"single",
"color",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L422-L424 | train |
faiface/pixel | pixelgl/window.go | Color | func (w *Window) Color(at pixel.Vec) pixel.RGBA {
return w.canvas.Color(at)
} | go | func (w *Window) Color(at pixel.Vec) pixel.RGBA {
return w.canvas.Color(at)
} | [
"func",
"(",
"w",
"*",
"Window",
")",
"Color",
"(",
"at",
"pixel",
".",
"Vec",
")",
"pixel",
".",
"RGBA",
"{",
"return",
"w",
".",
"canvas",
".",
"Color",
"(",
"at",
")",
"\n",
"}"
] | // Color returns the color of the pixel over the given position inside the Window. | [
"Color",
"returns",
"the",
"color",
"of",
"the",
"pixel",
"over",
"the",
"given",
"position",
"inside",
"the",
"Window",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/window.go#L427-L429 | train |
faiface/pixel | text/atlas.go | Contains | func (a *Atlas) Contains(r rune) bool {
_, ok := a.mapping[r]
return ok
} | go | func (a *Atlas) Contains(r rune) bool {
_, ok := a.mapping[r]
return ok
} | [
"func",
"(",
"a",
"*",
"Atlas",
")",
"Contains",
"(",
"r",
"rune",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"a",
".",
"mapping",
"[",
"r",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // Contains reports wheter r in contained within the Atlas. | [
"Contains",
"reports",
"wheter",
"r",
"in",
"contained",
"within",
"the",
"Atlas",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/atlas.go#L108-L111 | train |
faiface/pixel | text/atlas.go | Kern | func (a *Atlas) Kern(r0, r1 rune) float64 {
return i2f(a.face.Kern(r0, r1))
} | go | func (a *Atlas) Kern(r0, r1 rune) float64 {
return i2f(a.face.Kern(r0, r1))
} | [
"func",
"(",
"a",
"*",
"Atlas",
")",
"Kern",
"(",
"r0",
",",
"r1",
"rune",
")",
"float64",
"{",
"return",
"i2f",
"(",
"a",
".",
"face",
".",
"Kern",
"(",
"r0",
",",
"r1",
")",
")",
"\n",
"}"
] | // Kern returns the kerning distance between runes r0 and r1. Positive distance means that the
// glyphs should be further apart. | [
"Kern",
"returns",
"the",
"kerning",
"distance",
"between",
"runes",
"r0",
"and",
"r1",
".",
"Positive",
"distance",
"means",
"that",
"the",
"glyphs",
"should",
"be",
"further",
"apart",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/atlas.go#L120-L122 | train |
faiface/pixel | text/atlas.go | DrawRune | func (a *Atlas) DrawRune(prevR, r rune, dot pixel.Vec) (rect, frame, bounds pixel.Rect, newDot pixel.Vec) {
if !a.Contains(r) {
r = unicode.ReplacementChar
}
if !a.Contains(unicode.ReplacementChar) {
return pixel.Rect{}, pixel.Rect{}, pixel.Rect{}, dot
}
if !a.Contains(prevR) {
prevR = unicode.ReplacementChar
}
if prevR >= 0 {
dot.X += a.Kern(prevR, r)
}
glyph := a.Glyph(r)
rect = glyph.Frame.Moved(dot.Sub(glyph.Dot))
bounds = rect
if bounds.W()*bounds.H() != 0 {
bounds = pixel.R(
bounds.Min.X,
dot.Y-a.Descent(),
bounds.Max.X,
dot.Y+a.Ascent(),
)
}
dot.X += glyph.Advance
return rect, glyph.Frame, bounds, dot
} | go | func (a *Atlas) DrawRune(prevR, r rune, dot pixel.Vec) (rect, frame, bounds pixel.Rect, newDot pixel.Vec) {
if !a.Contains(r) {
r = unicode.ReplacementChar
}
if !a.Contains(unicode.ReplacementChar) {
return pixel.Rect{}, pixel.Rect{}, pixel.Rect{}, dot
}
if !a.Contains(prevR) {
prevR = unicode.ReplacementChar
}
if prevR >= 0 {
dot.X += a.Kern(prevR, r)
}
glyph := a.Glyph(r)
rect = glyph.Frame.Moved(dot.Sub(glyph.Dot))
bounds = rect
if bounds.W()*bounds.H() != 0 {
bounds = pixel.R(
bounds.Min.X,
dot.Y-a.Descent(),
bounds.Max.X,
dot.Y+a.Ascent(),
)
}
dot.X += glyph.Advance
return rect, glyph.Frame, bounds, dot
} | [
"func",
"(",
"a",
"*",
"Atlas",
")",
"DrawRune",
"(",
"prevR",
",",
"r",
"rune",
",",
"dot",
"pixel",
".",
"Vec",
")",
"(",
"rect",
",",
"frame",
",",
"bounds",
"pixel",
".",
"Rect",
",",
"newDot",
"pixel",
".",
"Vec",
")",
"{",
"if",
"!",
"a",
".",
"Contains",
"(",
"r",
")",
"{",
"r",
"=",
"unicode",
".",
"ReplacementChar",
"\n",
"}",
"\n",
"if",
"!",
"a",
".",
"Contains",
"(",
"unicode",
".",
"ReplacementChar",
")",
"{",
"return",
"pixel",
".",
"Rect",
"{",
"}",
",",
"pixel",
".",
"Rect",
"{",
"}",
",",
"pixel",
".",
"Rect",
"{",
"}",
",",
"dot",
"\n",
"}",
"\n",
"if",
"!",
"a",
".",
"Contains",
"(",
"prevR",
")",
"{",
"prevR",
"=",
"unicode",
".",
"ReplacementChar",
"\n",
"}",
"\n\n",
"if",
"prevR",
">=",
"0",
"{",
"dot",
".",
"X",
"+=",
"a",
".",
"Kern",
"(",
"prevR",
",",
"r",
")",
"\n",
"}",
"\n\n",
"glyph",
":=",
"a",
".",
"Glyph",
"(",
"r",
")",
"\n\n",
"rect",
"=",
"glyph",
".",
"Frame",
".",
"Moved",
"(",
"dot",
".",
"Sub",
"(",
"glyph",
".",
"Dot",
")",
")",
"\n",
"bounds",
"=",
"rect",
"\n\n",
"if",
"bounds",
".",
"W",
"(",
")",
"*",
"bounds",
".",
"H",
"(",
")",
"!=",
"0",
"{",
"bounds",
"=",
"pixel",
".",
"R",
"(",
"bounds",
".",
"Min",
".",
"X",
",",
"dot",
".",
"Y",
"-",
"a",
".",
"Descent",
"(",
")",
",",
"bounds",
".",
"Max",
".",
"X",
",",
"dot",
".",
"Y",
"+",
"a",
".",
"Ascent",
"(",
")",
",",
")",
"\n",
"}",
"\n\n",
"dot",
".",
"X",
"+=",
"glyph",
".",
"Advance",
"\n\n",
"return",
"rect",
",",
"glyph",
".",
"Frame",
",",
"bounds",
",",
"dot",
"\n",
"}"
] | // DrawRune returns parameters necessary for drawing a rune glyph.
//
// Rect is a rectangle where the glyph should be positioned. Frame is the glyph frame inside the
// Atlas's Picture. NewDot is the new position of the dot. | [
"DrawRune",
"returns",
"parameters",
"necessary",
"for",
"drawing",
"a",
"rune",
"glyph",
".",
"Rect",
"is",
"a",
"rectangle",
"where",
"the",
"glyph",
"should",
"be",
"positioned",
".",
"Frame",
"is",
"the",
"glyph",
"frame",
"inside",
"the",
"Atlas",
"s",
"Picture",
".",
"NewDot",
"is",
"the",
"new",
"position",
"of",
"the",
"dot",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/atlas.go#L143-L175 | train |
faiface/pixel | text/atlas.go | makeSquareMapping | func makeSquareMapping(face font.Face, runes []rune, padding fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
width := sort.Search(int(fixed.I(1024*1024)), func(i int) bool {
width := fixed.Int26_6(i)
_, bounds := makeMapping(face, runes, padding, width)
return bounds.Max.X-bounds.Min.X >= bounds.Max.Y-bounds.Min.Y
})
return makeMapping(face, runes, padding, fixed.Int26_6(width))
} | go | func makeSquareMapping(face font.Face, runes []rune, padding fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
width := sort.Search(int(fixed.I(1024*1024)), func(i int) bool {
width := fixed.Int26_6(i)
_, bounds := makeMapping(face, runes, padding, width)
return bounds.Max.X-bounds.Min.X >= bounds.Max.Y-bounds.Min.Y
})
return makeMapping(face, runes, padding, fixed.Int26_6(width))
} | [
"func",
"makeSquareMapping",
"(",
"face",
"font",
".",
"Face",
",",
"runes",
"[",
"]",
"rune",
",",
"padding",
"fixed",
".",
"Int26_6",
")",
"(",
"map",
"[",
"rune",
"]",
"fixedGlyph",
",",
"fixed",
".",
"Rectangle26_6",
")",
"{",
"width",
":=",
"sort",
".",
"Search",
"(",
"int",
"(",
"fixed",
".",
"I",
"(",
"1024",
"*",
"1024",
")",
")",
",",
"func",
"(",
"i",
"int",
")",
"bool",
"{",
"width",
":=",
"fixed",
".",
"Int26_6",
"(",
"i",
")",
"\n",
"_",
",",
"bounds",
":=",
"makeMapping",
"(",
"face",
",",
"runes",
",",
"padding",
",",
"width",
")",
"\n",
"return",
"bounds",
".",
"Max",
".",
"X",
"-",
"bounds",
".",
"Min",
".",
"X",
">=",
"bounds",
".",
"Max",
".",
"Y",
"-",
"bounds",
".",
"Min",
".",
"Y",
"\n",
"}",
")",
"\n",
"return",
"makeMapping",
"(",
"face",
",",
"runes",
",",
"padding",
",",
"fixed",
".",
"Int26_6",
"(",
"width",
")",
")",
"\n",
"}"
] | // makeSquareMapping finds an optimal glyph arrangement of the given runes, so that their common
// bounding box is as square as possible. | [
"makeSquareMapping",
"finds",
"an",
"optimal",
"glyph",
"arrangement",
"of",
"the",
"given",
"runes",
"so",
"that",
"their",
"common",
"bounding",
"box",
"is",
"as",
"square",
"as",
"possible",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/atlas.go#L185-L192 | train |
faiface/pixel | text/atlas.go | makeMapping | func makeMapping(face font.Face, runes []rune, padding, width fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
mapping := make(map[rune]fixedGlyph)
bounds := fixed.Rectangle26_6{}
dot := fixed.P(0, 0)
for _, r := range runes {
b, advance, ok := face.GlyphBounds(r)
if !ok {
fmt.Println(r)
continue
}
// this is important for drawing, artifacts arise otherwise
frame := fixed.Rectangle26_6{
Min: fixed.P(b.Min.X.Floor(), b.Min.Y.Floor()),
Max: fixed.P(b.Max.X.Ceil(), b.Max.Y.Ceil()),
}
dot.X -= frame.Min.X
frame = frame.Add(dot)
mapping[r] = fixedGlyph{
dot: dot,
frame: frame,
advance: advance,
}
bounds = bounds.Union(frame)
dot.X = frame.Max.X
// padding + align to integer
dot.X += padding
dot.X = fixed.I(dot.X.Ceil())
// width exceeded, new row
if frame.Max.X >= width {
dot.X = 0
dot.Y += face.Metrics().Ascent + face.Metrics().Descent
// padding + align to integer
dot.Y += padding
dot.Y = fixed.I(dot.Y.Ceil())
}
}
return mapping, bounds
} | go | func makeMapping(face font.Face, runes []rune, padding, width fixed.Int26_6) (map[rune]fixedGlyph, fixed.Rectangle26_6) {
mapping := make(map[rune]fixedGlyph)
bounds := fixed.Rectangle26_6{}
dot := fixed.P(0, 0)
for _, r := range runes {
b, advance, ok := face.GlyphBounds(r)
if !ok {
fmt.Println(r)
continue
}
// this is important for drawing, artifacts arise otherwise
frame := fixed.Rectangle26_6{
Min: fixed.P(b.Min.X.Floor(), b.Min.Y.Floor()),
Max: fixed.P(b.Max.X.Ceil(), b.Max.Y.Ceil()),
}
dot.X -= frame.Min.X
frame = frame.Add(dot)
mapping[r] = fixedGlyph{
dot: dot,
frame: frame,
advance: advance,
}
bounds = bounds.Union(frame)
dot.X = frame.Max.X
// padding + align to integer
dot.X += padding
dot.X = fixed.I(dot.X.Ceil())
// width exceeded, new row
if frame.Max.X >= width {
dot.X = 0
dot.Y += face.Metrics().Ascent + face.Metrics().Descent
// padding + align to integer
dot.Y += padding
dot.Y = fixed.I(dot.Y.Ceil())
}
}
return mapping, bounds
} | [
"func",
"makeMapping",
"(",
"face",
"font",
".",
"Face",
",",
"runes",
"[",
"]",
"rune",
",",
"padding",
",",
"width",
"fixed",
".",
"Int26_6",
")",
"(",
"map",
"[",
"rune",
"]",
"fixedGlyph",
",",
"fixed",
".",
"Rectangle26_6",
")",
"{",
"mapping",
":=",
"make",
"(",
"map",
"[",
"rune",
"]",
"fixedGlyph",
")",
"\n",
"bounds",
":=",
"fixed",
".",
"Rectangle26_6",
"{",
"}",
"\n\n",
"dot",
":=",
"fixed",
".",
"P",
"(",
"0",
",",
"0",
")",
"\n\n",
"for",
"_",
",",
"r",
":=",
"range",
"runes",
"{",
"b",
",",
"advance",
",",
"ok",
":=",
"face",
".",
"GlyphBounds",
"(",
"r",
")",
"\n",
"if",
"!",
"ok",
"{",
"fmt",
".",
"Println",
"(",
"r",
")",
"\n",
"continue",
"\n",
"}",
"\n\n",
"// this is important for drawing, artifacts arise otherwise",
"frame",
":=",
"fixed",
".",
"Rectangle26_6",
"{",
"Min",
":",
"fixed",
".",
"P",
"(",
"b",
".",
"Min",
".",
"X",
".",
"Floor",
"(",
")",
",",
"b",
".",
"Min",
".",
"Y",
".",
"Floor",
"(",
")",
")",
",",
"Max",
":",
"fixed",
".",
"P",
"(",
"b",
".",
"Max",
".",
"X",
".",
"Ceil",
"(",
")",
",",
"b",
".",
"Max",
".",
"Y",
".",
"Ceil",
"(",
")",
")",
",",
"}",
"\n\n",
"dot",
".",
"X",
"-=",
"frame",
".",
"Min",
".",
"X",
"\n",
"frame",
"=",
"frame",
".",
"Add",
"(",
"dot",
")",
"\n\n",
"mapping",
"[",
"r",
"]",
"=",
"fixedGlyph",
"{",
"dot",
":",
"dot",
",",
"frame",
":",
"frame",
",",
"advance",
":",
"advance",
",",
"}",
"\n",
"bounds",
"=",
"bounds",
".",
"Union",
"(",
"frame",
")",
"\n\n",
"dot",
".",
"X",
"=",
"frame",
".",
"Max",
".",
"X",
"\n\n",
"// padding + align to integer",
"dot",
".",
"X",
"+=",
"padding",
"\n",
"dot",
".",
"X",
"=",
"fixed",
".",
"I",
"(",
"dot",
".",
"X",
".",
"Ceil",
"(",
")",
")",
"\n\n",
"// width exceeded, new row",
"if",
"frame",
".",
"Max",
".",
"X",
">=",
"width",
"{",
"dot",
".",
"X",
"=",
"0",
"\n",
"dot",
".",
"Y",
"+=",
"face",
".",
"Metrics",
"(",
")",
".",
"Ascent",
"+",
"face",
".",
"Metrics",
"(",
")",
".",
"Descent",
"\n\n",
"// padding + align to integer",
"dot",
".",
"Y",
"+=",
"padding",
"\n",
"dot",
".",
"Y",
"=",
"fixed",
".",
"I",
"(",
"dot",
".",
"Y",
".",
"Ceil",
"(",
")",
")",
"\n",
"}",
"\n",
"}",
"\n\n",
"return",
"mapping",
",",
"bounds",
"\n",
"}"
] | // makeMapping arranges glyphs of the given runes into rows in such a way, that no glyph is located
// fully to the right of the specified width. Specifically, it places glyphs in a row one by one and
// once it reaches the specified width, it starts a new row. | [
"makeMapping",
"arranges",
"glyphs",
"of",
"the",
"given",
"runes",
"into",
"rows",
"in",
"such",
"a",
"way",
"that",
"no",
"glyph",
"is",
"located",
"fully",
"to",
"the",
"right",
"of",
"the",
"specified",
"width",
".",
"Specifically",
"it",
"places",
"glyphs",
"in",
"a",
"row",
"one",
"by",
"one",
"and",
"once",
"it",
"reaches",
"the",
"specified",
"width",
"it",
"starts",
"a",
"new",
"row",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/text/atlas.go#L197-L244 | train |
faiface/pixel | pixelgl/canvas.go | NewCanvas | func NewCanvas(bounds pixel.Rect) *Canvas {
c := &Canvas{
gf: NewGLFrame(bounds),
mat: mgl32.Ident3(),
col: mgl32.Vec4{1, 1, 1, 1},
}
baseShader(c)
c.SetBounds(bounds)
c.shader.update()
return c
} | go | func NewCanvas(bounds pixel.Rect) *Canvas {
c := &Canvas{
gf: NewGLFrame(bounds),
mat: mgl32.Ident3(),
col: mgl32.Vec4{1, 1, 1, 1},
}
baseShader(c)
c.SetBounds(bounds)
c.shader.update()
return c
} | [
"func",
"NewCanvas",
"(",
"bounds",
"pixel",
".",
"Rect",
")",
"*",
"Canvas",
"{",
"c",
":=",
"&",
"Canvas",
"{",
"gf",
":",
"NewGLFrame",
"(",
"bounds",
")",
",",
"mat",
":",
"mgl32",
".",
"Ident3",
"(",
")",
",",
"col",
":",
"mgl32",
".",
"Vec4",
"{",
"1",
",",
"1",
",",
"1",
",",
"1",
"}",
",",
"}",
"\n\n",
"baseShader",
"(",
"c",
")",
"\n",
"c",
".",
"SetBounds",
"(",
"bounds",
")",
"\n",
"c",
".",
"shader",
".",
"update",
"(",
")",
"\n",
"return",
"c",
"\n",
"}"
] | // NewCanvas creates a new empty, fully transparent Canvas with given bounds. | [
"NewCanvas",
"creates",
"a",
"new",
"empty",
"fully",
"transparent",
"Canvas",
"with",
"given",
"bounds",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/canvas.go#L33-L44 | train |
faiface/pixel | pixelgl/canvas.go | SetUniform | func (c *Canvas) SetUniform(name string, value interface{}) {
c.shader.setUniform(name, value)
} | go | func (c *Canvas) SetUniform(name string, value interface{}) {
c.shader.setUniform(name, value)
} | [
"func",
"(",
"c",
"*",
"Canvas",
")",
"SetUniform",
"(",
"name",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"c",
".",
"shader",
".",
"setUniform",
"(",
"name",
",",
"value",
")",
"\n",
"}"
] | // SetUniform will update the named uniform with the value of any supported underlying
// attribute variable. If the uniform already exists, including defaults, they will be reassigned
// to the new value. The value can be a pointer. | [
"SetUniform",
"will",
"update",
"the",
"named",
"uniform",
"with",
"the",
"value",
"of",
"any",
"supported",
"underlying",
"attribute",
"variable",
".",
"If",
"the",
"uniform",
"already",
"exists",
"including",
"defaults",
"they",
"will",
"be",
"reassigned",
"to",
"the",
"new",
"value",
".",
"The",
"value",
"can",
"be",
"a",
"pointer",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/canvas.go#L49-L51 | train |
faiface/pixel | pixelgl/canvas.go | SetFragmentShader | func (c *Canvas) SetFragmentShader(src string) {
c.shader.fs = src
c.shader.update()
} | go | func (c *Canvas) SetFragmentShader(src string) {
c.shader.fs = src
c.shader.update()
} | [
"func",
"(",
"c",
"*",
"Canvas",
")",
"SetFragmentShader",
"(",
"src",
"string",
")",
"{",
"c",
".",
"shader",
".",
"fs",
"=",
"src",
"\n",
"c",
".",
"shader",
".",
"update",
"(",
")",
"\n",
"}"
] | // SetFragmentShader allows you to set a new fragment shader on the underlying
// framebuffer. Argument "src" is the GLSL source, not a filename. | [
"SetFragmentShader",
"allows",
"you",
"to",
"set",
"a",
"new",
"fragment",
"shader",
"on",
"the",
"underlying",
"framebuffer",
".",
"Argument",
"src",
"is",
"the",
"GLSL",
"source",
"not",
"a",
"filename",
"."
] | a68a4e38b42dde3869de57fddbaea6da106d5940 | https://github.com/faiface/pixel/blob/a68a4e38b42dde3869de57fddbaea6da106d5940/pixelgl/canvas.go#L55-L58 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.