Screen cutting helper

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
kbmonkey
Party member
Posts: 139
Joined: Tue Sep 01, 2015 12:19 pm
Location: Sydney
Contact:

Screen cutting helper

Post by kbmonkey »

Just sharing this module I whipped up to assist me in cutting up screen regions. If it helps anyone, great! To wit:

Code: Select all

    cutter = require("cutter")
    -- function cutter.cut(width, height, [alignment], [container])

    -- a box 50% of the screen size (Blue)
    box1 = cutter.cut(0.5, 0.5, "center")

    -- a box half the height of the first box, aligned to the bottom (Green)
    box2 = cutter.cut(1, 0.5, "bottom", box1)

    -- a box half the width of the previous, left aligned (Red)
    box3 = cutter.cut(0.5, 1, "left", box2)
cutter-module2.png
cutter-module2.png (4.17 KiB) Viewed 731 times
Alignments can be: left, right, top, bottom, top left, top right, bottom left, bottom right

The .love includes an interactive demo.
Attachments
cutter-module.love
(3.41 KiB) Downloaded 46 times
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest