id int32 0 167k | repo stringlengths 5 54 | path stringlengths 4 155 | func_name stringlengths 1 118 | original_string stringlengths 52 85.5k | language stringclasses 1
value | code stringlengths 52 85.5k | code_tokens list | docstring stringlengths 6 2.61k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 85 252 |
|---|---|---|---|---|---|---|---|---|---|---|---|
147,400 | pankona/gomo-simra | examples/sample3/scene/obstacle.go | setPosition | func (o *Obstacle) setPosition(x, y float32) {
o.SetPosition(x, y)
} | go | func (o *Obstacle) setPosition(x, y float32) {
o.SetPosition(x, y)
} | [
"func",
"(",
"o",
"*",
"Obstacle",
")",
"setPosition",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"o",
".",
"SetPosition",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | /**
* Obstacle implementation for Model interface
*/ | [
"Obstacle",
"implementation",
"for",
"Model",
"interface"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/obstacle.go#L28-L30 |
147,401 | threatgrid/jqpipe-go | jqpipe.go | Eval | func Eval(js string, expr string, opts ...string) ([]json.RawMessage, error) {
jq, err := New(bytes.NewReader([]byte(js)), expr, opts...)
if err != nil {
return nil, err
}
ret := make([]json.RawMessage, 0, 16)
for {
next, err := jq.Next()
switch err {
case nil:
ret = append(ret, next)
case io.EOF:
... | go | func Eval(js string, expr string, opts ...string) ([]json.RawMessage, error) {
jq, err := New(bytes.NewReader([]byte(js)), expr, opts...)
if err != nil {
return nil, err
}
ret := make([]json.RawMessage, 0, 16)
for {
next, err := jq.Next()
switch err {
case nil:
ret = append(ret, next)
case io.EOF:
... | [
"func",
"Eval",
"(",
"js",
"string",
",",
"expr",
"string",
",",
"opts",
"...",
"string",
")",
"(",
"[",
"]",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"jq",
",",
"err",
":=",
"New",
"(",
"bytes",
".",
"NewReader",
"(",
"[",
"]",
"byte",... | // Eval starts a new Jq process to evaluate an expression with json input | [
"Eval",
"starts",
"a",
"new",
"Jq",
"process",
"to",
"evaluate",
"an",
"expression",
"with",
"json",
"input"
] | b5e15fb6d9f3f85353573236105b501a4ace0ccc | https://github.com/threatgrid/jqpipe-go/blob/b5e15fb6d9f3f85353573236105b501a4ace0ccc/jqpipe.go#L20-L39 |
147,402 | threatgrid/jqpipe-go | jqpipe.go | New | func New(r io.Reader, expr string, opts ...string) (*Pipe, error) {
var err error
proc := new(Pipe)
opts = append(opts, expr)
proc.jq = exec.Command("jq", opts...)
proc.jq.Stdin = r
proc.stdout, err = proc.jq.StdoutPipe()
if err != nil {
return nil, err
}
proc.jq.Stderr = &proc.stderr
err = proc.jq.Start... | go | func New(r io.Reader, expr string, opts ...string) (*Pipe, error) {
var err error
proc := new(Pipe)
opts = append(opts, expr)
proc.jq = exec.Command("jq", opts...)
proc.jq.Stdin = r
proc.stdout, err = proc.jq.StdoutPipe()
if err != nil {
return nil, err
}
proc.jq.Stderr = &proc.stderr
err = proc.jq.Start... | [
"func",
"New",
"(",
"r",
"io",
".",
"Reader",
",",
"expr",
"string",
",",
"opts",
"...",
"string",
")",
"(",
"*",
"Pipe",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n\n",
"proc",
":=",
"new",
"(",
"Pipe",
")",
"\n",
"opts",
"=",
"append",
... | // New wraps a jq.Pipe around an existing io.Reader, applying a JQ expression | [
"New",
"wraps",
"a",
"jq",
".",
"Pipe",
"around",
"an",
"existing",
"io",
".",
"Reader",
"applying",
"a",
"JQ",
"expression"
] | b5e15fb6d9f3f85353573236105b501a4ace0ccc | https://github.com/threatgrid/jqpipe-go/blob/b5e15fb6d9f3f85353573236105b501a4ace0ccc/jqpipe.go#L42-L64 |
147,403 | threatgrid/jqpipe-go | jqpipe.go | Next | func (p *Pipe) Next() (json.RawMessage, error) {
var msg json.RawMessage
err := p.dec.Decode(&msg)
//TODO: guard against a Next() after we have terminated.
if err == nil {
return msg, nil
}
p.stdout.Close()
// if we have a decoding error, jq is sick and we need to kill it with fire..
if err != io.EOF {
p.... | go | func (p *Pipe) Next() (json.RawMessage, error) {
var msg json.RawMessage
err := p.dec.Decode(&msg)
//TODO: guard against a Next() after we have terminated.
if err == nil {
return msg, nil
}
p.stdout.Close()
// if we have a decoding error, jq is sick and we need to kill it with fire..
if err != io.EOF {
p.... | [
"func",
"(",
"p",
"*",
"Pipe",
")",
"Next",
"(",
")",
"(",
"json",
".",
"RawMessage",
",",
"error",
")",
"{",
"var",
"msg",
"json",
".",
"RawMessage",
"\n",
"err",
":=",
"p",
".",
"dec",
".",
"Decode",
"(",
"&",
"msg",
")",
"\n\n",
"//TODO: guard... | // Next provides the next JSON result from JQ. If there are no more results, io.EOF is returned. | [
"Next",
"provides",
"the",
"next",
"JSON",
"result",
"from",
"JQ",
".",
"If",
"there",
"are",
"no",
"more",
"results",
"io",
".",
"EOF",
"is",
"returned",
"."
] | b5e15fb6d9f3f85353573236105b501a4ace0ccc | https://github.com/threatgrid/jqpipe-go/blob/b5e15fb6d9f3f85353573236105b501a4ace0ccc/jqpipe.go#L75-L105 |
147,404 | threatgrid/jqpipe-go | jqpipe.go | Close | func (p *Pipe) Close() error {
if p.stdout != nil {
p.stdout.Close()
}
if p.jq == nil {
return nil
}
if p.jq.ProcessState != nil && p.jq.ProcessState.Exited() {
return nil
}
if p.jq.Process != nil {
p.jq.Process.Kill()
go p.jq.Process.Wait()
}
return nil
} | go | func (p *Pipe) Close() error {
if p.stdout != nil {
p.stdout.Close()
}
if p.jq == nil {
return nil
}
if p.jq.ProcessState != nil && p.jq.ProcessState.Exited() {
return nil
}
if p.jq.Process != nil {
p.jq.Process.Kill()
go p.jq.Process.Wait()
}
return nil
} | [
"func",
"(",
"p",
"*",
"Pipe",
")",
"Close",
"(",
")",
"error",
"{",
"if",
"p",
".",
"stdout",
"!=",
"nil",
"{",
"p",
".",
"stdout",
".",
"Close",
"(",
")",
"\n",
"}",
"\n",
"if",
"p",
".",
"jq",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}"... | // Close attempts to halt the jq process if it has not already exited. This is only necessary if Next has not returned io.EOF. | [
"Close",
"attempts",
"to",
"halt",
"the",
"jq",
"process",
"if",
"it",
"has",
"not",
"already",
"exited",
".",
"This",
"is",
"only",
"necessary",
"if",
"Next",
"has",
"not",
"returned",
"io",
".",
"EOF",
"."
] | b5e15fb6d9f3f85353573236105b501a4ace0ccc | https://github.com/threatgrid/jqpipe-go/blob/b5e15fb6d9f3f85353573236105b501a4ace0ccc/jqpipe.go#L108-L123 |
147,405 | pankona/gomo-simra | examples/sample3/scene/sample.go | OnTouchEnd | func (s *sample) OnTouchEnd(x, y float32) {
s.isTouching = false
if s.gamestate == readyToStart {
s.gamestate = started
s.removeReadyText()
} else if s.gamestate == readyToRestart {
// TODO: methodize
s.resetPosition()
s.views.restart()
s.models.restart()
tex := s.simra.NewImageTexture("heart.png", i... | go | func (s *sample) OnTouchEnd(x, y float32) {
s.isTouching = false
if s.gamestate == readyToStart {
s.gamestate = started
s.removeReadyText()
} else if s.gamestate == readyToRestart {
// TODO: methodize
s.resetPosition()
s.views.restart()
s.models.restart()
tex := s.simra.NewImageTexture("heart.png", i... | [
"func",
"(",
"s",
"*",
"sample",
")",
"OnTouchEnd",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"s",
".",
"isTouching",
"=",
"false",
"\n\n",
"if",
"s",
".",
"gamestate",
"==",
"readyToStart",
"{",
"s",
".",
"gamestate",
"=",
"started",
"\n",
"s",
"."... | // OnTouchEnd is called when sample scene is Touched and it is released. | [
"OnTouchEnd",
"is",
"called",
"when",
"sample",
"scene",
"is",
"Touched",
"and",
"it",
"is",
"released",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/sample.go#L91-L118 |
147,406 | pankona/gomo-simra | simra/internal/peer/touch.go | RemoveTouchListener | func (tp *TouchPeer) RemoveTouchListener(listener TouchListener) {
simlog.FuncIn()
tp.touchListeners = remove(tp.touchListeners, listener)
simlog.FuncOut()
} | go | func (tp *TouchPeer) RemoveTouchListener(listener TouchListener) {
simlog.FuncIn()
tp.touchListeners = remove(tp.touchListeners, listener)
simlog.FuncOut()
} | [
"func",
"(",
"tp",
"*",
"TouchPeer",
")",
"RemoveTouchListener",
"(",
"listener",
"TouchListener",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"tp",
".",
"touchListeners",
"=",
"remove",
"(",
"tp",
".",
"touchListeners",
",",
"listener",
")",
"\n",
... | // RemoveTouchListener removes specified listener. | [
"RemoveTouchListener",
"removes",
"specified",
"listener",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/touch.go#L66-L70 |
147,407 | pankona/gomo-simra | simra/internal/peer/touch.go | RemoveAllTouchListeners | func (tp *TouchPeer) RemoveAllTouchListeners() {
simlog.FuncIn()
tp.touchListeners = nil
simlog.FuncOut()
} | go | func (tp *TouchPeer) RemoveAllTouchListeners() {
simlog.FuncIn()
tp.touchListeners = nil
simlog.FuncOut()
} | [
"func",
"(",
"tp",
"*",
"TouchPeer",
")",
"RemoveAllTouchListeners",
"(",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"tp",
".",
"touchListeners",
"=",
"nil",
"\n",
"simlog",
".",
"FuncOut",
"(",
")",
"\n",
"}"
] | // RemoveAllTouchListeners removes all registered listeners. | [
"RemoveAllTouchListeners",
"removes",
"all",
"registered",
"listeners",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/touch.go#L73-L77 |
147,408 | pankona/gomo-simra | examples/sample3/scene/views.go | Progress | func (views *views) Progress(isKeyTouching bool) {
if !views.isDead {
return
}
views.move()
_, py := views.ball.getPosition()
if py == 0 {
if views.elapsedDeadFrame > waitFrameAfterDead {
for _, v := range views.listeners {
v.onFinishDead()
views.isDead = false
views.elapsedDeadFrame = 0
}
... | go | func (views *views) Progress(isKeyTouching bool) {
if !views.isDead {
return
}
views.move()
_, py := views.ball.getPosition()
if py == 0 {
if views.elapsedDeadFrame > waitFrameAfterDead {
for _, v := range views.listeners {
v.onFinishDead()
views.isDead = false
views.elapsedDeadFrame = 0
}
... | [
"func",
"(",
"views",
"*",
"views",
")",
"Progress",
"(",
"isKeyTouching",
"bool",
")",
"{",
"if",
"!",
"views",
".",
"isDead",
"{",
"return",
"\n",
"}",
"\n\n",
"views",
".",
"move",
"(",
")",
"\n\n",
"_",
",",
"py",
":=",
"views",
".",
"ball",
... | // Progress progresses the time of views 1 frame | [
"Progress",
"progresses",
"the",
"time",
"of",
"views",
"1",
"frame"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/views.go#L47-L66 |
147,409 | pankona/gomo-simra | examples/sample3/scene/views.go | onDead | func (views *views) onDead() {
views.isDead = true
ball := views.ball
dx := ball.getSpeed() * math.Cos(ball.getDirection()*math.Pi/180)
dy := float64(0)
dx -= 3
ball.setSpeed(math.Sqrt(dx*dx + dy*dy))
ball.setDirection(math.Atan2(dy, dx) * 180 / math.Pi)
} | go | func (views *views) onDead() {
views.isDead = true
ball := views.ball
dx := ball.getSpeed() * math.Cos(ball.getDirection()*math.Pi/180)
dy := float64(0)
dx -= 3
ball.setSpeed(math.Sqrt(dx*dx + dy*dy))
ball.setDirection(math.Atan2(dy, dx) * 180 / math.Pi)
} | [
"func",
"(",
"views",
"*",
"views",
")",
"onDead",
"(",
")",
"{",
"views",
".",
"isDead",
"=",
"true",
"\n\n",
"ball",
":=",
"views",
".",
"ball",
"\n\n",
"dx",
":=",
"ball",
".",
"getSpeed",
"(",
")",
"*",
"math",
".",
"Cos",
"(",
"ball",
".",
... | // event notification from view | [
"event",
"notification",
"from",
"view"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/views.go#L74-L84 |
147,410 | pankona/gomo-simra | simra/internal/peer/gomobile.go | Initialize | func (g *Gomo) Initialize(onStart func(glc *GLContext), onStop func(), updateCallback func()) {
simlog.FuncIn()
g.onStart = onStart
g.onStop = onStop
g.updateCallback = updateCallback
g.screensize = screensize
simlog.FuncOut()
} | go | func (g *Gomo) Initialize(onStart func(glc *GLContext), onStop func(), updateCallback func()) {
simlog.FuncIn()
g.onStart = onStart
g.onStop = onStop
g.updateCallback = updateCallback
g.screensize = screensize
simlog.FuncOut()
} | [
"func",
"(",
"g",
"*",
"Gomo",
")",
"Initialize",
"(",
"onStart",
"func",
"(",
"glc",
"*",
"GLContext",
")",
",",
"onStop",
"func",
"(",
")",
",",
"updateCallback",
"func",
"(",
")",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"g",
".",
"o... | // Initialize initializes Gomo. | [
"Initialize",
"initializes",
"Gomo",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gomobile.go#L47-L54 |
147,411 | pankona/gomo-simra | simra/internal/peer/gomobile.go | Start | func (g *Gomo) Start() {
simlog.FuncIn()
app.Main(func(a app.App) {
g.app = a
for e := range a.Events() {
g.handleEvent(e)
}
})
simlog.FuncOut()
} | go | func (g *Gomo) Start() {
simlog.FuncIn()
app.Main(func(a app.App) {
g.app = a
for e := range a.Events() {
g.handleEvent(e)
}
})
simlog.FuncOut()
} | [
"func",
"(",
"g",
"*",
"Gomo",
")",
"Start",
"(",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"app",
".",
"Main",
"(",
"func",
"(",
"a",
"app",
".",
"App",
")",
"{",
"g",
".",
"app",
"=",
"a",
"\n",
"for",
"e",
":=",
"range",
"a",
... | // Start starts gomobile's main loop.
// Most of events handled by peer is fired by this function. | [
"Start",
"starts",
"gomobile",
"s",
"main",
"loop",
".",
"Most",
"of",
"events",
"handled",
"by",
"peer",
"is",
"fired",
"by",
"this",
"function",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gomobile.go#L110-L119 |
147,412 | pankona/gomo-simra | examples/sample1/scene/sample1.go | Initialize | func (s *sample) Initialize(sim simra.Simraer) {
s.simra = sim
s.simra.SetDesiredScreenSize(1080/2, 1920/2)
s.initSprite()
} | go | func (s *sample) Initialize(sim simra.Simraer) {
s.simra = sim
s.simra.SetDesiredScreenSize(1080/2, 1920/2)
s.initSprite()
} | [
"func",
"(",
"s",
"*",
"sample",
")",
"Initialize",
"(",
"sim",
"simra",
".",
"Simraer",
")",
"{",
"s",
".",
"simra",
"=",
"sim",
"\n",
"s",
".",
"simra",
".",
"SetDesiredScreenSize",
"(",
"1080",
"/",
"2",
",",
"1920",
"/",
"2",
")",
"\n",
"s",
... | // Initialize initializes sample scene.
// This is called from simra.
// simra.SetDesiredScreenSize should be called to determine
// screen size of this scene.
// If SetDesiredScreenSize is already called in previous scene, this scene may not call the function. | [
"Initialize",
"initializes",
"sample",
"scene",
".",
"This",
"is",
"called",
"from",
"simra",
".",
"simra",
".",
"SetDesiredScreenSize",
"should",
"be",
"called",
"to",
"determine",
"screen",
"size",
"of",
"this",
"scene",
".",
"If",
"SetDesiredScreenSize",
"is"... | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample1/scene/sample1.go#L21-L25 |
147,413 | apoorvam/goterminal | writer.go | New | func New(out io.Writer) *Writer {
writer := &Writer{Out: out}
if termWidth == 0 {
termWidth, _ = writer.GetTermDimensions()
}
return writer
} | go | func New(out io.Writer) *Writer {
writer := &Writer{Out: out}
if termWidth == 0 {
termWidth, _ = writer.GetTermDimensions()
}
return writer
} | [
"func",
"New",
"(",
"out",
"io",
".",
"Writer",
")",
"*",
"Writer",
"{",
"writer",
":=",
"&",
"Writer",
"{",
"Out",
":",
"out",
"}",
"\n",
"if",
"termWidth",
"==",
"0",
"{",
"termWidth",
",",
"_",
"=",
"writer",
".",
"GetTermDimensions",
"(",
")",
... | // New returns a new instance of the Writer. It initializes the terminal width and buffer. | [
"New",
"returns",
"a",
"new",
"instance",
"of",
"the",
"Writer",
".",
"It",
"initializes",
"the",
"terminal",
"width",
"and",
"buffer",
"."
] | 614d345c47e510f5bc95fef660f25d0c00d224e4 | https://github.com/apoorvam/goterminal/blob/614d345c47e510f5bc95fef660f25d0c00d224e4/writer.go#L23-L29 |
147,414 | apoorvam/goterminal | writer.go | Reset | func (w *Writer) Reset() {
w.mtx.Lock()
defer w.mtx.Unlock()
w.Buf.Reset()
w.lineCount = 0
} | go | func (w *Writer) Reset() {
w.mtx.Lock()
defer w.mtx.Unlock()
w.Buf.Reset()
w.lineCount = 0
} | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Reset",
"(",
")",
"{",
"w",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"w",
".",
"Buf",
".",
"Reset",
"(",
")",
"\n",
"w",
".",
"lineCount",
"=",
... | // Reset resets the Writer. | [
"Reset",
"resets",
"the",
"Writer",
"."
] | 614d345c47e510f5bc95fef660f25d0c00d224e4 | https://github.com/apoorvam/goterminal/blob/614d345c47e510f5bc95fef660f25d0c00d224e4/writer.go#L32-L37 |
147,415 | apoorvam/goterminal | writer.go | Print | func (w *Writer) Print() error {
w.mtx.Lock()
defer w.mtx.Unlock()
// do nothing if buffer is empty
if len(w.Buf.Bytes()) == 0 {
return nil
}
var currentLine bytes.Buffer
for _, b := range w.Buf.Bytes() {
if b == '\n' {
w.lineCount++
currentLine.Reset()
} else {
currentLine.Write([]byte{b})
if... | go | func (w *Writer) Print() error {
w.mtx.Lock()
defer w.mtx.Unlock()
// do nothing if buffer is empty
if len(w.Buf.Bytes()) == 0 {
return nil
}
var currentLine bytes.Buffer
for _, b := range w.Buf.Bytes() {
if b == '\n' {
w.lineCount++
currentLine.Reset()
} else {
currentLine.Write([]byte{b})
if... | [
"func",
"(",
"w",
"*",
"Writer",
")",
"Print",
"(",
")",
"error",
"{",
"w",
".",
"mtx",
".",
"Lock",
"(",
")",
"\n",
"defer",
"w",
".",
"mtx",
".",
"Unlock",
"(",
")",
"\n",
"// do nothing if buffer is empty",
"if",
"len",
"(",
"w",
".",
"Buf",
"... | // Print writes the buffer contents to Out and resets the buffer.
// It stores the number of lines to go up the Writer in the Writer.lineCount. | [
"Print",
"writes",
"the",
"buffer",
"contents",
"to",
"Out",
"and",
"resets",
"the",
"buffer",
".",
"It",
"stores",
"the",
"number",
"of",
"lines",
"to",
"go",
"up",
"the",
"Writer",
"in",
"the",
"Writer",
".",
"lineCount",
"."
] | 614d345c47e510f5bc95fef660f25d0c00d224e4 | https://github.com/apoorvam/goterminal/blob/614d345c47e510f5bc95fef660f25d0c00d224e4/writer.go#L41-L65 |
147,416 | pankona/gomo-simra | simra/simlog/log.go | Debugf | func (l *logger) Debugf(format string, a ...interface{}) {
if !l.isDebug {
return
}
l.printLog("[DEBUG]", format, a...)
} | go | func (l *logger) Debugf(format string, a ...interface{}) {
if !l.isDebug {
return
}
l.printLog("[DEBUG]", format, a...)
} | [
"func",
"(",
"l",
"*",
"logger",
")",
"Debugf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"l",
".",
"isDebug",
"{",
"return",
"\n",
"}",
"\n",
"l",
".",
"printLog",
"(",
"\"",
"\"",
",",
"format",
","... | // Debugf shows debug log with specified format and arguments | [
"Debugf",
"shows",
"debug",
"log",
"with",
"specified",
"format",
"and",
"arguments"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simlog/log.go#L75-L80 |
147,417 | pankona/gomo-simra | simra/simlog/log.go | Errorf | func (l *logger) Errorf(format string, a ...interface{}) {
l.printLog("[ERROR]", format, a...)
} | go | func (l *logger) Errorf(format string, a ...interface{}) {
l.printLog("[ERROR]", format, a...)
} | [
"func",
"(",
"l",
"*",
"logger",
")",
"Errorf",
"(",
"format",
"string",
",",
"a",
"...",
"interface",
"{",
"}",
")",
"{",
"l",
".",
"printLog",
"(",
"\"",
"\"",
",",
"format",
",",
"a",
"...",
")",
"\n",
"}"
] | // Errorf shows error log with specified format and arguments | [
"Errorf",
"shows",
"error",
"log",
"with",
"specified",
"format",
"and",
"arguments"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simlog/log.go#L83-L85 |
147,418 | pankona/gomo-simra | simra/simlog/log.go | Debug | func (l *logger) Debug(i interface{}) {
if !l.isDebug {
return
}
switch v := i.(type) {
case error:
l.printLog("[DEBUG]", v.Error())
case fmt.Stringer:
l.printLog("[DEBUG]", v.String())
case string:
l.printLog("[DEBUG]", v)
default:
panic("can't print input!")
}
} | go | func (l *logger) Debug(i interface{}) {
if !l.isDebug {
return
}
switch v := i.(type) {
case error:
l.printLog("[DEBUG]", v.Error())
case fmt.Stringer:
l.printLog("[DEBUG]", v.String())
case string:
l.printLog("[DEBUG]", v)
default:
panic("can't print input!")
}
} | [
"func",
"(",
"l",
"*",
"logger",
")",
"Debug",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"if",
"!",
"l",
".",
"isDebug",
"{",
"return",
"\n",
"}",
"\n",
"switch",
"v",
":=",
"i",
".",
"(",
"type",
")",
"{",
"case",
"error",
":",
"l",
".",
... | // Debug shows debug log with specified object | [
"Debug",
"shows",
"debug",
"log",
"with",
"specified",
"object"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simlog/log.go#L88-L102 |
147,419 | pankona/gomo-simra | simra/simlog/log.go | Error | func (l *logger) Error(i interface{}) {
switch v := i.(type) {
case error:
l.printLog("[ERROR]", v.Error())
case fmt.Stringer:
l.printLog("[ERROR]", v.String())
default:
panic("can't print input!")
}
} | go | func (l *logger) Error(i interface{}) {
switch v := i.(type) {
case error:
l.printLog("[ERROR]", v.Error())
case fmt.Stringer:
l.printLog("[ERROR]", v.String())
default:
panic("can't print input!")
}
} | [
"func",
"(",
"l",
"*",
"logger",
")",
"Error",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"switch",
"v",
":=",
"i",
".",
"(",
"type",
")",
"{",
"case",
"error",
":",
"l",
".",
"printLog",
"(",
"\"",
"\"",
",",
"v",
".",
"Error",
"(",
")",
"... | // Error shows error log with specified object | [
"Error",
"shows",
"error",
"log",
"with",
"specified",
"object"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simlog/log.go#L105-L114 |
147,420 | pankona/gomo-simra | simra/pubsub.go | Publish | func (p *PubSub) Publish(i interface{}) {
p.m.Lock()
defer p.m.Unlock()
for _, v := range p.subscribers {
v.OnEvent(i)
}
} | go | func (p *PubSub) Publish(i interface{}) {
p.m.Lock()
defer p.m.Unlock()
for _, v := range p.subscribers {
v.OnEvent(i)
}
} | [
"func",
"(",
"p",
"*",
"PubSub",
")",
"Publish",
"(",
"i",
"interface",
"{",
"}",
")",
"{",
"p",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"for",
"_",
",",
"v",
":=",
"range",
"p",
".",
... | // Publish publishes specified object to all subscriber | [
"Publish",
"publishes",
"specified",
"object",
"to",
"all",
"subscriber"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/pubsub.go#L31-L38 |
147,421 | pankona/gomo-simra | simra/pubsub.go | Subscribe | func (p *PubSub) Subscribe(id string, s Subscriber) error {
p.m.Lock()
defer p.m.Unlock()
p.subscribers[id] = s
return nil
} | go | func (p *PubSub) Subscribe(id string, s Subscriber) error {
p.m.Lock()
defer p.m.Unlock()
p.subscribers[id] = s
return nil
} | [
"func",
"(",
"p",
"*",
"PubSub",
")",
"Subscribe",
"(",
"id",
"string",
",",
"s",
"Subscriber",
")",
"error",
"{",
"p",
".",
"m",
".",
"Lock",
"(",
")",
"\n",
"defer",
"p",
".",
"m",
".",
"Unlock",
"(",
")",
"\n\n",
"p",
".",
"subscribers",
"["... | // Subscribe adds a subscriber to publisher | [
"Subscribe",
"adds",
"a",
"subscriber",
"to",
"publisher"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/pubsub.go#L41-L47 |
147,422 | pankona/gomo-simra | examples/filestore/scene/filestore.go | Initialize | func (f *filestore) Initialize(sim simra.Simraer) {
f.simra = sim
f.simra.SetDesiredScreenSize(1080/2, 1920/2)
var err error
f.db, err = simra.OpenDB(&database.Boltdb{}, storage.NewStorage().DirectoryPath())
if err != nil {
simlog.Errorf("failed to open database. fatal.")
return
}
f.initSprite()
go func()... | go | func (f *filestore) Initialize(sim simra.Simraer) {
f.simra = sim
f.simra.SetDesiredScreenSize(1080/2, 1920/2)
var err error
f.db, err = simra.OpenDB(&database.Boltdb{}, storage.NewStorage().DirectoryPath())
if err != nil {
simlog.Errorf("failed to open database. fatal.")
return
}
f.initSprite()
go func()... | [
"func",
"(",
"f",
"*",
"filestore",
")",
"Initialize",
"(",
"sim",
"simra",
".",
"Simraer",
")",
"{",
"f",
".",
"simra",
"=",
"sim",
"\n",
"f",
".",
"simra",
".",
"SetDesiredScreenSize",
"(",
"1080",
"/",
"2",
",",
"1920",
"/",
"2",
")",
"\n\n",
... | // Initialize initializes filestore scene.
// This is called from simra.
// simra.SetDesiredScreenSize should be called to determine
// screen size of this scene.
// If SetDesiredScreenSize is already called in previous scene, this scene may not call the function. | [
"Initialize",
"initializes",
"filestore",
"scene",
".",
"This",
"is",
"called",
"from",
"simra",
".",
"simra",
".",
"SetDesiredScreenSize",
"should",
"be",
"called",
"to",
"determine",
"screen",
"size",
"of",
"this",
"scene",
".",
"If",
"SetDesiredScreenSize",
"... | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/filestore/scene/filestore.go#L27-L49 |
147,423 | pankona/gomo-simra | simra/internal/peer/size.go | SetDesiredScreenSize | func (ss *screenSize) SetDesiredScreenSize(w, h float32) {
simlog.FuncIn()
ss.height = h
ss.width = w
ss.calcScale()
simlog.FuncOut()
} | go | func (ss *screenSize) SetDesiredScreenSize(w, h float32) {
simlog.FuncIn()
ss.height = h
ss.width = w
ss.calcScale()
simlog.FuncOut()
} | [
"func",
"(",
"ss",
"*",
"screenSize",
")",
"SetDesiredScreenSize",
"(",
"w",
",",
"h",
"float32",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"ss",
".",
"height",
"=",
"h",
"\n",
"ss",
".",
"width",
"=",
"w",
"\n",
"ss",
".",
"calcScale",
... | // SetDesiredScreenSize sets virtual screen size.
// Any positive value can be specified to arguments.
// like, w=1920, h=1080 | [
"SetDesiredScreenSize",
"sets",
"virtual",
"screen",
"size",
".",
"Any",
"positive",
"value",
"can",
"be",
"specified",
"to",
"arguments",
".",
"like",
"w",
"=",
"1920",
"h",
"=",
"1080"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/size.go#L52-L58 |
147,424 | pankona/gomo-simra | simra/database.go | OpenDB | func OpenDB(databaser Databaser, dirpath string) (*Database, error) {
err := databaser.Open(dirpath)
if err != nil {
simlog.Errorf("failed to open database. err = %s", err)
return nil, err
}
return &Database{databaser}, nil
} | go | func OpenDB(databaser Databaser, dirpath string) (*Database, error) {
err := databaser.Open(dirpath)
if err != nil {
simlog.Errorf("failed to open database. err = %s", err)
return nil, err
}
return &Database{databaser}, nil
} | [
"func",
"OpenDB",
"(",
"databaser",
"Databaser",
",",
"dirpath",
"string",
")",
"(",
"*",
"Database",
",",
"error",
")",
"{",
"err",
":=",
"databaser",
".",
"Open",
"(",
"dirpath",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"simlog",
".",
"Errorf",
"(... | // OpenDB opens database connection | [
"OpenDB",
"opens",
"database",
"connection"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database.go#L19-L26 |
147,425 | pankona/gomo-simra | simra/database.go | Put | func (database *Database) Put(key string, value interface{}) {
database.db.Put(key, value)
} | go | func (database *Database) Put(key string, value interface{}) {
database.db.Put(key, value)
} | [
"func",
"(",
"database",
"*",
"Database",
")",
"Put",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"database",
".",
"db",
".",
"Put",
"(",
"key",
",",
"value",
")",
"\n",
"}"
] | // Put stores a specified data to database | [
"Put",
"stores",
"a",
"specified",
"data",
"to",
"database"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database.go#L34-L36 |
147,426 | pankona/gomo-simra | simra/database/boltdb.go | Open | func (database *Boltdb) Open(dirpath string) error {
db, err := bolt.Open(filepath.Join(dirpath, "db"), 0600, nil)
if err != nil {
return fmt.Errorf("failed to open database. error is: %s", err)
}
database.db = db
err = db.Update(func(tx *bolt.Tx) error {
_, e := tx.CreateBucketIfNotExists([]byte("my_bucket"))... | go | func (database *Boltdb) Open(dirpath string) error {
db, err := bolt.Open(filepath.Join(dirpath, "db"), 0600, nil)
if err != nil {
return fmt.Errorf("failed to open database. error is: %s", err)
}
database.db = db
err = db.Update(func(tx *bolt.Tx) error {
_, e := tx.CreateBucketIfNotExists([]byte("my_bucket"))... | [
"func",
"(",
"database",
"*",
"Boltdb",
")",
"Open",
"(",
"dirpath",
"string",
")",
"error",
"{",
"db",
",",
"err",
":=",
"bolt",
".",
"Open",
"(",
"filepath",
".",
"Join",
"(",
"dirpath",
",",
"\"",
"\"",
")",
",",
"0600",
",",
"nil",
")",
"\n",... | // Open opens new DB connection.
// Open will create a DB file under dirpath if not exist. | [
"Open",
"opens",
"new",
"DB",
"connection",
".",
"Open",
"will",
"create",
"a",
"DB",
"file",
"under",
"dirpath",
"if",
"not",
"exist",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database/boltdb.go#L19-L34 |
147,427 | pankona/gomo-simra | simra/database/boltdb.go | Close | func (database *Boltdb) Close() {
err := database.db.Close()
if err != nil {
log.Println(err)
}
database.db = nil
} | go | func (database *Boltdb) Close() {
err := database.db.Close()
if err != nil {
log.Println(err)
}
database.db = nil
} | [
"func",
"(",
"database",
"*",
"Boltdb",
")",
"Close",
"(",
")",
"{",
"err",
":=",
"database",
".",
"db",
".",
"Close",
"(",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"log",
".",
"Println",
"(",
"err",
")",
"\n",
"}",
"\n",
"database",
".",
"db"... | // Close closes database.
// it is necessary to call this function after using database functions. | [
"Close",
"closes",
"database",
".",
"it",
"is",
"necessary",
"to",
"call",
"this",
"function",
"after",
"using",
"database",
"functions",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database/boltdb.go#L38-L44 |
147,428 | pankona/gomo-simra | simra/database/boltdb.go | Put | func (database *Boltdb) Put(key string, value interface{}) {
db := database.db
if db == nil {
log.Fatal("database is not opened yet.")
return
}
err := db.Update(func(tx *bolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists([]byte("my_bucket"))
if err != nil {
log.Fatal(err)
return nil
}
if ... | go | func (database *Boltdb) Put(key string, value interface{}) {
db := database.db
if db == nil {
log.Fatal("database is not opened yet.")
return
}
err := db.Update(func(tx *bolt.Tx) error {
bucket, err := tx.CreateBucketIfNotExists([]byte("my_bucket"))
if err != nil {
log.Fatal(err)
return nil
}
if ... | [
"func",
"(",
"database",
"*",
"Boltdb",
")",
"Put",
"(",
"key",
"string",
",",
"value",
"interface",
"{",
"}",
")",
"{",
"db",
":=",
"database",
".",
"db",
"\n",
"if",
"db",
"==",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"re... | // Put puts a data to database.
// input must have ability to be casted into byte array. | [
"Put",
"puts",
"a",
"data",
"to",
"database",
".",
"input",
"must",
"have",
"ability",
"to",
"be",
"casted",
"into",
"byte",
"array",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database/boltdb.go#L48-L75 |
147,429 | pankona/gomo-simra | simra/database/boltdb.go | Get | func (database *Boltdb) Get(key string) interface{} {
db := database.db
if db == nil {
log.Fatal("database is not opened yet.")
return nil
}
var value interface{}
err := db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte("my_bucket"))
if bucket == nil {
log.Fatal("bucket not found")
return ... | go | func (database *Boltdb) Get(key string) interface{} {
db := database.db
if db == nil {
log.Fatal("database is not opened yet.")
return nil
}
var value interface{}
err := db.View(func(tx *bolt.Tx) error {
bucket := tx.Bucket([]byte("my_bucket"))
if bucket == nil {
log.Fatal("bucket not found")
return ... | [
"func",
"(",
"database",
"*",
"Boltdb",
")",
"Get",
"(",
"key",
"string",
")",
"interface",
"{",
"}",
"{",
"db",
":=",
"database",
".",
"db",
"\n",
"if",
"db",
"==",
"nil",
"{",
"log",
".",
"Fatal",
"(",
"\"",
"\"",
")",
"\n",
"return",
"nil",
... | // Get returns put data. | [
"Get",
"returns",
"put",
"data",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/database/boltdb.go#L78-L98 |
147,430 | pankona/gomo-simra | simra/animationset.go | NewAnimationSet | func NewAnimationSet() *AnimationSet {
simlog.FuncIn()
defaultInterval := (int64)(6)
simlog.FuncOut()
return &AnimationSet{interval: defaultInterval}
} | go | func NewAnimationSet() *AnimationSet {
simlog.FuncIn()
defaultInterval := (int64)(6)
simlog.FuncOut()
return &AnimationSet{interval: defaultInterval}
} | [
"func",
"NewAnimationSet",
"(",
")",
"*",
"AnimationSet",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"defaultInterval",
":=",
"(",
"int64",
")",
"(",
"6",
")",
"\n",
"simlog",
".",
"FuncOut",
"(",
")",
"\n",
"return",
"&",
"AnimationSet",
"{",
"inte... | // NewAnimationSet returns an instance of AnimationSet | [
"NewAnimationSet",
"returns",
"an",
"instance",
"of",
"AnimationSet"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/animationset.go#L12-L17 |
147,431 | pankona/gomo-simra | simra/animationset.go | AddTexture | func (animation *AnimationSet) AddTexture(texture *Texture) {
simlog.FuncIn()
animation.textures = append(animation.textures, texture)
simlog.FuncOut()
} | go | func (animation *AnimationSet) AddTexture(texture *Texture) {
simlog.FuncIn()
animation.textures = append(animation.textures, texture)
simlog.FuncOut()
} | [
"func",
"(",
"animation",
"*",
"AnimationSet",
")",
"AddTexture",
"(",
"texture",
"*",
"Texture",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"animation",
".",
"textures",
"=",
"append",
"(",
"animation",
".",
"textures",
",",
"texture",
")",
"\n"... | // AddTexture adds a specified texture to AnimationSet | [
"AddTexture",
"adds",
"a",
"specified",
"texture",
"to",
"AnimationSet"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/animationset.go#L20-L24 |
147,432 | pankona/gomo-simra | simra/animationset.go | SetInterval | func (animation *AnimationSet) SetInterval(interval int64) {
simlog.FuncIn()
animation.interval = interval
simlog.FuncOut()
} | go | func (animation *AnimationSet) SetInterval(interval int64) {
simlog.FuncIn()
animation.interval = interval
simlog.FuncOut()
} | [
"func",
"(",
"animation",
"*",
"AnimationSet",
")",
"SetInterval",
"(",
"interval",
"int64",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"animation",
".",
"interval",
"=",
"interval",
"\n",
"simlog",
".",
"FuncOut",
"(",
")",
"\n",
"}"
] | // SetInterval sets interval of animation | [
"SetInterval",
"sets",
"interval",
"of",
"animation"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/animationset.go#L27-L31 |
147,433 | pankona/gomo-simra | examples/sprites/scene/title.go | OnTouchBegin | func (t *Title) OnTouchBegin(x, y float32) {
t.spawnKokeshi(x, y)
} | go | func (t *Title) OnTouchBegin(x, y float32) {
t.spawnKokeshi(x, y)
} | [
"func",
"(",
"t",
"*",
"Title",
")",
"OnTouchBegin",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"t",
".",
"spawnKokeshi",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // OnTouchBegin is called when Title scene is Touched.
// It is caused by calling AddtouchListener for title.background sprite. | [
"OnTouchBegin",
"is",
"called",
"when",
"Title",
"scene",
"is",
"Touched",
".",
"It",
"is",
"caused",
"by",
"calling",
"AddtouchListener",
"for",
"title",
".",
"background",
"sprite",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sprites/scene/title.go#L97-L99 |
147,434 | pankona/gomo-simra | examples/sprites/scene/title.go | OnTouchMove | func (t *Title) OnTouchMove(x, y float32) {
t.spawnKokeshi(x, y)
} | go | func (t *Title) OnTouchMove(x, y float32) {
t.spawnKokeshi(x, y)
} | [
"func",
"(",
"t",
"*",
"Title",
")",
"OnTouchMove",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"t",
".",
"spawnKokeshi",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | // OnTouchMove is called when Title scene is Touched and moved.
// It is caused by calling AddtouchListener for title.background sprite. | [
"OnTouchMove",
"is",
"called",
"when",
"Title",
"scene",
"is",
"Touched",
"and",
"moved",
".",
"It",
"is",
"caused",
"by",
"calling",
"AddtouchListener",
"for",
"title",
".",
"background",
"sprite",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sprites/scene/title.go#L103-L105 |
147,435 | pankona/gomo-simra | simra/simra.go | Start | func (sim *simra) Start(driver Driver) {
simlog.FuncIn()
gl := peer.NewGLPeer()
sc := peer.GetSpriteContainer()
sc.Initialize(gl)
sim.gl = gl
sim.spritecontainer = sc
sim.driver = driver
gomo := peer.GetGomo()
gomo.Initialize(sim.onGomoStart, sim.onGomoStop, sim.onUpdate)
gomo.Start()
simlog.FuncOut()
} | go | func (sim *simra) Start(driver Driver) {
simlog.FuncIn()
gl := peer.NewGLPeer()
sc := peer.GetSpriteContainer()
sc.Initialize(gl)
sim.gl = gl
sim.spritecontainer = sc
sim.driver = driver
gomo := peer.GetGomo()
gomo.Initialize(sim.onGomoStart, sim.onGomoStop, sim.onUpdate)
gomo.Start()
simlog.FuncOut()
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"Start",
"(",
"driver",
"Driver",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"gl",
":=",
"peer",
".",
"NewGLPeer",
"(",
")",
"\n",
"sc",
":=",
"peer",
".",
"GetSpriteContainer",
"(",
")",
"\n",
"sc",... | // Start starts to run gomobile and set specified scene as first driver | [
"Start",
"starts",
"to",
"run",
"gomobile",
"and",
"set",
"specified",
"scene",
"as",
"first",
"driver"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L108-L122 |
147,436 | pankona/gomo-simra | simra/simra.go | SetScene | func (sim *simra) SetScene(driver Driver) {
simlog.FuncIn()
sim.spritecontainer.RemoveSprites()
sim.gl.Reset()
sim.spritecontainer.Initialize(sim.gl)
peer.GetTouchPeer().RemoveAllTouchListeners()
sim.spritecontainer.RemoveSprites()
sim.driver = driver
sim.spritecontainer.Initialize(sim.gl)
err := sim.spritec... | go | func (sim *simra) SetScene(driver Driver) {
simlog.FuncIn()
sim.spritecontainer.RemoveSprites()
sim.gl.Reset()
sim.spritecontainer.Initialize(sim.gl)
peer.GetTouchPeer().RemoveAllTouchListeners()
sim.spritecontainer.RemoveSprites()
sim.driver = driver
sim.spritecontainer.Initialize(sim.gl)
err := sim.spritec... | [
"func",
"(",
"sim",
"*",
"simra",
")",
"SetScene",
"(",
"driver",
"Driver",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"sim",
".",
"spritecontainer",
".",
"RemoveSprites",
"(",
")",
"\n",
"sim",
".",
"gl",
".",
"Reset",
"(",
")",
"\n",
"s... | // SetScene sets a driver as a scene.
// If a driver is already set, it is replaced with new one. | [
"SetScene",
"sets",
"a",
"driver",
"as",
"a",
"scene",
".",
"If",
"a",
"driver",
"is",
"already",
"set",
"it",
"is",
"replaced",
"with",
"new",
"one",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L126-L146 |
147,437 | pankona/gomo-simra | simra/simra.go | NewSprite | func (sim *simra) NewSprite() Spriter {
return &sprite{
simra: sim,
animationSets: map[string]*AnimationSet{},
}
} | go | func (sim *simra) NewSprite() Spriter {
return &sprite{
simra: sim,
animationSets: map[string]*AnimationSet{},
}
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"NewSprite",
"(",
")",
"Spriter",
"{",
"return",
"&",
"sprite",
"{",
"simra",
":",
"sim",
",",
"animationSets",
":",
"map",
"[",
"string",
"]",
"*",
"AnimationSet",
"{",
"}",
",",
"}",
"\n",
"}"
] | // NewSprite returns an instance of Sprite | [
"NewSprite",
"returns",
"an",
"instance",
"of",
"Sprite"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L149-L154 |
147,438 | pankona/gomo-simra | simra/simra.go | AddSprite | func (sim *simra) AddSprite(s Spriter) {
sp := s.(*sprite)
err := sim.spritecontainer.AddSprite(&sp.Sprite, nil, nil)
if err != nil {
simlog.Errorf("failed to add sprite. err: %s", err.Error())
}
} | go | func (sim *simra) AddSprite(s Spriter) {
sp := s.(*sprite)
err := sim.spritecontainer.AddSprite(&sp.Sprite, nil, nil)
if err != nil {
simlog.Errorf("failed to add sprite. err: %s", err.Error())
}
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"AddSprite",
"(",
"s",
"Spriter",
")",
"{",
"sp",
":=",
"s",
".",
"(",
"*",
"sprite",
")",
"\n",
"err",
":=",
"sim",
".",
"spritecontainer",
".",
"AddSprite",
"(",
"&",
"sp",
".",
"Sprite",
",",
"nil",
",",
... | // AddSprite adds a sprite to current scene with empty texture. | [
"AddSprite",
"adds",
"a",
"sprite",
"to",
"current",
"scene",
"with",
"empty",
"texture",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L157-L163 |
147,439 | pankona/gomo-simra | simra/simra.go | RemoveSprite | func (sim *simra) RemoveSprite(s Spriter) {
sp := s.(*sprite)
sp.texture = nil
sim.spritecontainer.RemoveSprite(&sp.Sprite)
} | go | func (sim *simra) RemoveSprite(s Spriter) {
sp := s.(*sprite)
sp.texture = nil
sim.spritecontainer.RemoveSprite(&sp.Sprite)
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"RemoveSprite",
"(",
"s",
"Spriter",
")",
"{",
"sp",
":=",
"s",
".",
"(",
"*",
"sprite",
")",
"\n",
"sp",
".",
"texture",
"=",
"nil",
"\n",
"sim",
".",
"spritecontainer",
".",
"RemoveSprite",
"(",
"&",
"sp",
... | // RemoveSprite removes specified sprite from current scene.
// Removed sprite will be disappeared. | [
"RemoveSprite",
"removes",
"specified",
"sprite",
"from",
"current",
"scene",
".",
"Removed",
"sprite",
"will",
"be",
"disappeared",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L167-L171 |
147,440 | pankona/gomo-simra | simra/simra.go | SetDesiredScreenSize | func (sim *simra) SetDesiredScreenSize(w, h float32) {
ss := peer.GetScreenSizePeer()
ss.SetDesiredScreenSize(w, h)
} | go | func (sim *simra) SetDesiredScreenSize(w, h float32) {
ss := peer.GetScreenSizePeer()
ss.SetDesiredScreenSize(w, h)
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"SetDesiredScreenSize",
"(",
"w",
",",
"h",
"float32",
")",
"{",
"ss",
":=",
"peer",
".",
"GetScreenSizePeer",
"(",
")",
"\n",
"ss",
".",
"SetDesiredScreenSize",
"(",
"w",
",",
"h",
")",
"\n",
"}"
] | // SetDesiredScreenSize configures virtual screen size.
// This function must be called at least once before calling Start. | [
"SetDesiredScreenSize",
"configures",
"virtual",
"screen",
"size",
".",
"This",
"function",
"must",
"be",
"called",
"at",
"least",
"once",
"before",
"calling",
"Start",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L196-L199 |
147,441 | pankona/gomo-simra | simra/simra.go | AddCollisionListener | func (sim *simra) AddCollisionListener(c1, c2 Collider, listener CollisionListener) {
// TODO: exclusive control
simlog.FuncIn()
sim.comap = append(sim.comap, &collisionMap{c1, c2, listener})
simlog.FuncOut()
} | go | func (sim *simra) AddCollisionListener(c1, c2 Collider, listener CollisionListener) {
// TODO: exclusive control
simlog.FuncIn()
sim.comap = append(sim.comap, &collisionMap{c1, c2, listener})
simlog.FuncOut()
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"AddCollisionListener",
"(",
"c1",
",",
"c2",
"Collider",
",",
"listener",
"CollisionListener",
")",
"{",
"// TODO: exclusive control",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"sim",
".",
"comap",
"=",
"append",
"(",
... | // AddCollisionListener add a callback function that is called on
// collision is detected between c1 and c2. | [
"AddCollisionListener",
"add",
"a",
"callback",
"function",
"that",
"is",
"called",
"on",
"collision",
"is",
"detected",
"between",
"c1",
"and",
"c2",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L214-L219 |
147,442 | pankona/gomo-simra | simra/simra.go | RemoveAllCollisionListener | func (sim *simra) RemoveAllCollisionListener() {
simlog.FuncIn()
sim.comap = nil
simlog.FuncOut()
} | go | func (sim *simra) RemoveAllCollisionListener() {
simlog.FuncIn()
sim.comap = nil
simlog.FuncOut()
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"RemoveAllCollisionListener",
"(",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"sim",
".",
"comap",
"=",
"nil",
"\n",
"simlog",
".",
"FuncOut",
"(",
")",
"\n",
"}"
] | // RemoveAllCollisionListener removes all registered listeners | [
"RemoveAllCollisionListener",
"removes",
"all",
"registered",
"listeners"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L234-L238 |
147,443 | pankona/gomo-simra | simra/simra.go | NewImageTexture | func (sim *simra) NewImageTexture(assetName string, rect image.Rectangle) *Texture {
simlog.FuncIn()
gl := sim.gl
tex := gl.LoadTexture(assetName, rect.Rectangle)
t := &Texture{
simra: sim,
texture: gl.NewTexture(tex),
}
runtime.SetFinalizer(t, (*Texture).release)
simlog.FuncOut()
return t
} | go | func (sim *simra) NewImageTexture(assetName string, rect image.Rectangle) *Texture {
simlog.FuncIn()
gl := sim.gl
tex := gl.LoadTexture(assetName, rect.Rectangle)
t := &Texture{
simra: sim,
texture: gl.NewTexture(tex),
}
runtime.SetFinalizer(t, (*Texture).release)
simlog.FuncOut()
return t
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"NewImageTexture",
"(",
"assetName",
"string",
",",
"rect",
"image",
".",
"Rectangle",
")",
"*",
"Texture",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"gl",
":=",
"sim",
".",
"gl",
"\n",
"tex",
":=",
"gl",
... | // NewImageTexture allocates a texture from asset image | [
"NewImageTexture",
"allocates",
"a",
"texture",
"from",
"asset",
"image"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L241-L254 |
147,444 | pankona/gomo-simra | simra/simra.go | NewTextTexture | func (sim *simra) NewTextTexture(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) *Texture {
simlog.FuncIn()
gl := sim.gl
tex := gl.MakeTextureByText(text, fontsize, fontcolor, rect.Rectangle)
t := &Texture{
simra: sim,
texture: gl.NewTexture(tex),
}
runtime.SetFinalizer(t, (*Text... | go | func (sim *simra) NewTextTexture(text string, fontsize float64, fontcolor color.RGBA, rect image.Rectangle) *Texture {
simlog.FuncIn()
gl := sim.gl
tex := gl.MakeTextureByText(text, fontsize, fontcolor, rect.Rectangle)
t := &Texture{
simra: sim,
texture: gl.NewTexture(tex),
}
runtime.SetFinalizer(t, (*Text... | [
"func",
"(",
"sim",
"*",
"simra",
")",
"NewTextTexture",
"(",
"text",
"string",
",",
"fontsize",
"float64",
",",
"fontcolor",
"color",
".",
"RGBA",
",",
"rect",
"image",
".",
"Rectangle",
")",
"*",
"Texture",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n... | // NewTextTexture allocates a texture from specified text | [
"NewTextTexture",
"allocates",
"a",
"texture",
"from",
"specified",
"text"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L257-L270 |
147,445 | pankona/gomo-simra | simra/simra.go | RemoveCollisionListener | func (sim *simra) RemoveCollisionListener(c1, c2 Collider) {
// TODO: exclusive control
simlog.FuncIn()
sim.removeCollisionMap(&collisionMap{c1, c2, nil})
simlog.FuncOut()
} | go | func (sim *simra) RemoveCollisionListener(c1, c2 Collider) {
// TODO: exclusive control
simlog.FuncIn()
sim.removeCollisionMap(&collisionMap{c1, c2, nil})
simlog.FuncOut()
} | [
"func",
"(",
"sim",
"*",
"simra",
")",
"RemoveCollisionListener",
"(",
"c1",
",",
"c2",
"Collider",
")",
"{",
"// TODO: exclusive control",
"simlog",
".",
"FuncIn",
"(",
")",
"\n",
"sim",
".",
"removeCollisionMap",
"(",
"&",
"collisionMap",
"{",
"c1",
",",
... | // RemoveCollisionListener removes a collision map by specified collider instance. | [
"RemoveCollisionListener",
"removes",
"a",
"collision",
"map",
"by",
"specified",
"collider",
"instance",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/simra.go#L299-L304 |
147,446 | pankona/gomo-simra | examples/sample2/scene/listener.go | OnTouchBegin | func (c *ButtonBlueTouchListener) OnTouchBegin(x, y float32) {
if c.buttonReplaced {
c.originalButtonColor()
} else {
c.replaceButtonColor()
}
c.simra.RemoveSprite(c.ball)
} | go | func (c *ButtonBlueTouchListener) OnTouchBegin(x, y float32) {
if c.buttonReplaced {
c.originalButtonColor()
} else {
c.replaceButtonColor()
}
c.simra.RemoveSprite(c.ball)
} | [
"func",
"(",
"c",
"*",
"ButtonBlueTouchListener",
")",
"OnTouchBegin",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"if",
"c",
".",
"buttonReplaced",
"{",
"c",
".",
"originalButtonColor",
"(",
")",
"\n",
"}",
"else",
"{",
"c",
".",
"replaceButtonColor",
"(",... | // OnTouchBegin is called when Blue Button is Touched. | [
"OnTouchBegin",
"is",
"called",
"when",
"Blue",
"Button",
"is",
"Touched",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample2/scene/listener.go#L46-L53 |
147,447 | pankona/gomo-simra | examples/sample2/scene/listener.go | OnTouchBegin | func (c *ButtonRedTouchListener) OnTouchBegin(x, y float32) {
if c.buttonReplaced {
c.originalButtonColor()
} else {
c.replaceButtonColor()
}
c.simra.AddSprite(c.ball)
tex := c.simra.NewImageTexture("ball.png",
image.Rect(0, 0, c.ball.GetScale().W, c.ball.GetScale().H))
c.ball.ReplaceTexture(tex)
} | go | func (c *ButtonRedTouchListener) OnTouchBegin(x, y float32) {
if c.buttonReplaced {
c.originalButtonColor()
} else {
c.replaceButtonColor()
}
c.simra.AddSprite(c.ball)
tex := c.simra.NewImageTexture("ball.png",
image.Rect(0, 0, c.ball.GetScale().W, c.ball.GetScale().H))
c.ball.ReplaceTexture(tex)
} | [
"func",
"(",
"c",
"*",
"ButtonRedTouchListener",
")",
"OnTouchBegin",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"if",
"c",
".",
"buttonReplaced",
"{",
"c",
".",
"originalButtonColor",
"(",
")",
"\n",
"}",
"else",
"{",
"c",
".",
"replaceButtonColor",
"(",
... | // OnTouchBegin is called when Red Button is Touched. | [
"OnTouchBegin",
"is",
"called",
"when",
"Red",
"Button",
"is",
"Touched",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample2/scene/listener.go#L72-L82 |
147,448 | pankona/gomo-simra | examples/sample3/scene/ball.go | setPosition | func (b *Ball) setPosition(x, y float32) {
b.SetPosition(x, y)
} | go | func (b *Ball) setPosition(x, y float32) {
b.SetPosition(x, y)
} | [
"func",
"(",
"b",
"*",
"Ball",
")",
"setPosition",
"(",
"x",
",",
"y",
"float32",
")",
"{",
"b",
".",
"SetPosition",
"(",
"x",
",",
"y",
")",
"\n",
"}"
] | /**
* Ball implementation for Model interface
*/ | [
"Ball",
"implementation",
"for",
"Model",
"interface"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/ball.go#L21-L23 |
147,449 | pankona/gomo-simra | examples/sample3/scene/models.go | Progress | func (m *models) Progress(isKeyTouching bool) {
b := m.ball
if !m.isDead {
degree++
if degree >= 360 {
degree = 0
}
b.setRotate(degree * math.Pi / 180)
if isKeyTouching {
dx := b.getSpeed() * math.Cos(b.getDirection()*math.Pi/180)
dy := b.getSpeed() * math.Sin(b.getDirection()*math.Pi/180)
dy... | go | func (m *models) Progress(isKeyTouching bool) {
b := m.ball
if !m.isDead {
degree++
if degree >= 360 {
degree = 0
}
b.setRotate(degree * math.Pi / 180)
if isKeyTouching {
dx := b.getSpeed() * math.Cos(b.getDirection()*math.Pi/180)
dy := b.getSpeed() * math.Sin(b.getDirection()*math.Pi/180)
dy... | [
"func",
"(",
"m",
"*",
"models",
")",
"Progress",
"(",
"isKeyTouching",
"bool",
")",
"{",
"b",
":=",
"m",
".",
"ball",
"\n\n",
"if",
"!",
"m",
".",
"isDead",
"{",
"degree",
"++",
"\n",
"if",
"degree",
">=",
"360",
"{",
"degree",
"=",
"0",
"\n",
... | // Progress progresses the time of models 1 frame | [
"Progress",
"progresses",
"the",
"time",
"of",
"models",
"1",
"frame"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/models.go#L62-L82 |
147,450 | pankona/gomo-simra | examples/sample3/scene/models.go | OnCollision | func (m *models) OnCollision(c1, c2 simra.Collider) {
if _, ok := c1.(*Ball); ok {
if _, ok := c2.(*Obstacle); ok {
// collision indicates a miss. this will be decrease a life.
if !m.isDead {
m.isDead = true
for _, v := range m.listeners {
m.isDead = true
v.onDead()
}
}
}
}
} | go | func (m *models) OnCollision(c1, c2 simra.Collider) {
if _, ok := c1.(*Ball); ok {
if _, ok := c2.(*Obstacle); ok {
// collision indicates a miss. this will be decrease a life.
if !m.isDead {
m.isDead = true
for _, v := range m.listeners {
m.isDead = true
v.onDead()
}
}
}
}
} | [
"func",
"(",
"m",
"*",
"models",
")",
"OnCollision",
"(",
"c1",
",",
"c2",
"simra",
".",
"Collider",
")",
"{",
"if",
"_",
",",
"ok",
":=",
"c1",
".",
"(",
"*",
"Ball",
")",
";",
"ok",
"{",
"if",
"_",
",",
"ok",
":=",
"c2",
".",
"(",
"*",
... | // OnCollision is called at collision detected | [
"OnCollision",
"is",
"called",
"at",
"collision",
"detected"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/examples/sample3/scene/models.go#L93-L106 |
147,451 | pankona/gomo-simra | simra/internal/peer/gl.go | Initialize | func (glpeer *GLPeer) Initialize(glc *GLContext) {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.glc = glc
glpeer.startTime = time.Now()
glctx := glc.glcontext
// transparency of png
glctx.Enable(gl.BLEND)
glctx.BlendEquation(gl.FUNC_ADD)
glctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_AL... | go | func (glpeer *GLPeer) Initialize(glc *GLContext) {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.glc = glc
glpeer.startTime = time.Now()
glctx := glc.glcontext
// transparency of png
glctx.Enable(gl.BLEND)
glctx.BlendEquation(gl.FUNC_ADD)
glctx.BlendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_AL... | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"Initialize",
"(",
"glc",
"*",
"GLContext",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"... | // Initialize initializes GLPeer.
// This function must be called in advance of using GLPeer | [
"Initialize",
"initializes",
"GLPeer",
".",
"This",
"function",
"must",
"be",
"called",
"in",
"advance",
"of",
"using",
"GLPeer"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L116-L135 |
147,452 | pankona/gomo-simra | simra/internal/peer/gl.go | NewNode | func (glpeer *GLPeer) NewNode(fn arrangerFunc) *ZNode {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
n := &sprite.Node{Arranger: fn}
glpeer.eng.Register(n)
return &ZNode{Node: n}
} | go | func (glpeer *GLPeer) NewNode(fn arrangerFunc) *ZNode {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
n := &sprite.Node{Arranger: fn}
glpeer.eng.Register(n)
return &ZNode{Node: n}
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"NewNode",
"(",
"fn",
"arrangerFunc",
")",
"*",
"ZNode",
"{",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"n",
":=",
"&",
"sprite",
".",... | // NewNode returns new node | [
"NewNode",
"returns",
"new",
"node"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L150-L156 |
147,453 | pankona/gomo-simra | simra/internal/peer/gl.go | AppendNode | func (glpeer *GLPeer) AppendNode(zn *ZNode) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.znodes = append(glpeer.znodes, zn)
} | go | func (glpeer *GLPeer) AppendNode(zn *ZNode) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.znodes = append(glpeer.znodes, zn)
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"AppendNode",
"(",
"zn",
"*",
"ZNode",
")",
"{",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"glpeer",
".",
"znodes",
"=",
"append",
"("... | // AppendNode adds specified node as a child | [
"AppendNode",
"adds",
"specified",
"node",
"as",
"a",
"child"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L159-L163 |
147,454 | pankona/gomo-simra | simra/internal/peer/gl.go | RemoveNode | func (glpeer *GLPeer) RemoveNode(n *ZNode) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
znodes := make([]*ZNode, len(glpeer.znodes)-1)
var count int
for _, zn := range glpeer.znodes {
if n != zn {
znodes[count] = zn
count++
}
}
glpeer.znodes = znodes
} | go | func (glpeer *GLPeer) RemoveNode(n *ZNode) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
znodes := make([]*ZNode, len(glpeer.znodes)-1)
var count int
for _, zn := range glpeer.znodes {
if n != zn {
znodes[count] = zn
count++
}
}
glpeer.znodes = znodes
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"RemoveNode",
"(",
"n",
"*",
"ZNode",
")",
"{",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"znodes",
":=",
"make",
"(",
"[",
"]",
"*"... | // RemoveNode removes specified node | [
"RemoveNode",
"removes",
"specified",
"node"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L166-L178 |
147,455 | pankona/gomo-simra | simra/internal/peer/gl.go | LoadTexture | func (glpeer *GLPeer) LoadTexture(assetName string, rect image.Rectangle) sprite.SubTex {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
a, err := asset.Open(assetName)
if err != nil {
simlog.Error(err)
}
defer func() {
closeErr := a.Close()
if closeErr != nil {
simlog.Error(closeErr)
}
... | go | func (glpeer *GLPeer) LoadTexture(assetName string, rect image.Rectangle) sprite.SubTex {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
a, err := asset.Open(assetName)
if err != nil {
simlog.Error(err)
}
defer func() {
closeErr := a.Close()
if closeErr != nil {
simlog.Error(closeErr)
}
... | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"LoadTexture",
"(",
"assetName",
"string",
",",
"rect",
"image",
".",
"Rectangle",
")",
"sprite",
".",
"SubTex",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\... | // LoadTexture return texture that is loaded by the information of arguments.
// Loaded texture can assign using AddSprite function. | [
"LoadTexture",
"return",
"texture",
"that",
"is",
"loaded",
"by",
"the",
"information",
"of",
"arguments",
".",
"Loaded",
"texture",
"can",
"assign",
"using",
"AddSprite",
"function",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L182-L210 |
147,456 | pankona/gomo-simra | simra/internal/peer/gl.go | Finalize | func (glpeer *GLPeer) Finalize() {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.eng.Release()
glpeer.fps.Release()
glpeer.images.Release()
glpeer.glc.glcontext = nil
simlog.FuncOut()
} | go | func (glpeer *GLPeer) Finalize() {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.eng.Release()
glpeer.fps.Release()
glpeer.images.Release()
glpeer.glc.glcontext = nil
simlog.FuncOut()
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"Finalize",
"(",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"glpeer",
".",
"eng"... | // Finalize finalizes GLPeer.
// This is called at termination of application. | [
"Finalize",
"finalizes",
"GLPeer",
".",
"This",
"is",
"called",
"at",
"termination",
"of",
"application",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L266-L278 |
147,457 | pankona/gomo-simra | simra/internal/peer/gl.go | Update | func (glpeer *GLPeer) Update(sc SpriteContainerer) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glctx := glpeer.glc.glcontext
if glctx == nil {
return
}
glctx.ClearColor(0, 0, 0, 1) // black background
glctx.Clear(gl.COLOR_BUFFER_BIT)
now := clock.Time(time.Since(glpeer.startTime) * 60 / time.Second)
glpeer... | go | func (glpeer *GLPeer) Update(sc SpriteContainerer) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glctx := glpeer.glc.glcontext
if glctx == nil {
return
}
glctx.ClearColor(0, 0, 0, 1) // black background
glctx.Clear(gl.COLOR_BUFFER_BIT)
now := clock.Time(time.Since(glpeer.startTime) * 60 / time.Second)
glpeer... | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"Update",
"(",
"sc",
"SpriteContainerer",
")",
"{",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n\n",
"glctx",
":=",
"glpeer",
".",
"glc",
"."... | // Update updates screen.
// This is called 60 times per 1 sec. | [
"Update",
"updates",
"screen",
".",
"This",
"is",
"called",
"60",
"times",
"per",
"1",
"sec",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L282-L311 |
147,458 | pankona/gomo-simra | simra/internal/peer/gl.go | Reset | func (glpeer *GLPeer) Reset() {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.initEng()
simlog.FuncOut()
} | go | func (glpeer *GLPeer) Reset() {
simlog.FuncIn()
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
glpeer.initEng()
simlog.FuncOut()
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"Reset",
"(",
")",
"{",
"simlog",
".",
"FuncIn",
"(",
")",
"\n\n",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"glpeer",
".",
"initEng",... | // Reset resets current gl context.
// All sprites are also cleaned.
// This is called at changing of scene, and
// this function is for clean previous scene. | [
"Reset",
"resets",
"current",
"gl",
"context",
".",
"All",
"sprites",
"are",
"also",
"cleaned",
".",
"This",
"is",
"called",
"at",
"changing",
"of",
"scene",
"and",
"this",
"function",
"is",
"for",
"clean",
"previous",
"scene",
"."
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L323-L331 |
147,459 | pankona/gomo-simra | simra/internal/peer/gl.go | SetSubTex | func (glpeer *GLPeer) SetSubTex(zn *ZNode, subTex *sprite.SubTex) {
glpeer.eng.SetSubTex(zn.Node, *subTex)
} | go | func (glpeer *GLPeer) SetSubTex(zn *ZNode, subTex *sprite.SubTex) {
glpeer.eng.SetSubTex(zn.Node, *subTex)
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"SetSubTex",
"(",
"zn",
"*",
"ZNode",
",",
"subTex",
"*",
"sprite",
".",
"SubTex",
")",
"{",
"glpeer",
".",
"eng",
".",
"SetSubTex",
"(",
"zn",
".",
"Node",
",",
"*",
"subTex",
")",
"\n",
"}"
] | // SetSubTex registers subtexture to specified node | [
"SetSubTex",
"registers",
"subtexture",
"to",
"specified",
"node"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L334-L336 |
147,460 | pankona/gomo-simra | simra/internal/peer/gl.go | NewTexture | func (glpeer *GLPeer) NewTexture(s sprite.SubTex) *Texture {
return &Texture{
subTex: s,
}
} | go | func (glpeer *GLPeer) NewTexture(s sprite.SubTex) *Texture {
return &Texture{
subTex: s,
}
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"NewTexture",
"(",
"s",
"sprite",
".",
"SubTex",
")",
"*",
"Texture",
"{",
"return",
"&",
"Texture",
"{",
"subTex",
":",
"s",
",",
"}",
"\n",
"}"
] | // NewTexture returns a new Texture instance | [
"NewTexture",
"returns",
"a",
"new",
"Texture",
"instance"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L377-L381 |
147,461 | pankona/gomo-simra | simra/internal/peer/gl.go | ReleaseTexture | func (glpeer *GLPeer) ReleaseTexture(t *Texture) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
t.subTex.T.Release()
} | go | func (glpeer *GLPeer) ReleaseTexture(t *Texture) {
glpeer.mu.Lock()
defer glpeer.mu.Unlock()
t.subTex.T.Release()
} | [
"func",
"(",
"glpeer",
"*",
"GLPeer",
")",
"ReleaseTexture",
"(",
"t",
"*",
"Texture",
")",
"{",
"glpeer",
".",
"mu",
".",
"Lock",
"(",
")",
"\n",
"defer",
"glpeer",
".",
"mu",
".",
"Unlock",
"(",
")",
"\n",
"t",
".",
"subTex",
".",
"T",
".",
"... | // ReleaseTexture releases specified texture | [
"ReleaseTexture",
"releases",
"specified",
"texture"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/internal/peer/gl.go#L384-L388 |
147,462 | pankona/gomo-simra | simra/image/image.go | Rect | func Rect(x0, y0, x1, y1 float32) Rectangle {
return Rectangle{
image.Rect(int(x0), int(y0), int(x1), int(y1)),
}
} | go | func Rect(x0, y0, x1, y1 float32) Rectangle {
return Rectangle{
image.Rect(int(x0), int(y0), int(x1), int(y1)),
}
} | [
"func",
"Rect",
"(",
"x0",
",",
"y0",
",",
"x1",
",",
"y1",
"float32",
")",
"Rectangle",
"{",
"return",
"Rectangle",
"{",
"image",
".",
"Rect",
"(",
"int",
"(",
"x0",
")",
",",
"int",
"(",
"y0",
")",
",",
"int",
"(",
"x1",
")",
",",
"int",
"(... | // Rect returns a Rectangle instance | [
"Rect",
"returns",
"a",
"Rectangle",
"instance"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/image/image.go#L11-L15 |
147,463 | pankona/gomo-simra | simra/fps/fps.go | Progress | func Progress() {
fpsTimerContainer.Range(func(_, v interface{}) bool {
fps := v.(*fps)
if id, fired := fps.progress(); fired {
fpsTimerContainer.Delete(id)
}
return true
})
} | go | func Progress() {
fpsTimerContainer.Range(func(_, v interface{}) bool {
fps := v.(*fps)
if id, fired := fps.progress(); fired {
fpsTimerContainer.Delete(id)
}
return true
})
} | [
"func",
"Progress",
"(",
")",
"{",
"fpsTimerContainer",
".",
"Range",
"(",
"func",
"(",
"_",
",",
"v",
"interface",
"{",
"}",
")",
"bool",
"{",
"fps",
":=",
"v",
".",
"(",
"*",
"fps",
")",
"\n",
"if",
"id",
",",
"fired",
":=",
"fps",
".",
"prog... | // Progress progresses elapsed frames for all timers | [
"Progress",
"progresses",
"elapsed",
"frames",
"for",
"all",
"timers"
] | 90dc6493157a6a46357be5a14d966d2f032f868e | https://github.com/pankona/gomo-simra/blob/90dc6493157a6a46357be5a14d966d2f032f868e/simra/fps/fps.go#L46-L54 |
147,464 | pingcap/go-themis | oracle/oracles/remote.go | GetTimestamp | func (t *remoteOracle) GetTimestamp() (uint64, error) {
var err error
for i := 0; i < maxRetryCnt; i++ {
ts, e := t.c.GoGetTimestamp().GetTS()
if e == nil {
return uint64((ts.Physical << epochShiftBits) + ts.Logical), nil
}
err = errors.Trace(e)
}
return 0, err
} | go | func (t *remoteOracle) GetTimestamp() (uint64, error) {
var err error
for i := 0; i < maxRetryCnt; i++ {
ts, e := t.c.GoGetTimestamp().GetTS()
if e == nil {
return uint64((ts.Physical << epochShiftBits) + ts.Logical), nil
}
err = errors.Trace(e)
}
return 0, err
} | [
"func",
"(",
"t",
"*",
"remoteOracle",
")",
"GetTimestamp",
"(",
")",
"(",
"uint64",
",",
"error",
")",
"{",
"var",
"err",
"error",
"\n",
"for",
"i",
":=",
"0",
";",
"i",
"<",
"maxRetryCnt",
";",
"i",
"++",
"{",
"ts",
",",
"e",
":=",
"t",
".",
... | // GetTimestamp gets timestamp from remote data source. | [
"GetTimestamp",
"gets",
"timestamp",
"from",
"remote",
"data",
"source",
"."
] | dbb996606c1d1fe8571fd9ac6da2254c76d2c5c9 | https://github.com/pingcap/go-themis/blob/dbb996606c1d1fe8571fd9ac6da2254c76d2c5c9/oracle/oracles/remote.go#L38-L48 |
147,465 | alexandrevicenzi/go-sse | channel.go | SendMessage | func (c *Channel) SendMessage(message *Message) {
c.lastEventID = message.id
for c, open := range c.clients {
if open {
c.send <- message
}
}
} | go | func (c *Channel) SendMessage(message *Message) {
c.lastEventID = message.id
for c, open := range c.clients {
if open {
c.send <- message
}
}
} | [
"func",
"(",
"c",
"*",
"Channel",
")",
"SendMessage",
"(",
"message",
"*",
"Message",
")",
"{",
"c",
".",
"lastEventID",
"=",
"message",
".",
"id",
"\n\n",
"for",
"c",
",",
"open",
":=",
"range",
"c",
".",
"clients",
"{",
"if",
"open",
"{",
"c",
... | // SendMessage broadcast a message to all clients in a channel. | [
"SendMessage",
"broadcast",
"a",
"message",
"to",
"all",
"clients",
"in",
"a",
"channel",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/channel.go#L19-L27 |
147,466 | alexandrevicenzi/go-sse | client.go | SendMessage | func (c *Client) SendMessage(message *Message) {
c.lastEventID = message.id
c.send <- message
} | go | func (c *Client) SendMessage(message *Message) {
c.lastEventID = message.id
c.send <- message
} | [
"func",
"(",
"c",
"*",
"Client",
")",
"SendMessage",
"(",
"message",
"*",
"Message",
")",
"{",
"c",
".",
"lastEventID",
"=",
"message",
".",
"id",
"\n",
"c",
".",
"send",
"<-",
"message",
"\n",
"}"
] | // SendMessage sends a message to client. | [
"SendMessage",
"sends",
"a",
"message",
"to",
"client",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/client.go#L19-L22 |
147,467 | alexandrevicenzi/go-sse | sse.go | NewServer | func NewServer(options *Options) *Server {
if options == nil {
options = &Options{
Logger: log.New(os.Stdout, "go-sse: ", log.LstdFlags),
}
}
if options.Logger == nil {
options.Logger = log.New(ioutil.Discard, "", log.LstdFlags)
}
s := &Server{
options,
make(map[string]*Channel),
make(chan *Client... | go | func NewServer(options *Options) *Server {
if options == nil {
options = &Options{
Logger: log.New(os.Stdout, "go-sse: ", log.LstdFlags),
}
}
if options.Logger == nil {
options.Logger = log.New(ioutil.Discard, "", log.LstdFlags)
}
s := &Server{
options,
make(map[string]*Channel),
make(chan *Client... | [
"func",
"NewServer",
"(",
"options",
"*",
"Options",
")",
"*",
"Server",
"{",
"if",
"options",
"==",
"nil",
"{",
"options",
"=",
"&",
"Options",
"{",
"Logger",
":",
"log",
".",
"New",
"(",
"os",
".",
"Stdout",
",",
"\"",
"\"",
",",
"log",
".",
"L... | // NewServer creates a new SSE server. | [
"NewServer",
"creates",
"a",
"new",
"SSE",
"server",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L22-L45 |
147,468 | alexandrevicenzi/go-sse | sse.go | SendMessage | func (s *Server) SendMessage(channel string, message *Message) {
if len(channel) == 0 {
s.options.Logger.Print("broadcasting message to all channels.")
for _, ch := range s.channels {
ch.SendMessage(message)
}
} else if _, ok := s.channels[channel]; ok {
s.options.Logger.Printf("message sent to channel '%... | go | func (s *Server) SendMessage(channel string, message *Message) {
if len(channel) == 0 {
s.options.Logger.Print("broadcasting message to all channels.")
for _, ch := range s.channels {
ch.SendMessage(message)
}
} else if _, ok := s.channels[channel]; ok {
s.options.Logger.Printf("message sent to channel '%... | [
"func",
"(",
"s",
"*",
"Server",
")",
"SendMessage",
"(",
"channel",
"string",
",",
"message",
"*",
"Message",
")",
"{",
"if",
"len",
"(",
"channel",
")",
"==",
"0",
"{",
"s",
".",
"options",
".",
"Logger",
".",
"Print",
"(",
"\"",
"\"",
")",
"\n... | // SendMessage broadcast a message to all clients in a channel.
// If channel is an empty string, it will broadcast the message to all channels. | [
"SendMessage",
"broadcast",
"a",
"message",
"to",
"all",
"clients",
"in",
"a",
"channel",
".",
"If",
"channel",
"is",
"an",
"empty",
"string",
"it",
"will",
"broadcast",
"the",
"message",
"to",
"all",
"channels",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L101-L114 |
147,469 | alexandrevicenzi/go-sse | sse.go | ClientCount | func (s *Server) ClientCount() int {
i := 0
for _, channel := range s.channels {
i += channel.ClientCount()
}
return i
} | go | func (s *Server) ClientCount() int {
i := 0
for _, channel := range s.channels {
i += channel.ClientCount()
}
return i
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"ClientCount",
"(",
")",
"int",
"{",
"i",
":=",
"0",
"\n\n",
"for",
"_",
",",
"channel",
":=",
"range",
"s",
".",
"channels",
"{",
"i",
"+=",
"channel",
".",
"ClientCount",
"(",
")",
"\n",
"}",
"\n\n",
"retur... | // ClientCount returns the number of clients connected to this server. | [
"ClientCount",
"returns",
"the",
"number",
"of",
"clients",
"connected",
"to",
"this",
"server",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L129-L137 |
147,470 | alexandrevicenzi/go-sse | sse.go | HasChannel | func (s *Server) HasChannel(name string) bool {
_, ok := s.channels[name]
return ok
} | go | func (s *Server) HasChannel(name string) bool {
_, ok := s.channels[name]
return ok
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"HasChannel",
"(",
"name",
"string",
")",
"bool",
"{",
"_",
",",
"ok",
":=",
"s",
".",
"channels",
"[",
"name",
"]",
"\n",
"return",
"ok",
"\n",
"}"
] | // HasChannel returns true if the channel associated with name exists. | [
"HasChannel",
"returns",
"true",
"if",
"the",
"channel",
"associated",
"with",
"name",
"exists",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L140-L143 |
147,471 | alexandrevicenzi/go-sse | sse.go | GetChannel | func (s *Server) GetChannel(name string) (*Channel, bool) {
ch, ok := s.channels[name]
return ch, ok
} | go | func (s *Server) GetChannel(name string) (*Channel, bool) {
ch, ok := s.channels[name]
return ch, ok
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"GetChannel",
"(",
"name",
"string",
")",
"(",
"*",
"Channel",
",",
"bool",
")",
"{",
"ch",
",",
"ok",
":=",
"s",
".",
"channels",
"[",
"name",
"]",
"\n",
"return",
"ch",
",",
"ok",
"\n",
"}"
] | // GetChannel returns the channel associated with name or nil if not found. | [
"GetChannel",
"returns",
"the",
"channel",
"associated",
"with",
"name",
"or",
"nil",
"if",
"not",
"found",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L146-L149 |
147,472 | alexandrevicenzi/go-sse | sse.go | Channels | func (s *Server) Channels() []string {
channels := []string{}
for name := range s.channels {
channels = append(channels, name)
}
return channels
} | go | func (s *Server) Channels() []string {
channels := []string{}
for name := range s.channels {
channels = append(channels, name)
}
return channels
} | [
"func",
"(",
"s",
"*",
"Server",
")",
"Channels",
"(",
")",
"[",
"]",
"string",
"{",
"channels",
":=",
"[",
"]",
"string",
"{",
"}",
"\n\n",
"for",
"name",
":=",
"range",
"s",
".",
"channels",
"{",
"channels",
"=",
"append",
"(",
"channels",
",",
... | // Channels returns a list of all channels to the server. | [
"Channels",
"returns",
"a",
"list",
"of",
"all",
"channels",
"to",
"the",
"server",
"."
] | cdfb375b261850b6aafeddaa033baf3708a736de | https://github.com/alexandrevicenzi/go-sse/blob/cdfb375b261850b6aafeddaa033baf3708a736de/sse.go#L152-L160 |
147,473 | andybons/hipchat | hipchat.go | NewClient | func NewClient(authToken string) Client {
return Client{
AuthToken: authToken,
BaseURL: defaultBaseURL,
Transport: http.DefaultTransport,
}
} | go | func NewClient(authToken string) Client {
return Client{
AuthToken: authToken,
BaseURL: defaultBaseURL,
Transport: http.DefaultTransport,
}
} | [
"func",
"NewClient",
"(",
"authToken",
"string",
")",
"Client",
"{",
"return",
"Client",
"{",
"AuthToken",
":",
"authToken",
",",
"BaseURL",
":",
"defaultBaseURL",
",",
"Transport",
":",
"http",
".",
"DefaultTransport",
",",
"}",
"\n",
"}"
] | // NewClient allocates and returns a Client with the given authToken.
// By default, the client will use the publicly available HipChat servers.
// For internal or custom servers, set the BaseURL field of the Client. | [
"NewClient",
"allocates",
"and",
"returns",
"a",
"Client",
"with",
"the",
"given",
"authToken",
".",
"By",
"default",
"the",
"client",
"will",
"use",
"the",
"publicly",
"available",
"HipChat",
"servers",
".",
"For",
"internal",
"or",
"custom",
"servers",
"set"... | c9ecf9bd5709df68539effb29f65de8b4f1a89b0 | https://github.com/andybons/hipchat/blob/c9ecf9bd5709df68539effb29f65de8b4f1a89b0/hipchat.go#L98-L104 |
147,474 | andybons/hipchat | hipchat.go | getError | func getError(body []byte) error {
var errResp ErrorResponse
if err := json.Unmarshal(body, &errResp); err != nil {
return err
}
return errResp.Error
} | go | func getError(body []byte) error {
var errResp ErrorResponse
if err := json.Unmarshal(body, &errResp); err != nil {
return err
}
return errResp.Error
} | [
"func",
"getError",
"(",
"body",
"[",
"]",
"byte",
")",
"error",
"{",
"var",
"errResp",
"ErrorResponse",
"\n",
"if",
"err",
":=",
"json",
".",
"Unmarshal",
"(",
"body",
",",
"&",
"errResp",
")",
";",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
... | // getError unmarshals a HipChat error response from the request body and
// returns its error field. | [
"getError",
"unmarshals",
"a",
"HipChat",
"error",
"response",
"from",
"the",
"request",
"body",
"and",
"returns",
"its",
"error",
"field",
"."
] | c9ecf9bd5709df68539effb29f65de8b4f1a89b0 | https://github.com/andybons/hipchat/blob/c9ecf9bd5709df68539effb29f65de8b4f1a89b0/hipchat.go#L259-L265 |
147,475 | shafreeck/configo | rule/rule.go | parseCompExp | func parseCompExp(r string, pos int) (*vrange, int, error) {
i := pos
v := &vrange{}
const (
ce_start = iota
val_start
val_in
val_end
ce_end
)
st := ce_start
vstart := 0
vend := 0
lt := true
LOOP:
for ; i < len(r); i++ {
c := r[i]
switch c {
case '<', '>':
if st != ce_start {
return n... | go | func parseCompExp(r string, pos int) (*vrange, int, error) {
i := pos
v := &vrange{}
const (
ce_start = iota
val_start
val_in
val_end
ce_end
)
st := ce_start
vstart := 0
vend := 0
lt := true
LOOP:
for ; i < len(r); i++ {
c := r[i]
switch c {
case '<', '>':
if st != ce_start {
return n... | [
"func",
"parseCompExp",
"(",
"r",
"string",
",",
"pos",
"int",
")",
"(",
"*",
"vrange",
",",
"int",
",",
"error",
")",
"{",
"i",
":=",
"pos",
"\n",
"v",
":=",
"&",
"vrange",
"{",
"}",
"\n\n",
"const",
"(",
"ce_start",
"=",
"iota",
"\n",
"val_star... | //parse comparison expression | [
"parse",
"comparison",
"expression"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/rule/rule.go#L230-L330 |
147,476 | shafreeck/configo | load.go | Load | func Load(file string, v interface{}) error {
b, err := ioutil.ReadFile(file)
if err != nil {
return err
}
return Unmarshal(b, v)
} | go | func Load(file string, v interface{}) error {
b, err := ioutil.ReadFile(file)
if err != nil {
return err
}
return Unmarshal(b, v)
} | [
"func",
"Load",
"(",
"file",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"Unm... | //Load toml file and unmarshal to v, v shoud be a pointer | [
"Load",
"toml",
"file",
"and",
"unmarshal",
"to",
"v",
"v",
"shoud",
"be",
"a",
"pointer"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/load.go#L8-L15 |
147,477 | shafreeck/configo | load.go | Dump | func Dump(file string, v interface{}) error {
b, err := Marshal(v)
if err != nil {
return err
}
return ioutil.WriteFile(file, b, 0644)
} | go | func Dump(file string, v interface{}) error {
b, err := Marshal(v)
if err != nil {
return err
}
return ioutil.WriteFile(file, b, 0644)
} | [
"func",
"Dump",
"(",
"file",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"Marshal",
"(",
"v",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"return",
"ioutil",
".",
"WriteFi... | //Dump the object to file in toml format | [
"Dump",
"the",
"object",
"to",
"file",
"in",
"toml",
"format"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/load.go#L18-L25 |
147,478 | shafreeck/configo | load.go | Update | func Update(file string, v interface{}) error {
b, err := ioutil.ReadFile(file)
if err != nil {
return err
}
out, err := Patch(b, v)
if err != nil {
return err
}
return ioutil.WriteFile(file, out, 0644)
} | go | func Update(file string, v interface{}) error {
b, err := ioutil.ReadFile(file)
if err != nil {
return err
}
out, err := Patch(b, v)
if err != nil {
return err
}
return ioutil.WriteFile(file, out, 0644)
} | [
"func",
"Update",
"(",
"file",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"b",
",",
"err",
":=",
"ioutil",
".",
"ReadFile",
"(",
"file",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
"out",
",",
... | //Update an exist file | [
"Update",
"an",
"exist",
"file"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/load.go#L28-L39 |
147,479 | jjcollinge/logrus-appinsights | hook.go | New | func New(name string, conf Config) (*AppInsightsHook, error) {
if conf.InstrumentationKey == "" {
return nil, fmt.Errorf("InstrumentationKey is required and missing from configuration")
}
telemetryConf := appinsights.NewTelemetryConfiguration(conf.InstrumentationKey)
if conf.MaxBatchSize != 0 {
telemetryConf.Ma... | go | func New(name string, conf Config) (*AppInsightsHook, error) {
if conf.InstrumentationKey == "" {
return nil, fmt.Errorf("InstrumentationKey is required and missing from configuration")
}
telemetryConf := appinsights.NewTelemetryConfiguration(conf.InstrumentationKey)
if conf.MaxBatchSize != 0 {
telemetryConf.Ma... | [
"func",
"New",
"(",
"name",
"string",
",",
"conf",
"Config",
")",
"(",
"*",
"AppInsightsHook",
",",
"error",
")",
"{",
"if",
"conf",
".",
"InstrumentationKey",
"==",
"\"",
"\"",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
"(",
"\"",
"\"",
")",
... | // New returns an initialised logrus hook for Application Insights | [
"New",
"returns",
"an",
"initialised",
"logrus",
"hook",
"for",
"Application",
"Insights"
] | 9b66602d496a139e4722bdde32f0f1ac1c12d4a8 | https://github.com/jjcollinge/logrus-appinsights/blob/9b66602d496a139e4722bdde32f0f1ac1c12d4a8/hook.go#L38-L62 |
147,480 | jjcollinge/logrus-appinsights | hook.go | NewWithAppInsightsConfig | func NewWithAppInsightsConfig(name string, conf *appinsights.TelemetryConfiguration) (*AppInsightsHook, error) {
if conf == nil {
return nil, fmt.Errorf("Nil configuration provided")
}
if conf.InstrumentationKey == "" {
return nil, fmt.Errorf("InstrumentationKey is required in configuration")
}
telemetryClient... | go | func NewWithAppInsightsConfig(name string, conf *appinsights.TelemetryConfiguration) (*AppInsightsHook, error) {
if conf == nil {
return nil, fmt.Errorf("Nil configuration provided")
}
if conf.InstrumentationKey == "" {
return nil, fmt.Errorf("InstrumentationKey is required in configuration")
}
telemetryClient... | [
"func",
"NewWithAppInsightsConfig",
"(",
"name",
"string",
",",
"conf",
"*",
"appinsights",
".",
"TelemetryConfiguration",
")",
"(",
"*",
"AppInsightsHook",
",",
"error",
")",
"{",
"if",
"conf",
"==",
"nil",
"{",
"return",
"nil",
",",
"fmt",
".",
"Errorf",
... | // NewWithAppInsightsConfig returns an initialised logrus hook for Application Insights | [
"NewWithAppInsightsConfig",
"returns",
"an",
"initialised",
"logrus",
"hook",
"for",
"Application",
"Insights"
] | 9b66602d496a139e4722bdde32f0f1ac1c12d4a8 | https://github.com/jjcollinge/logrus-appinsights/blob/9b66602d496a139e4722bdde32f0f1ac1c12d4a8/hook.go#L65-L82 |
147,481 | jjcollinge/logrus-appinsights | hook.go | Fire | func (hook *AppInsightsHook) Fire(entry *logrus.Entry) error {
if !hook.async {
return hook.fire(entry)
}
// async - fire and forget
go hook.fire(entry)
return nil
} | go | func (hook *AppInsightsHook) Fire(entry *logrus.Entry) error {
if !hook.async {
return hook.fire(entry)
}
// async - fire and forget
go hook.fire(entry)
return nil
} | [
"func",
"(",
"hook",
"*",
"AppInsightsHook",
")",
"Fire",
"(",
"entry",
"*",
"logrus",
".",
"Entry",
")",
"error",
"{",
"if",
"!",
"hook",
".",
"async",
"{",
"return",
"hook",
".",
"fire",
"(",
"entry",
")",
"\n",
"}",
"\n",
"// async - fire and forget... | // Fire is invoked by logrus and sends log data to Application Insights. | [
"Fire",
"is",
"invoked",
"by",
"logrus",
"and",
"sends",
"log",
"data",
"to",
"Application",
"Insights",
"."
] | 9b66602d496a139e4722bdde32f0f1ac1c12d4a8 | https://github.com/jjcollinge/logrus-appinsights/blob/9b66602d496a139e4722bdde32f0f1ac1c12d4a8/hook.go#L111-L118 |
147,482 | shafreeck/configo | configo.go | unmarshalArray | func unmarshalArray(key, value string, v interface{}) error {
//construct a valid toml array
data := key + " = " + value
if err := toml.Unmarshal([]byte(data), v); err != nil {
return err
}
return nil
} | go | func unmarshalArray(key, value string, v interface{}) error {
//construct a valid toml array
data := key + " = " + value
if err := toml.Unmarshal([]byte(data), v); err != nil {
return err
}
return nil
} | [
"func",
"unmarshalArray",
"(",
"key",
",",
"value",
"string",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"//construct a valid toml array",
"data",
":=",
"key",
"+",
"\"",
"\"",
"+",
"value",
"\n",
"if",
"err",
":=",
"toml",
".",
"Unmarshal",
"("... | //parse a toml array | [
"parse",
"a",
"toml",
"array"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/configo.go#L94-L101 |
147,483 | shafreeck/configo | configo.go | Unmarshal | func Unmarshal(data []byte, v interface{}) error {
table, err := toml.Parse(data)
if err != nil {
return err
}
if err := toml.UnmarshalTable(table, v); err != nil {
return err
}
if err := applyDefault(reflect.ValueOf(v), false); err != nil {
return err
}
return nil
} | go | func Unmarshal(data []byte, v interface{}) error {
table, err := toml.Parse(data)
if err != nil {
return err
}
if err := toml.UnmarshalTable(table, v); err != nil {
return err
}
if err := applyDefault(reflect.ValueOf(v), false); err != nil {
return err
}
return nil
} | [
"func",
"Unmarshal",
"(",
"data",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"error",
"{",
"table",
",",
"err",
":=",
"toml",
".",
"Parse",
"(",
"data",
")",
"\n",
"if",
"err",
"!=",
"nil",
"{",
"return",
"err",
"\n",
"}",
"\n\n",
... | //Unmarshal data into struct v, v shoud be a pointer to struct | [
"Unmarshal",
"data",
"into",
"struct",
"v",
"v",
"shoud",
"be",
"a",
"pointer",
"to",
"struct"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/configo.go#L262-L276 |
147,484 | shafreeck/configo | configo.go | Marshal | func Marshal(v interface{}) ([]byte, error) {
rv := reflect.ValueOf(v)
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
pv := reflect.New(rv.Type())
pv.Elem().Set(rv)
if err := applyDefault(pv, true); err != nil {
return nil, err
}
return toml.Marshal(pv.Interface())
} | go | func Marshal(v interface{}) ([]byte, error) {
rv := reflect.ValueOf(v)
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
pv := reflect.New(rv.Type())
pv.Elem().Set(rv)
if err := applyDefault(pv, true); err != nil {
return nil, err
}
return toml.Marshal(pv.Interface())
} | [
"func",
"Marshal",
"(",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"rv",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"for",
"rv",
".",
"Kind",
"(",
")",
"==",
"reflect",
".",
"Ptr",
"{",
"rv",
"=... | //Marshal v to configuration in toml format | [
"Marshal",
"v",
"to",
"configuration",
"in",
"toml",
"format"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/configo.go#L279-L291 |
147,485 | shafreeck/configo | configo.go | Patch | func Patch(base []byte, v interface{}) ([]byte, error) {
//Clone struct v, v shoud not be modified
rv := reflect.ValueOf(v)
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
pv := reflect.New(rv.Type())
pv.Elem().Set(rv)
nv := pv.Interface()
//unmarshal base
table, err := toml.Parse(base)
if err != nil {
... | go | func Patch(base []byte, v interface{}) ([]byte, error) {
//Clone struct v, v shoud not be modified
rv := reflect.ValueOf(v)
for rv.Kind() == reflect.Ptr {
rv = rv.Elem()
}
pv := reflect.New(rv.Type())
pv.Elem().Set(rv)
nv := pv.Interface()
//unmarshal base
table, err := toml.Parse(base)
if err != nil {
... | [
"func",
"Patch",
"(",
"base",
"[",
"]",
"byte",
",",
"v",
"interface",
"{",
"}",
")",
"(",
"[",
"]",
"byte",
",",
"error",
")",
"{",
"//Clone struct v, v shoud not be modified",
"rv",
":=",
"reflect",
".",
"ValueOf",
"(",
"v",
")",
"\n",
"for",
"rv",
... | //Patch the base using the value from v, the new bytes returned
//combines the base's value and v's default value | [
"Patch",
"the",
"base",
"using",
"the",
"value",
"from",
"v",
"the",
"new",
"bytes",
"returned",
"combines",
"the",
"base",
"s",
"value",
"and",
"v",
"s",
"default",
"value"
] | 53ef1e8a2fd0c576d0fa7c94949947fbe3942564 | https://github.com/shafreeck/configo/blob/53ef1e8a2fd0c576d0fa7c94949947fbe3942564/configo.go#L295-L317 |
147,486 | soniakeys/quant | median/median.go | Paletted | func (q Quantizer) Paletted(img image.Image) *image.Paletted {
n := int(q)
if n > 256 {
n = 256
}
qz := newQuantizer(img, n)
if n > 1 {
qz.cluster() // cluster pixels by color
}
return qz.paletted() // generate paletted image from clusters
} | go | func (q Quantizer) Paletted(img image.Image) *image.Paletted {
n := int(q)
if n > 256 {
n = 256
}
qz := newQuantizer(img, n)
if n > 1 {
qz.cluster() // cluster pixels by color
}
return qz.paletted() // generate paletted image from clusters
} | [
"func",
"(",
"q",
"Quantizer",
")",
"Paletted",
"(",
"img",
"image",
".",
"Image",
")",
"*",
"image",
".",
"Paletted",
"{",
"n",
":=",
"int",
"(",
"q",
")",
"\n",
"if",
"n",
">",
"256",
"{",
"n",
"=",
"256",
"\n",
"}",
"\n",
"qz",
":=",
"newQ... | // Paletted performs color quantization and returns a paletted image.
//
// Returned is an image.Paletted with no more than q colors. Note though
// that image.Paletted is limited to 256 colors. | [
"Paletted",
"performs",
"color",
"quantization",
"and",
"returns",
"a",
"paletted",
"image",
".",
"Returned",
"is",
"an",
"image",
".",
"Paletted",
"with",
"no",
"more",
"than",
"q",
"colors",
".",
"Note",
"though",
"that",
"image",
".",
"Paletted",
"is",
... | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/median/median.go#L35-L45 |
147,487 | soniakeys/quant | median/median.go | Palette | func (q Quantizer) Palette(img image.Image) quant.Palette {
qz := newQuantizer(img, int(q))
if q > 1 {
qz.cluster() // cluster pixels by color
}
return qz.t
} | go | func (q Quantizer) Palette(img image.Image) quant.Palette {
qz := newQuantizer(img, int(q))
if q > 1 {
qz.cluster() // cluster pixels by color
}
return qz.t
} | [
"func",
"(",
"q",
"Quantizer",
")",
"Palette",
"(",
"img",
"image",
".",
"Image",
")",
"quant",
".",
"Palette",
"{",
"qz",
":=",
"newQuantizer",
"(",
"img",
",",
"int",
"(",
"q",
")",
")",
"\n",
"if",
"q",
">",
"1",
"{",
"qz",
".",
"cluster",
"... | // Palette performs color quantization and returns a quant.Palette object.
//
// Returned is a palette with no more than q colors. Q may be > 256. | [
"Palette",
"performs",
"color",
"quantization",
"and",
"returns",
"a",
"quant",
".",
"Palette",
"object",
".",
"Returned",
"is",
"a",
"palette",
"with",
"no",
"more",
"than",
"q",
"colors",
".",
"Q",
"may",
"be",
">",
"256",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/median/median.go#L50-L56 |
147,488 | soniakeys/quant | median/median.go | cluster | func (qz *quantizer) cluster() {
pq := new(queue)
// Initial cluster. populated at this point, but not analyzed.
c := &qz.cs[0]
var m uint32
i := 1
for {
// Only enqueue clusters that can be split.
if qz.setWidestChannel(c) {
heap.Push(pq, c)
}
// If no clusters have any color variation, mark the end ... | go | func (qz *quantizer) cluster() {
pq := new(queue)
// Initial cluster. populated at this point, but not analyzed.
c := &qz.cs[0]
var m uint32
i := 1
for {
// Only enqueue clusters that can be split.
if qz.setWidestChannel(c) {
heap.Push(pq, c)
}
// If no clusters have any color variation, mark the end ... | [
"func",
"(",
"qz",
"*",
"quantizer",
")",
"cluster",
"(",
")",
"{",
"pq",
":=",
"new",
"(",
"queue",
")",
"\n",
"// Initial cluster. populated at this point, but not analyzed.",
"c",
":=",
"&",
"qz",
".",
"cs",
"[",
"0",
"]",
"\n",
"var",
"m",
"uint32",
... | // Cluster by repeatedly splitting clusters.
// Use a heap as priority queue for picking clusters to split.
// The rule is to spilt the cluster with the most pixels.
// Terminate when the desired number of clusters has been populated
// or when clusters cannot be further split. | [
"Cluster",
"by",
"repeatedly",
"splitting",
"clusters",
".",
"Use",
"a",
"heap",
"as",
"priority",
"queue",
"for",
"picking",
"clusters",
"to",
"split",
".",
"The",
"rule",
"is",
"to",
"spilt",
"the",
"cluster",
"with",
"the",
"most",
"pixels",
".",
"Termi... | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/median/median.go#L171-L223 |
147,489 | soniakeys/quant | median/median.go | split | func (q *quantizer) split(s, c *cluster, m uint32) {
*c = *s // copy extent data
px := s.px
var v uint32
i := 0
last := len(px) - 1
for i <= last {
// Get color value in appropriate dimension.
r, g, b, _ := q.pxRGBA(int(px[i].x), int(px[i].y))
switch s.widestCh {
case rgbR:
v = r
case rgbG:
v = g
... | go | func (q *quantizer) split(s, c *cluster, m uint32) {
*c = *s // copy extent data
px := s.px
var v uint32
i := 0
last := len(px) - 1
for i <= last {
// Get color value in appropriate dimension.
r, g, b, _ := q.pxRGBA(int(px[i].x), int(px[i].y))
switch s.widestCh {
case rgbR:
v = r
case rgbG:
v = g
... | [
"func",
"(",
"q",
"*",
"quantizer",
")",
"split",
"(",
"s",
",",
"c",
"*",
"cluster",
",",
"m",
"uint32",
")",
"{",
"*",
"c",
"=",
"*",
"s",
"// copy extent data",
"\n",
"px",
":=",
"s",
".",
"px",
"\n",
"var",
"v",
"uint32",
"\n",
"i",
":=",
... | // split s into c and s at value m | [
"split",
"s",
"into",
"c",
"and",
"s",
"at",
"value",
"m"
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/median/median.go#L317-L372 |
147,490 | dafiti/go-instrument | newrelic.go | ExternalSegment | func (nr *NewRelic) ExternalSegment(url string) Segment {
return NewRelicExternalSegment{
newrelic.ExternalSegment{
StartTime: newrelic.StartSegmentNow(nr.txn),
URL: url,
},
}
} | go | func (nr *NewRelic) ExternalSegment(url string) Segment {
return NewRelicExternalSegment{
newrelic.ExternalSegment{
StartTime: newrelic.StartSegmentNow(nr.txn),
URL: url,
},
}
} | [
"func",
"(",
"nr",
"*",
"NewRelic",
")",
"ExternalSegment",
"(",
"url",
"string",
")",
"Segment",
"{",
"return",
"NewRelicExternalSegment",
"{",
"newrelic",
".",
"ExternalSegment",
"{",
"StartTime",
":",
"newrelic",
".",
"StartSegmentNow",
"(",
"nr",
".",
"txn... | // Create a external segment | [
"Create",
"a",
"external",
"segment"
] | 8f83375ad9263e7d743c4f16793d4b2dfebff427 | https://github.com/dafiti/go-instrument/blob/8f83375ad9263e7d743c4f16793d4b2dfebff427/newrelic.go#L25-L32 |
147,491 | dafiti/go-instrument | newrelic.go | Segment | func (nr *NewRelic) Segment(name string) Segment {
return NewRelicSegment{
newrelic.StartSegment(nr.txn, name),
}
} | go | func (nr *NewRelic) Segment(name string) Segment {
return NewRelicSegment{
newrelic.StartSegment(nr.txn, name),
}
} | [
"func",
"(",
"nr",
"*",
"NewRelic",
")",
"Segment",
"(",
"name",
"string",
")",
"Segment",
"{",
"return",
"NewRelicSegment",
"{",
"newrelic",
".",
"StartSegment",
"(",
"nr",
".",
"txn",
",",
"name",
")",
",",
"}",
"\n",
"}"
] | // Create a segment | [
"Create",
"a",
"segment"
] | 8f83375ad9263e7d743c4f16793d4b2dfebff427 | https://github.com/dafiti/go-instrument/blob/8f83375ad9263e7d743c4f16793d4b2dfebff427/newrelic.go#L35-L39 |
147,492 | soniakeys/quant | sierra.go | Draw | func (d Sierra24A) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point) {
pd, ok := dst.(*image.Paletted)
if !ok {
// dither211 currently requires a palette
draw.Draw(dst, r, src, sp, draw.Src)
return
}
// intersect r with both dst and src bounds, fix up sp.
ir := r.Intersect(pd.Bounds())... | go | func (d Sierra24A) Draw(dst draw.Image, r image.Rectangle, src image.Image, sp image.Point) {
pd, ok := dst.(*image.Paletted)
if !ok {
// dither211 currently requires a palette
draw.Draw(dst, r, src, sp, draw.Src)
return
}
// intersect r with both dst and src bounds, fix up sp.
ir := r.Intersect(pd.Bounds())... | [
"func",
"(",
"d",
"Sierra24A",
")",
"Draw",
"(",
"dst",
"draw",
".",
"Image",
",",
"r",
"image",
".",
"Rectangle",
",",
"src",
"image",
".",
"Image",
",",
"sp",
"image",
".",
"Point",
")",
"{",
"pd",
",",
"ok",
":=",
"dst",
".",
"(",
"*",
"imag... | // Draw performs error diffusion dithering.
//
// This method satisfies the draw.Drawer interface, implementing a dithering
// filter attributed to Frankie Sierra. It uses the kernel
//
// X 2
// 1 1 | [
"Draw",
"performs",
"error",
"diffusion",
"dithering",
".",
"This",
"method",
"satisfies",
"the",
"draw",
".",
"Drawer",
"interface",
"implementing",
"a",
"dithering",
"filter",
"attributed",
"to",
"Frankie",
"Sierra",
".",
"It",
"uses",
"the",
"kernel",
"X",
... | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/sierra.go#L25-L60 |
147,493 | soniakeys/quant | mean/mean.go | cluster | func (qz *quantizer) cluster() {
cs := qz.cs
half := len(cs) / 2
// cx is index of new cluster, populated at start of loop here, but
// not yet analyzed.
cx := 0
c := &cs[cx]
for {
qz.setPriority(c, cx < half) // compute statistics for new cluster
// determine cluster to split, sx
sx := -1
var maxP int
... | go | func (qz *quantizer) cluster() {
cs := qz.cs
half := len(cs) / 2
// cx is index of new cluster, populated at start of loop here, but
// not yet analyzed.
cx := 0
c := &cs[cx]
for {
qz.setPriority(c, cx < half) // compute statistics for new cluster
// determine cluster to split, sx
sx := -1
var maxP int
... | [
"func",
"(",
"qz",
"*",
"quantizer",
")",
"cluster",
"(",
")",
"{",
"cs",
":=",
"qz",
".",
"cs",
"\n",
"half",
":=",
"len",
"(",
"cs",
")",
"/",
"2",
"\n",
"// cx is index of new cluster, populated at start of loop here, but",
"// not yet analyzed.",
"cx",
":=... | // Cluster by repeatedly splitting clusters in two stages. For the first
// stage, prioritize by population and split tails off distribution in color
// dimension with widest range. For the second stage, prioritize by the
// product of population and color volume, and split at the mean of the color
// values in the d... | [
"Cluster",
"by",
"repeatedly",
"splitting",
"clusters",
"in",
"two",
"stages",
".",
"For",
"the",
"first",
"stage",
"prioritize",
"by",
"population",
"and",
"split",
"tails",
"off",
"distribution",
"in",
"color",
"dimension",
"with",
"widest",
"range",
".",
"F... | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/mean/mean.go#L138-L184 |
147,494 | soniakeys/quant | palette.go | IndexNear | func (p LinearPalette) IndexNear(c color.Color) int {
return p.Palette.Index(c)
} | go | func (p LinearPalette) IndexNear(c color.Color) int {
return p.Palette.Index(c)
} | [
"func",
"(",
"p",
"LinearPalette",
")",
"IndexNear",
"(",
"c",
"color",
".",
"Color",
")",
"int",
"{",
"return",
"p",
".",
"Palette",
".",
"Index",
"(",
"c",
")",
"\n",
"}"
] | // IndexNear returns the palette index of the nearest palette color.
//
// It simply wraps color.Palette.Index. | [
"IndexNear",
"returns",
"the",
"palette",
"index",
"of",
"the",
"nearest",
"palette",
"color",
".",
"It",
"simply",
"wraps",
"color",
".",
"Palette",
".",
"Index",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L36-L38 |
147,495 | soniakeys/quant | palette.go | ColorNear | func (p LinearPalette) ColorNear(c color.Color) color.Color {
return p.Palette.Convert(c)
} | go | func (p LinearPalette) ColorNear(c color.Color) color.Color {
return p.Palette.Convert(c)
} | [
"func",
"(",
"p",
"LinearPalette",
")",
"ColorNear",
"(",
"c",
"color",
".",
"Color",
")",
"color",
".",
"Color",
"{",
"return",
"p",
".",
"Palette",
".",
"Convert",
"(",
"c",
")",
"\n",
"}"
] | // Color near returns the nearest palette color.
//
// It simply wraps color.Palette.Convert. | [
"Color",
"near",
"returns",
"the",
"nearest",
"palette",
"color",
".",
"It",
"simply",
"wraps",
"color",
".",
"Palette",
".",
"Convert",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L43-L45 |
147,496 | soniakeys/quant | palette.go | IndexNear | func (t TreePalette) IndexNear(c color.Color) (i int) {
if t.Root == nil {
return -1
}
t.Search(c, func(leaf *Node) { i = leaf.Index })
return
} | go | func (t TreePalette) IndexNear(c color.Color) (i int) {
if t.Root == nil {
return -1
}
t.Search(c, func(leaf *Node) { i = leaf.Index })
return
} | [
"func",
"(",
"t",
"TreePalette",
")",
"IndexNear",
"(",
"c",
"color",
".",
"Color",
")",
"(",
"i",
"int",
")",
"{",
"if",
"t",
".",
"Root",
"==",
"nil",
"{",
"return",
"-",
"1",
"\n",
"}",
"\n",
"t",
".",
"Search",
"(",
"c",
",",
"func",
"(",... | // IndexNear returns the index of the nearest palette color. | [
"IndexNear",
"returns",
"the",
"index",
"of",
"the",
"nearest",
"palette",
"color",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L89-L95 |
147,497 | soniakeys/quant | palette.go | ColorNear | func (t TreePalette) ColorNear(c color.Color) (p color.Color) {
if t.Root == nil {
return color.RGBA64{0x7fff, 0x7fff, 0x7fff, 0xfff}
}
t.Search(c, func(leaf *Node) { p = leaf.Color })
return
} | go | func (t TreePalette) ColorNear(c color.Color) (p color.Color) {
if t.Root == nil {
return color.RGBA64{0x7fff, 0x7fff, 0x7fff, 0xfff}
}
t.Search(c, func(leaf *Node) { p = leaf.Color })
return
} | [
"func",
"(",
"t",
"TreePalette",
")",
"ColorNear",
"(",
"c",
"color",
".",
"Color",
")",
"(",
"p",
"color",
".",
"Color",
")",
"{",
"if",
"t",
".",
"Root",
"==",
"nil",
"{",
"return",
"color",
".",
"RGBA64",
"{",
"0x7fff",
",",
"0x7fff",
",",
"0x... | // ColorNear returns the nearest palette color. | [
"ColorNear",
"returns",
"the",
"nearest",
"palette",
"color",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L98-L104 |
147,498 | soniakeys/quant | palette.go | Search | func (t TreePalette) Search(c color.Color, f func(leaf *Node)) {
r, g, b, _ := c.RGBA()
var lt bool
var s func(*Node)
s = func(n *Node) {
switch n.Type {
case TLeaf:
f(n)
return
case TSplitR:
lt = r < n.Split
case TSplitG:
lt = g < n.Split
case TSplitB:
lt = b < n.Split
}
if lt {
s(n... | go | func (t TreePalette) Search(c color.Color, f func(leaf *Node)) {
r, g, b, _ := c.RGBA()
var lt bool
var s func(*Node)
s = func(n *Node) {
switch n.Type {
case TLeaf:
f(n)
return
case TSplitR:
lt = r < n.Split
case TSplitG:
lt = g < n.Split
case TSplitB:
lt = b < n.Split
}
if lt {
s(n... | [
"func",
"(",
"t",
"TreePalette",
")",
"Search",
"(",
"c",
"color",
".",
"Color",
",",
"f",
"func",
"(",
"leaf",
"*",
"Node",
")",
")",
"{",
"r",
",",
"g",
",",
"b",
",",
"_",
":=",
"c",
".",
"RGBA",
"(",
")",
"\n",
"var",
"lt",
"bool",
"\n"... | // Search searches for the given color and calls f for the node representing
// the nearest color. | [
"Search",
"searches",
"for",
"the",
"given",
"color",
"and",
"calls",
"f",
"for",
"the",
"node",
"representing",
"the",
"nearest",
"color",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L108-L131 |
147,499 | soniakeys/quant | palette.go | ColorPalette | func (t TreePalette) ColorPalette() color.Palette {
if t.Root == nil {
return nil
}
p := make(color.Palette, 0, t.Leaves)
t.Walk(func(leaf *Node, i int) {
p = append(p, leaf.Color)
})
return p
} | go | func (t TreePalette) ColorPalette() color.Palette {
if t.Root == nil {
return nil
}
p := make(color.Palette, 0, t.Leaves)
t.Walk(func(leaf *Node, i int) {
p = append(p, leaf.Color)
})
return p
} | [
"func",
"(",
"t",
"TreePalette",
")",
"ColorPalette",
"(",
")",
"color",
".",
"Palette",
"{",
"if",
"t",
".",
"Root",
"==",
"nil",
"{",
"return",
"nil",
"\n",
"}",
"\n",
"p",
":=",
"make",
"(",
"color",
".",
"Palette",
",",
"0",
",",
"t",
".",
... | // ColorPalette returns a color.Palette corresponding to the TreePalette. | [
"ColorPalette",
"returns",
"a",
"color",
".",
"Palette",
"corresponding",
"to",
"the",
"TreePalette",
"."
] | 0a3861b3bd925b434c67c93a15633ced8475092d | https://github.com/soniakeys/quant/blob/0a3861b3bd925b434c67c93a15633ced8475092d/palette.go#L134-L143 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.