Skip to content

Commit c9d076c

Browse files
committed
Update to latest Umka
1 parent f4f698f commit c9d076c

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ UmPlot: A plotting library for [Umka](https://github.com/vtereshkov/umka-lang) b
66
import "umplot.um"
77
88
fn main() {
9-
plt := umplot.init(4)
9+
plt := umplot::init(4)
1010
1111
for i := 0; i < 4; i++ {
1212
plt.series[i].name = sprintf("Sine wave %d", i + 1)
@@ -17,7 +17,7 @@ fn main() {
1717
}
1818
}
1919
20-
plt.series[1].style.kind = umplot.STYLE_SCATTER
20+
plt.series[1].style.kind = .scatter
2121
2222
plt.titles.graph = "UmPlot demo"
2323
plt.titles.x = "Time (seconds)"

umplot.um

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
const (
2-
STYLE_LINE* = 1
3-
STYLE_SCATTER*
4-
)
5-
61
type (
72
Point* = struct {
83
x, y: real
94
}
105

6+
Kind* = enum {
7+
line = 1
8+
scatter
9+
}
10+
1111
Style* = struct {
12-
kind: int
12+
kind: Kind
1313
color: uint32
1414
width: real
1515
}
@@ -54,7 +54,7 @@ fn (s: ^Series) add*(x, y: real) {
5454
s.points = append(s.points, Point{x, y})
5555
}
5656

57-
fn init*(numSeries: int = 1, kind: int = STYLE_LINE): Plot {
57+
fn init*(numSeries: int = 1, kind: Kind = .line): Plot {
5858
plt := Plot{series: make([]Series, numSeries)}
5959

6060
const getDefaultColors = fn (numColors: int): []uint32 {
@@ -77,12 +77,12 @@ fn init*(numSeries: int = 1, kind: int = STYLE_LINE): Plot {
7777

7878
for i := 0; i < numSeries; i++ {
7979
plt.series[i].name = ""
80-
plt.series[i].style = Style{kind: kind, color: defaultColors[i], width: 3.0}
80+
plt.series[i].style = {kind: kind, color: defaultColors[i], width: 3.0}
8181
}
8282

83-
plt.grid = Grid{xNumLines: 5, yNumLines: 5, color: 0xFF505050, fontSize: 12, visible: true, labelled: true}
84-
plt.titles = Titles{x: "", y: "", graph: "", color: plt.grid.color, fontSize: plt.grid.fontSize, visible: true}
85-
plt.legend = Legend{visible: true}
83+
plt.grid = {xNumLines: 5, yNumLines: 5, color: 0xFF505050, fontSize: 12, visible: true, labelled: true}
84+
plt.titles = {x: "", y: "", graph: "", color: plt.grid.color, fontSize: plt.grid.fontSize, visible: true}
85+
plt.legend = {visible: true}
8686

8787
return plt
8888
}

umplottest.um

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import "umplot.um"
22

33
fn main() {
4-
plt := umplot.init(4)
4+
plt := umplot::init(4)
55

66
for i := 0; i < 4; i++ {
77
plt.series[i].name = sprintf("Sine wave %d", i + 1)
@@ -12,7 +12,7 @@ fn main() {
1212
}
1313
}
1414

15-
plt.series[1].style.kind = umplot.STYLE_SCATTER
15+
plt.series[1].style.kind = .scatter
1616

1717
plt.titles.graph = "UmPlot demo"
1818
plt.titles.x = "Time (seconds)"

0 commit comments

Comments
 (0)