mirror of
https://github.com/aseprite/aseprite.git
synced 2025-01-30 15:32:38 +00:00
Add some tests for Palette, Color, and app.command
This commit is contained in:
parent
a5c733290e
commit
0e6a76e500
33
scripts/app_command.lua
Normal file
33
scripts/app_command.lua
Normal file
@ -0,0 +1,33 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
local s = Sprite(32, 32)
|
||||
assert(s.width == 32)
|
||||
assert(s.height == 32)
|
||||
|
||||
s:resize(50, 40)
|
||||
assert(s.width == 50)
|
||||
assert(s.height == 40)
|
||||
|
||||
-- Undo/Redo
|
||||
|
||||
local pc = app.command.Undo()
|
||||
assert(s.width == 32)
|
||||
assert(s.height == 32)
|
||||
|
||||
local pc = app.command.Redo()
|
||||
assert(s.width == 50)
|
||||
assert(s.height == 40)
|
||||
|
||||
-- NewLayer
|
||||
|
||||
assert(#s.layers == 1)
|
||||
app.command.NewLayer{top=true}
|
||||
assert(#s.layers == 2)
|
||||
assert(s.layers[2].isImage)
|
||||
|
||||
app.command.NewLayer{top=true, group=true}
|
||||
assert(#s.layers == 3)
|
||||
assert(s.layers[3].isGroup)
|
40
scripts/color.lua
Normal file
40
scripts/color.lua
Normal file
@ -0,0 +1,40 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
local a, b
|
||||
|
||||
a = Color()
|
||||
assert(a.red == 0)
|
||||
assert(a.green == 0)
|
||||
assert(a.blue == 0)
|
||||
assert(a.alpha == 0)
|
||||
|
||||
a = Color{ r=100, g=50, b=10 }
|
||||
b = Color(100, 50, 10)
|
||||
assert(a.red == 100)
|
||||
assert(a.green == 50)
|
||||
assert(a.blue == 10)
|
||||
assert(a.alpha == 255)
|
||||
assert(a == b)
|
||||
|
||||
a = Color{ red=200, green=100, blue=20, alpha=200 }
|
||||
b = Color(200, 100, 20, 200)
|
||||
assert(a.red == 200)
|
||||
assert(a.green == 100)
|
||||
assert(a.blue == 20)
|
||||
assert(a.alpha == 200)
|
||||
assert(a == b)
|
||||
|
||||
a = Color{ h=180, s=0.4, v=0.5, a=200 }
|
||||
b = Color{ hue=180, saturation=0.4, value=0.5, alpha=200 }
|
||||
assert(a.hue == 180)
|
||||
assert(a.saturation == 0.4)
|
||||
assert(a.value == 0.5)
|
||||
assert(a.alpha == 200)
|
||||
assert(b.hue == 180)
|
||||
assert(b.saturation == 0.4)
|
||||
assert(b.value == 0.5)
|
||||
assert(b.alpha == 200)
|
||||
assert(a == b)
|
21
scripts/palette.lua
Normal file
21
scripts/palette.lua
Normal file
@ -0,0 +1,21 @@
|
||||
-- Copyright (C) 2018 David Capello
|
||||
--
|
||||
-- This file is released under the terms of the MIT license.
|
||||
-- Read LICENSE.txt for more information.
|
||||
|
||||
local p = Palette(32)
|
||||
assert(#p == 32)
|
||||
for i = 0,#p-1 do
|
||||
assert(p:getColor(i) == Color(0, 0, 0))
|
||||
end
|
||||
|
||||
p:resize(4)
|
||||
assert(#p == 4)
|
||||
p:setColor(0, Color(255, 8, 32))
|
||||
p:setColor(1, Color(250, 4, 30))
|
||||
p:setColor(2, Color(240, 3, 20))
|
||||
p:setColor(3, Color(210, 2, 10))
|
||||
assert(p:getColor(0) == Color(255, 8, 32))
|
||||
assert(p:getColor(1) == Color(250, 4, 30))
|
||||
assert(p:getColor(2) == Color(240, 3, 20))
|
||||
assert(p:getColor(3) == Color(210, 2, 10))
|
Loading…
x
Reference in New Issue
Block a user