Serge Bazanski | 18c1a26 | 2022-07-07 14:24:53 +0200 | [diff] [blame] | 1 | local node = Node:extend('nodes.time', {}) |
| 2 | |
| 3 | local textFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 400) |
| 4 | local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 60) |
| 5 | |
| 6 | function node:init(config) |
| 7 | node.super.init(self, config) |
| 8 | self.timeFormat = self.timeFormat or '%H:%M' |
| 9 | self.dateFormat = self.dateFormat or '%Y/%m/%d' |
| 10 | end |
| 11 | |
| 12 | function node:render() |
| 13 | love.graphics.setColor( 0, 0, 0 ) |
| 14 | love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) |
| 15 | |
| 16 | love.graphics.setColor( 1.0, 1.0, 1.0 ) |
| 17 | |
| 18 | love.graphics.setFont(textFont); |
| 19 | love.graphics.printf(os.date(self.timeFormat), 0, 0.14*love.graphics.getHeight(), love.graphics.getWidth(), 'center'); |
| 20 | |
| 21 | love.graphics.setFont(smallFont); |
| 22 | love.graphics.printf(os.date(self.dateFormat), 0, 0.8*love.graphics.getHeight(), love.graphics.getWidth(), 'center'); |
| 23 | end |
| 24 | |
| 25 | return node |