--# Main --[[ Author: Anatoly Version: 1 Description: Creates a Color() function that returns color() from a #HEX or by color name. Copyright 2019 Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ]] -- colors1 function setup() displayMode(FULLSCREEN) scrollY = 0 scrollYAcc = 0 scrollYAccMax = 100 scrollYAccMin = -100 touching = false infoState = 0 infoVisibility = 0 COLORS = _colors -- Sort alphabetically. table.sort(COLORS, function(a, b) return a.n < b.n end) end function showInfo() infoState = 1 end function hideInfo() infoState = 2 end function draw() scrollY = scrollY + scrollYAcc if scrollYAcc < 1.5 and not touching then scrollYAcc = scrollYAcc + .05 elseif touching then scrollYAcc = scrollYAcc * .8 end if scrollYAcc > scrollYAccMax then scrollYAcc = scrollYAccMax elseif scrollYAcc < scrollYAccMin then scrollYAcc = scrollYAccMin end if scrollY > #COLORS * 50 + 100 then scrollY = -HEIGHT scrollYAcc = 1.5 elseif scrollY < -HEIGHT then scrollY = -HEIGHT scrollYAcc = 0 showInfo() end if scrollY > 100-HEIGHT then hideInfo() end if infoState == 1 and infoVisibility < 20 then infoVisibility = infoVisibility + 1 elseif infoState == 2 and infoVisibility > 0 then infoVisibility = infoVisibility - 1 end background(0) for a, b in pairs(COLORS) do -- BG strokeWidth(40) stroke(b.c or color(0, 255)) line(50, HEIGHT - 50 * a + scrollY, WIDTH-50, HEIGHT - 50 * a + scrollY) -- TEXT strokeWidth(0) --fill(colors["invert-"..b.n] or color(0, 0)) fill(0) if (b.c.r <= 50 and b.c.g <= 50 and b.c.b <= 50) then fill(255) end fontSize(40) font("CourierNewPS-BoldMT") text(b.n, WIDTH*.5, HEIGHT - 50 * a + scrollY) -- COMPARISERS for d, e in ipairs({"white", "white-50", "black", "red", "green", "blue"}) do fill(Color(e)) ellipse(50 + (d-1) * 25, HEIGHT - 50 * a + scrollY, 20) end end if infoVisibility > 0 then fill(255 * (infoVisibility / 20), 255) fontSize(100) font("MarkerFelt-Wide") text("Colors v1", WIDTH*.5, HEIGHT*.5) fill(127 * (infoVisibility / 20), 255) fontSize(50) font("Noteworthy-Light") text("Created by Anatoly.", WIDTH*.5, HEIGHT*.5-100) end end function touched(t) if t.state == BEGAN then touching = true elseif t.state == MOVING then scrollYAcc = scrollYAcc + t.deltaY *.2 else -- END touching = false end end