Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Struct And Simulation Uebung 2 Monte Carlo
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Torda, Prof. Dr. Andrew Ernest
Struct And Simulation Uebung 2 Monte Carlo
Commits
58009410
Commit
58009410
authored
May 3, 2021
by
Andrew E. Torda
Browse files
Options
Downloads
Patches
Plain Diff
Before deleting the img image. Next step will be to try to just put text behind.
parent
7f3f2bad
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
screenplot.go
+41
-24
41 additions, 24 deletions
screenplot.go
with
41 additions
and
24 deletions
screenplot.go
+
41
−
24
View file @
58009410
...
...
@@ -4,27 +4,37 @@ package main
import
(
"fmt"
"github.com/gizak/termui/v3/drawille"
"image"
"image/color"
"image/draw"
ui
"github.com/gizak/termui/v3"
"github.com/gizak/termui/v3/widgets"
"image"
)
func
breaker
(
x
interface
{})
{}
func
scrnPlt
(
pi
,
stdErr
[]
float32
)
error
{
ui
.
Theme
.
Plot
.
Axes
=
ui
.
ColorBlack
nrmlStyle
:=
ui
.
NewStyle
(
ui
.
ColorBlack
,
ui
.
ColorClear
)
// invisStyle := ui.NewStyle (ui.ColorClear, ui.ColorClear)
thm
:=
ui
.
Theme
thm
.
Default
=
ui
.
NewStyle
(
ui
.
ColorBlack
,
ui
.
ColorWhite
,
ui
.
ModifierReverse
)
thm
.
Default
.
Fg
=
ui
.
ColorBlack
thm
.
Default
.
Bg
=
ui
.
ColorWhite
thm
.
Plot
.
Lines
=
[]
ui
.
Color
{
ui
.
ColorBlack
}
thm
.
Paragraph
.
Text
=
ui
.
NewStyle
(
ui
.
ColorBlack
,
ui
.
ColorWhite
)
thm
.
Block
.
Title
=
nrmlStyle
thm
.
Plot
.
Axes
=
ui
.
ColorBlack
thm
.
Default
=
ui
.
NewStyle
(
ui
.
ColorBlack
,
ui
.
ColorClear
)
thm
.
Block
.
Border
=
nrmlStyle
ui
.
Theme
=
thm
ptxt
:=
widgets
.
NewParagraph
()
ptxt
.
Text
=
"Hello World!"
ptxt
.
SetRect
(
0
,
0
,
25
,
5
)
for
i
:=
0
;
i
<
24
;
i
++
{
for
j
:=
0
;
j
<
800
;
j
++
{
ptxt
.
Text
+=
"."
}
ptxt
.
Text
+=
"
\n
"
}
ptxt
.
SetRect
(
0
,
0
,
80
,
24
)
ptxt
.
TextStyle
=
ui
.
NewStyle
(
ui
.
ColorWhite
,
ui
.
ColorWhite
)
p1
:=
widgets
.
NewPlot
()
p1
.
Title
=
"π"
...
...
@@ -38,28 +48,35 @@ func scrnPlt(pi, stdErr []float32) error {
}
p1
.
Data
=
data
}
breaker
(
thm
)
p1
.
SetRect
(
5
,
5
,
80
,
80
)
p1
.
AxesColor
=
ui
.
ColorBlack
p1
.
LineColors
=
[]
ui
.
Color
{
ui
.
ColorRed
}
p1
.
SetRect
(
2
,
2
,
80
,
24
)
p1
.
Block
.
TitleStyle
=
nrmlStyle
p1
.
AxesColor
=
ui
.
ColorBlack
// p1.LineColors = []ui.Color{ui.ColorBlack, ui.ColorBlack}
p1
.
SetRect
(
0
,
0
,
80
,
24
)
p1
.
Marker
=
widgets
.
MarkerBraille
p1
.
PlotType
=
widgets
.
ScatterPlot
// next: syntax OK, just doesn't work
r
:=
image
.
Rectangle
(
image
.
Rect
(
0
,
0
,
100
,
100
))
b
uf
:=
ui
.
NewBuffer
(
r
)
p1
.
Border
=
false
b
reaker
(
thm
)
cell
:=
drawille
.
Cell
{
Color
:
7
}
fmt
.
Println
(
cell
)
// buf.Fill(cell, r)
p1
.
Block
.
Draw
(
buf
)
m
:=
image
.
NewRGBA
(
image
.
Rect
(
0
,
0
,
80
,
24
))
// draw.Draw(m, m.Bounds(), &image.Uniform{color.White}, image.ZP, draw.Src)
draw
.
Draw
(
m
,
m
.
Bounds
(),
&
image
.
Uniform
{
color
.
White
},
image
.
ZP
,
draw
.
Src
)
img
:=
widgets
.
NewImage
(
m
)
img
.
SetRect
(
0
,
0
,
100
,
50
)
defer
fmt
.
Println
(
"m bounds"
,
m
.
Bounds
())
if
err
:=
ui
.
Init
();
err
!=
nil
{
return
fmt
.
Errorf
(
"failed to initialize termui: %w"
,
err
)
return
err
}
defer
ui
.
Close
()
ui
.
Render
(
p1
,
ptxt
)
ui
.
Render
(
img
,
ptxt
,
p1
)
for
e
:=
range
ui
.
PollEvents
()
{
if
e
.
Type
==
ui
.
KeyboardEvent
{
break
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment