diff --git a/graphics/elements/hbar.lua b/graphics/elements/hbar.lua index f200bee..37e1550 100644 --- a/graphics/elements/hbar.lua +++ b/graphics/elements/hbar.lua @@ -28,9 +28,7 @@ local function hbar(args) assert(bar_width > 0, "graphics.elements.hbar: too small for bar") -- set background blit string - for _ = 1, bar_width do - bkg = bkg .. args.bar_fg_bg.blit_bkg - end + bkg = util.strrep(args.bar_fg_bg.blit_bkg, bar_width) -- handle data changes function e.on_update(fraction) diff --git a/graphics/elements/rectangle.lua b/graphics/elements/rectangle.lua index f1b177d..069ef2b 100644 --- a/graphics/elements/rectangle.lua +++ b/graphics/elements/rectangle.lua @@ -38,11 +38,9 @@ local function rectangle(args) assert(border_width_h * 2 <= e.frame.h, "graphics.elements.rectangle: border too thick for height") -- form the basic and top/bottom blit strings - for _ = 1, e.frame.w do - spaces = spaces .. " " - blit_fg = blit_fg .. e.fg_bg.blit_fgd - blit_bg_top_bot = blit_bg_top_bot .. border_blit - end + spaces = util.strrep(" ", e.frame.w) + blit_fg = util.strrep(e.fg_bg.blit_fgd, e.frame.w) + blit_bg_top_bot = util.strrep(border_blit, e.frame.w) -- form the body blit strings (sides are border, inside is normal) for x = 1, e.frame.w do