Skip to content

Commit

Permalink
examples/times_table: clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
medvednikov committed Apr 14, 2019
1 parent eeb5713 commit f2801fb
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions examples/times_table/times_table.v
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,24 @@ fn main() {

// ui.Window uses native drawing API (Core Graphics, GDI+)
fn draw() {
// Horizontal header
gx.draw_rect(0, 0, WIN_SIZE, CELL_SIZE, HEADER_COLOR)
// Vertical header
gx.draw_rect(0, 0, CELL_SIZE, WIN_SIZE, HEADER_COLOR)
gx.draw_rect(0, 0, WIN_SIZE, CELL_SIZE, HEADER_COLOR) // Horizontal header
gx.draw_rect(0, 0, CELL_SIZE, WIN_SIZE, HEADER_COLOR) // Vertical header
for i := MIN; i <= MAX; i++ {
y := CELL_SIZE * (i - MIN)
for j := MIN; j <= MAX; j++ {
x := CELL_SIZE * (j - MIN)
// Skip top left corner
if i == MIN && j == MIN {
continue
}
// Draw the result
if ! (i == MIN && j == MIN) {
res := i * j
mut text_padding_x := (CELL_SIZE - FONT_SIZE) / 2 - 1
text_padding_y := text_padding_x - 3
if res < 10 {
text_padding_x += 9
}
gx.draw_text(x + text_padding_x, y + text_padding_y, res.str(), TEXT_CFG)
x := CELL_SIZE * (j - MIN)
res := i * j
mut text_padding_x := (CELL_SIZE - FONT_SIZE) / 2 - 1
text_padding_y := text_padding_x - 3
if res < 10 {
text_padding_x += 9
}
gx.draw_text(x + text_padding_x, y + text_padding_y, res.str(), TEXT_CFG)
}
// Horizontal lines
gx.draw_line(0, y, WIN_SIZE, y)
Expand Down

0 comments on commit f2801fb

Please sign in to comment.