<commit_before>local class = require '30log'
local json = require 'json'
local Slide = require 'slide'

local ImageSlide = Slide:extend("ImageSlide")

function ImageSlide:init(x, y, width, height, data_filename, font)
  self.super:init()
  self.x, self.y = x, y
  self.padding = 0.1
  self.width, self.height = width, height
  self:reset()
  self.image = nil

  util.file_watch(data_filename, function(content)
    local data = json.decode(content)
    self.duration = data.duration
    self.image = resource.load_image(data.file)
  end)
end

function ImageSlide:draw()
  self.super:tick()
  local padding = self.padding
  self.image:draw(self.width * padding, self.height * padding,
                  self.width * (1 - padding), self.height * (1 - padding))
end

function ImageSlide:reset()
  self.super:reset()
end

function ImageSlide:is_done()
  return (self.super.active_time > self.duration)
end

return ImageSlide<commit_msg>Added parameter in json for specifying image padding<commit_after>local class = require '30log'
local json = require 'json'
local Slide = require 'slide'

local ImageSlide = Slide:extend("ImageSlide")

function ImageSlide:init(x, y, width, height, data_filename, font)
  self.super:init()
  self.x, self.y = x, y
  self.padding = 0
  self.width, self.height = width, height
  self:reset()
  self.image = nil

  util.file_watch(data_filename, function(content)
    local data = json.decode(content)
    self.duration = data.duration
    self.image = resource.load_image(data.file)
    if data.padding then
      self.padding = data.padding
    end
  end)
end

function ImageSlide:draw()
  self.super:tick()
  local padding = self.padding
  self.image:draw(self.width * padding, self.height * padding,
                  self.width * (1 - padding), self.height * (1 - padding))
end

function ImageSlide:reset()
  self.super:reset()
end

function ImageSlide:is_done()
  return (self.super.active_time > self.duration)
end

return ImageSlide
{'fraction_non_alphanumeric': 0.11636178861788618, 'fraction_numerical': 0.005589430894308943, 'mean_word_length': 3.910224438902743, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6224537', 'n_tokens_mistral': 648, 'n_tokens_neox': 638, 'n_words': 164}