This repository has been archived by the owner on May 6, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
160 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
--[=[ | ||
@function Transparency | ||
@within Blend | ||
@param background Color3 -- The background colour. | ||
@param foreground Color3 -- The foreground colour. | ||
@param transparency number -- The transparency value. | ||
@return Color3 -- The resulting colour. | ||
]=] | ||
local function applyTransparency(background: Color3, foreground: Color3, transparency: number): Color3 | ||
local alpha = 1 - transparency | ||
|
||
local red = foreground.R * alpha + background.R * transparency | ||
local green = foreground.G * alpha + background.G * transparency | ||
local blue = foreground.B * alpha + background.B * transparency | ||
|
||
return Color3.new(red, green, blue) | ||
end | ||
|
||
return applyTransparency |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
local BasicallyIdentical = require(script.Parent.Parent._Util.BasicallyIdentical) | ||
|
||
return function() | ||
local Filter = require(script.Parent.Transparency) | ||
|
||
local FOREGROUND = Color3.fromHex("#FF6B00") | ||
local BACKGROUND = Color3.fromHex("#252525") | ||
|
||
local RESULTS = { | ||
[0] = FOREGROUND, | ||
[13] = Color3.fromHex("#E36204"), | ||
[50] = Color3.fromHex("#914712"), | ||
[94] = Color3.fromHex("#322922"), | ||
[100] = Color3.fromHex("#252525"), | ||
} | ||
|
||
it("throws if arguments are incorrect types", function() | ||
expect(function() | ||
Filter(true) | ||
end).to.throw() | ||
|
||
expect(function() | ||
Filter(BACKGROUND, true) | ||
end).to.throw() | ||
|
||
expect(function() | ||
Filter(BACKGROUND, FOREGROUND, true) | ||
end).to.throw() | ||
end) | ||
|
||
for transparencyPercent, result in pairs(RESULTS) do | ||
local testName = string.format("correctly applies filter with transparency %d%%", transparencyPercent) | ||
|
||
it(testName, function() | ||
local transparency = transparencyPercent / 100 | ||
local filterResult = Filter(BACKGROUND, FOREGROUND, transparency) | ||
|
||
expect(BasicallyIdentical(result, filterResult)).to.equal(true) | ||
end) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters