-
Notifications
You must be signed in to change notification settings - Fork 3
/
option.go
77 lines (66 loc) · 2.51 KB
/
option.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package ui
import (
"github.com/cenkalti/backoff/v4"
"os/exec"
"time"
)
// Option configures a Renderer to statically change its default behaviour.
type Option = func(r *Renderer)
// NOTE: There are more options defined in impl*.go, all starting with Opt<X>
// OptMRunCommand replaces the default run command (go run -v .) with any other command generator.
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMRunCommand(runCmd func() *exec.Cmd) Option {
return func(r *Renderer) {
r.runCmd = runCmd
}
}
// OptMWatchFiles replaces the default set of files to watch for changes (["."]).
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMWatchFiles(filePaths []string) Option {
return func(r *Renderer) {
r.watchFiles = filePaths
}
}
// OptMBackoff changes the default backoff algorithm used when trying to connect to the new code.
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMBackoff(backOff backoff.BackOff) Option {
return func(r *Renderer) {
r.backOff = backOff
}
}
// OptMPartialRenderEvery changes the default duration between partial renders (loading a partial render takes a little
// time and slows down the full render if too frequent).
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMPartialRenderEvery(duration time.Duration) Option {
return func(r *Renderer) {
r.partialRenderEvery = duration
}
}
// OptMZoom changes the default scaling factor (> 1)
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMZoom(zoom float64) Option {
return func(r *Renderer) {
r.zoomFactor = zoom
}
}
// OptMResInv changes the default image pixels per rendererd pixel
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMResInv(resInv int) Option {
return func(r *Renderer) {
r.implState.ResInv = resInv
}
}
// OptMColorMode changes the default color mode of the renderer
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMColorMode(colorMode int) Option {
return func(r *Renderer) {
r.implState.ColorMode = colorMode % r.impl.ColorModes()
}
}
// OptMSmoothCamera renders camera frames while dragging the mouse if enabled (2D/3D). Disabled by default.
// WARNING: Need to run again the main renderer to apply a change of this option.
func OptMSmoothCamera(smoothCamera bool) Option {
return func(r *Renderer) {
r.smoothCamera = smoothCamera
}
}