Skip to content

Commit 43a9483

Browse files
committed
Luven v1.3
More utils for lights and ranges
1 parent f9de06c commit 43a9483

2 files changed

Lines changed: 53 additions & 7 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 Lionel Leeser
3+
Copyright (c) 2020 Lionel Leeser
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

luven/luven.lua

Lines changed: 52 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
local luven = {
2-
_VERSION = 'Luven v1.2',
2+
_VERSION = 'Luven v1.3',
33
_URL = 'https://github.com/chicogamedev/Luven',
44
_DESCRIPTION = 'A minimalist light engine for Löve2D',
55
_CONTRIBUTORS = 'Lionel Leeser, Pedro Gimeno (Help with camera)',
66
_LICENSE = [[
77
MIT License
88
9-
Copyright (c) 2019 Lionel Leeser
9+
Copyright (c) 2020 Lionel Leeser
1010
1111
Permission is hereby granted, free of charge, to any person obtaining a copy
1212
of this software and associated documentation files (the "Software"), to deal
@@ -460,6 +460,28 @@ function luven.getLightCount()
460460
return count
461461
end
462462

463+
-- ///////////////////////////////////////////////
464+
-- /// Luven utils functions
465+
-- ///////////////////////////////////////////////
466+
467+
function luven.newColor(r, g, b)
468+
return { r, g, b }
469+
end
470+
471+
function luven.newColorRange(minR, minG, minB, maxR, maxG, maxB)
472+
minR = minR or 0
473+
minG = minG or 0
474+
minB = minB or 0
475+
maxR = maxR or 0
476+
maxG = maxG or 0
477+
maxB = maxB or 0
478+
return { min = { minR, minG, minB }, max = { maxR, maxG, maxB } }
479+
end
480+
481+
function luven.newNumberRange(minN, maxN)
482+
return { min = minN, max = maxN }
483+
end
484+
463485
-- ///////////////////////////////////////////////
464486
-- /// Luven lights functions
465487
-- ///////////////////////////////////////////////
@@ -608,13 +630,21 @@ function luven.moveLight(lightId, dx, dy)
608630
currentLights[lightId].y = currentLights[index].y + dy
609631
end
610632

611-
function luven.setLightPower(lightId, power)
612-
currentLights[lightId].power = power
633+
function luven.setLightPower(lightId, p)
634+
currentLights[lightId].power = p
635+
end
636+
637+
function luven.setLightPowerRange(lightId, r)
638+
currentLights[lightId].powerRange = r
613639
end
614640

615641
-- param : color = { r, g, b } (values between 0 - 1)
616-
function luven.setLightColor(lightId, color)
617-
currentLights[lightId].color = color
642+
function luven.setLightColor(lightId, c)
643+
currentLights[lightId].color = c
644+
end
645+
646+
function luven.setLightColorRange(lightId, r)
647+
currentLights[lightId].colorRange = r
618648
end
619649

620650
function luven.setLightPosition(lightId, x, y)
@@ -626,6 +656,10 @@ function luven.setLightRotation(lightId, dr)
626656
currentLights[lightId].angle = dr
627657
end
628658

659+
function luven.setLightSpeedRange(lightId, r)
660+
currentLights[lightId].speedRange = r
661+
end
662+
629663
function luven.setLightScale(lightId, sx, sy)
630664
sx = sx or 1
631665
sy = sy or sx
@@ -638,10 +672,18 @@ function luven.getLightPower(lightId)
638672
return currentLights[lightId].power
639673
end
640674

675+
function luven.getLightPowerRange(lightId)
676+
return currentLights[lightId].powerRange
677+
end
678+
641679
function luven.getLightColor(lightId)
642680
return currentLights[lightId].color
643681
end
644682

683+
function luven.getLightColorRange(lightId)
684+
return currentLights[lightId].colorRange
685+
end
686+
645687
function luven.getLightPosition(lightId)
646688
return currentLights[lightId].x, currentLights[lightId].y
647689
end
@@ -650,6 +692,10 @@ function luven.getLightRotation(lightId)
650692
return currentLights[lightId].angle
651693
end
652694

695+
function luven.getLightSpeedRange(lightId)
696+
return currentLights[lightId].speedRange
697+
end
698+
653699
function luven.getLightScale(lightId)
654700
return currentLights[lightId].scaleX, currentLights[lightId].scaleY
655701
end

0 commit comments

Comments
 (0)