Skip to content

Commit

Permalink
Update to latest Umka
Browse files Browse the repository at this point in the history
  • Loading branch information
vtereshkov committed Apr 14, 2024
1 parent f4f698f commit c9d076c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ UmPlot: A plotting library for [Umka](https://github.com/vtereshkov/umka-lang) b
import "umplot.um"
fn main() {
plt := umplot.init(4)
plt := umplot::init(4)
for i := 0; i < 4; i++ {
plt.series[i].name = sprintf("Sine wave %d", i + 1)
Expand All @@ -17,7 +17,7 @@ fn main() {
}
}
plt.series[1].style.kind = umplot.STYLE_SCATTER
plt.series[1].style.kind = .scatter
plt.titles.graph = "UmPlot demo"
plt.titles.x = "Time (seconds)"
Expand Down
22 changes: 11 additions & 11 deletions umplot.um
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
const (
STYLE_LINE* = 1
STYLE_SCATTER*
)

type (
Point* = struct {
x, y: real
}

Kind* = enum {
line = 1
scatter
}

Style* = struct {
kind: int
kind: Kind
color: uint32
width: real
}
Expand Down Expand Up @@ -54,7 +54,7 @@ fn (s: ^Series) add*(x, y: real) {
s.points = append(s.points, Point{x, y})
}

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

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

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

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

return plt
}
Expand Down
4 changes: 2 additions & 2 deletions umplottest.um
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import "umplot.um"

fn main() {
plt := umplot.init(4)
plt := umplot::init(4)

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

plt.series[1].style.kind = umplot.STYLE_SCATTER
plt.series[1].style.kind = .scatter

plt.titles.graph = "UmPlot demo"
plt.titles.x = "Time (seconds)"
Expand Down

0 comments on commit c9d076c

Please sign in to comment.