diff options
Diffstat (limited to 'libs/o-ten-one')
-rw-r--r-- | libs/o-ten-one/baby.png | bin | 0 -> 3175 bytes | |||
-rw-r--r-- | libs/o-ten-one/handy-andy.otf | bin | 0 -> 26416 bytes | |||
-rw-r--r-- | libs/o-ten-one/heart.png | bin | 0 -> 3840 bytes | |||
-rw-r--r-- | libs/o-ten-one/init.lua | 393 | ||||
-rw-r--r-- | libs/o-ten-one/logo-mask.png | bin | 0 -> 21082 bytes | |||
-rw-r--r-- | libs/o-ten-one/logo.png | bin | 0 -> 7589 bytes | |||
-rw-r--r-- | libs/o-ten-one/timer.lua | 197 |
7 files changed, 590 insertions, 0 deletions
diff --git a/libs/o-ten-one/baby.png b/libs/o-ten-one/baby.png Binary files differnew file mode 100644 index 0000000..de89bb6 --- /dev/null +++ b/libs/o-ten-one/baby.png diff --git a/libs/o-ten-one/handy-andy.otf b/libs/o-ten-one/handy-andy.otf Binary files differnew file mode 100644 index 0000000..3e7abfa --- /dev/null +++ b/libs/o-ten-one/handy-andy.otf diff --git a/libs/o-ten-one/heart.png b/libs/o-ten-one/heart.png Binary files differnew file mode 100644 index 0000000..fc6933c --- /dev/null +++ b/libs/o-ten-one/heart.png diff --git a/libs/o-ten-one/init.lua b/libs/o-ten-one/init.lua new file mode 100644 index 0000000..7909357 --- /dev/null +++ b/libs/o-ten-one/init.lua @@ -0,0 +1,393 @@ +local splashlib = { + _VERSION = "v1.2.0", + _DESCRIPTION = "a 0.10.1 splash", + _URL = "https://github.com/love2d-community/splashes", + _LICENSE = [[Copyright (c) 2016 love-community members (as per git commits in repository above) + +This software is provided 'as-is', without any express or implied +warranty. In no event will the authors be held liable for any damages +arising from the use of this software. + +Permission is granted to anyone to use this software for any purpose, +including commercial applications, and to alter it and redistribute it +freely, subject to the following restrictions: + +1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgement in the product documentation would be + appreciated but is not required. +2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. +3. This notice may not be removed or altered from any source distribution. + +The font used in this splash is "Handy Andy" by www.andrzejgdula.com]] +} + +local current_module = (...):gsub("%.init$", "") +local current_folder = current_module:gsub("%.", "/") + +local timer = require(current_module .. ".timer") + +local colors = { + bg = {.42, .75, .89}, + white = { 1, 1, 1}, + blue = {.15, .67, .88}, + pink = {.91, .29, .6}, + shadow = {0, 0, 0, .33} +} + +-- patch shader:send if 'lighten' gets optimized away +local function safesend(shader, name, ...) + if shader:hasUniform(name) then + shader:send(name, ...) + end +end + +function splashlib.new(init) + init = init or {} + local self = {} + local width, height = love.graphics.getDimensions() + + self.background = init.background == nil and colors.bg or init.background + self.delay_before = init.delay_before or 0.3 + self.delay_after = init.delay_after or 0.7 + + if init.fill == "rain" then + local rain = {} + rain.spacing_x = 110 + rain.spacing_y = 80 + rain.image = love.graphics.newImage(current_folder .. "/baby.png") + rain.img_w = rain.image:getWidth() + rain.img_h = rain.image:getHeight() + rain.ox = -rain.img_w / 2 + rain.oy = -rain.img_h / 2 + rain.batch = love.graphics.newSpriteBatch(rain.image, 512) + rain.t = 0 + + local gradient = love.graphics.newMesh({ + { 0, height/4, 0, 0, 0, 0, 0, 0}, + {width, height/4, 0, 0, 0, 0, 0, 0}, + {width, height, 0, 0, 0, 0, 0, 200}, + { 0, height, 0, 0, 0, 0, 0, 200}, + }, "fan", "static") + do + local batch = rain.batch + + local sx = rain.spacing_x + local sy = rain.spacing_y + local ox = rain.ox + local oy = rain.oy + + local batch_w = 2 * math.ceil(love.graphics.getWidth() / sx) + 2 + local batch_h = 2 * math.ceil(love.graphics.getHeight() / sy) + 2 + + batch:clear() + + if batch:getBufferSize() < batch_w * batch_h then + batch:setBufferSize(batch_w * batch_h) + end + + for i = 0, batch_h - 1 do + for j = 0, batch_w - 1 do + local is_even = (j % 2) == 0 + local offset_y = is_even and 0 or sy / 2 + local x = ox + j * sx + local y = oy + i * sy + offset_y + batch:add(x, y) + end + end + + batch:flush() + end + + function self.fill() + local y = rain.spacing_y * select(2, math.modf(self.elapsed)) + + local small_y = -rain.spacing_y + y / 2 + local big_y = -rain.spacing_y + y + + love.graphics.setBlendMode("subtract") + love.graphics.setColor(1, 1, 1, .5) + love.graphics.draw(rain.batch, -rain.spacing_x, small_y, 0, 0.5, 0.5) + + love.graphics.setBlendMode("alpha") + love.graphics.setColor(.81, .81, .81, 1) + love.graphics.draw(rain.batch, -rain.spacing_x, big_y) + + love.graphics.draw(gradient) + end + end + + -- radial mask shader + self.maskshader = love.graphics.newShader((init.fill == "lighten" and "#define LIGHTEN" or "") .. [[ + + extern number radius; + extern number blur; + extern number shadow; + extern number lighten; + + vec4 desat(vec4 color) { + number g = dot(vec3(.299, .587, .114), color.rgb); + return vec4(g, g, g, 1.0) * lighten; + } + + vec4 effect(vec4 global_color, Image canvas, vec2 tc, vec2 _) + { + // radial mask + vec4 color = Texel(canvas, tc); + number r = length((tc - vec2(.5)) * love_ScreenSize.xy); + number s = smoothstep(radius+blur, radius-blur, r); + #ifdef LIGHTEN + color = color + desat(color) * (1.0-s); + #else + color.a *= s; + #endif + color.a *= global_color.a; + + // add shadow on lower diagonal along the circle + number sr = 7. * (1. - smoothstep(-.1,.04,(1.-tc.x)-tc.y)); + s = (1. - pow(exp(-pow(radius-r, 2.) / sr),3.) * shadow); + + return color - vec4(1, 1, 1, 0) * (1.0-s); + } + ]]) + + -- this shader makes the text appear from left to right + self.textshader = love.graphics.newShader[[ + extern number alpha; + + vec4 effect(vec4 color, Image logo, vec2 tc, vec2 sc) + { + //Probably would be better to just use the texture's dimensions instead; faster reaction. + vec2 sd = sc / love_ScreenSize.xy; + + if (sd.x <= alpha) { + return color * Texel(logo, tc); + } + return vec4(0); + } + ]] + + -- this shader applies a stroke effect on the logo using a gradient mask + self.logoshader = love.graphics.newShader[[ + //Using the pen extern, only draw out pixels that have their color below a certain treshold. + //Since pen will eventually equal 1.0, the full logo will be drawn out. + + extern number pen; + extern Image mask; + + vec4 effect(vec4 color, Image logo, vec2 tc, vec2 sc) + { + number value = max(Texel(mask, tc).r, max(Texel(mask, tc).g, Texel(mask, tc).b)); + number alpha = Texel(mask, tc).a; + + //probably could be optimzied... + if (alpha > 0.0) { + if (pen >= value) { + return color * Texel(logo, tc); + } + } + return vec4(0); + } + ]] + + self.canvas = love.graphics.newCanvas() + + self.elapsed = 0 + self.alpha = 1 + self.heart = { + sprite = love.graphics.newImage(current_folder .. "/heart.png"), + scale = 0, + rot = 0 + } + + self.stripes = { + rot = 0, + height = 100, + offset = -2 * width, + radius = math.max(width, height), + lighten = 0, + shadow = 0, + } + + self.text = { + obj = love.graphics.newText(love.graphics.newFont(current_folder .. "/handy-andy.otf", 22), "made with"), + alpha = 0 + } + self.text.width, self.text.height = self.text.obj:getDimensions() + + self.logo = { + sprite = love.graphics.newImage(current_folder .. "/logo.png"), + mask = love.graphics.newImage(current_folder .. "/logo-mask.png"), + pen = 0 + } + self.logo.width, self.logo.height = self.logo.sprite:getDimensions() + + safesend(self.maskshader, "radius", width*height) + safesend(self.maskshader, "lighten", 0) + safesend(self.maskshader, "shadow", 0) + safesend(self.maskshader, "blur", 1) + + safesend(self.textshader, "alpha", 0) + + safesend(self.logoshader, "pen", 0) + safesend(self.logoshader, "mask", self.logo.mask) + + timer.clear() + timer.script(function(wait) + + wait(self.delay_before) + + -- roll in stripes + timer.tween(0.5, self.stripes, {offset = 0}) + wait(0.3) + + timer.tween(0.3, self.stripes, {rot = -5 * math.pi / 18, height=height}) + wait(0.2) + + -- hackety hack: execute timer to update shader every frame + timer.every(0, function() + safesend(self.maskshader, "radius", self.stripes.radius) + safesend(self.maskshader, "lighten", self.stripes.lighten) + safesend(self.maskshader, "shadow", self.stripes.shadow) + safesend(self.textshader, "alpha", self.text.alpha) + safesend(self.logoshader, "pen", self.logo.pen) + end) + + -- focus the heart, desaturate the rest + timer.tween(0.2, self.stripes, {radius = 170*love.graphics.getDPIScale()}) + timer.tween(0.4, self.stripes, {lighten = .06}, "quad") + wait(0.2) + + timer.tween(0.2, self.stripes, {radius = 70*love.graphics.getDPIScale()}, "out-back") + timer.tween(0.7, self.stripes, {shadow = .3}, "back") + timer.tween(0.8, self.heart, {scale = 1}, "out-elastic", nil, 1, 0.3) + + -- write out the text + timer.tween(.75, self.text, {alpha = 1}, "linear") + + -- draw out the logo, in parts + local mult = 0.65 + local function tween_and_wait(dur, pen, easing) + timer.tween(mult * dur, self.logo, {pen = pen/255}, easing) + wait(mult * dur) + end + tween_and_wait(0.175, 50, "in-quad") -- L + tween_and_wait(0.300, 100, "in-out-quad") -- O + tween_and_wait(0.075, 115, "out-sine") -- first dot on O + tween_and_wait(0.075, 129, "out-sine") -- second dot on O + tween_and_wait(0.125, 153, "in-out-quad") -- \ + tween_and_wait(0.075, 179, "in-quad") -- / + tween_and_wait(0.250, 205, "in-quart") -- e->break + tween_and_wait(0.150, 230, "out-cubic") -- e finish + tween_and_wait(0.150, 244, "linear") -- () + tween_and_wait(0.100, 255, "linear") -- R + wait(0.4) + + -- no more skipping + wait(self.delay_after) + self.done = true + + timer.tween(0.3, self, {alpha = 0}) + wait(0.3) + + timer.clear() + + if self.onDone then self.onDone() end + end) + + self.draw = splashlib.draw + self.update = splashlib.update + self.skip = splashlib.skip + + return self +end + +function splashlib:draw() + local width, height = love.graphics.getDimensions() + + if self.background then + love.graphics.clear(self.background) + end + + if self.fill and self.elapsed > self.delay_before + 0.6 then + self:fill() + end + + self.canvas:renderTo(function() + love.graphics.push() + love.graphics.translate(width / 2, height / 2) + + love.graphics.push() + love.graphics.rotate(self.stripes.rot) + love.graphics.setColor(colors.pink) + love.graphics.rectangle( + "fill", + self.stripes.offset - width, -self.stripes.height, + width * 2, self.stripes.height + ) + + love.graphics.setColor(colors.blue) + love.graphics.rectangle( + "line", -- draw line for anti aliasing + -width - self.stripes.offset, 0, + width * 2, self.stripes.height + ) + love.graphics.rectangle( + "fill", + -width - self.stripes.offset, 0, + width * 2, self.stripes.height + ) + love.graphics.pop() + + love.graphics.setColor(1, 1, 1, self.heart.scale) + love.graphics.draw(self.heart.sprite, 0, 5, self.heart.rot, self.heart.scale, self.heart.scale, 43, 39) + love.graphics.pop() + end) + + love.graphics.setColor(1, 1, 1, self.alpha) + love.graphics.setShader(self.maskshader) + love.graphics.draw(self.canvas, 0,0) + love.graphics.setShader() + + love.graphics.push() + love.graphics.setShader(self.textshader) + love.graphics.draw( + self.text.obj, + (width / 2) - (self.text.width / 2), + (height / 2) - (self.text.height / 2) + (height / 10) + 62 + ) + love.graphics.pop() + + love.graphics.push() + love.graphics.setShader(self.logoshader) + love.graphics.draw( + self.logo.sprite, + (width / 2) - (self.logo.width / 4), + (height / 2) + (self.logo.height / 4) + (height / 10), + 0, 0.5, 0.5 + ) + love.graphics.setShader() + love.graphics.pop() +end + +function splashlib:update(dt) + timer.update(dt) + self.elapsed = self.elapsed + dt +end + +function splashlib:skip() + if not self.done then + self.done = true + + timer.tween(0.3, self, {alpha = 0}) + timer.after(0.3, function () + timer.clear() -- to be safe + if self.onDone then self.onDone() end + end) + end +end + +setmetatable(splashlib, { __call = function(self, ...) return self.new(...) end }) + +return splashlib diff --git a/libs/o-ten-one/logo-mask.png b/libs/o-ten-one/logo-mask.png Binary files differnew file mode 100644 index 0000000..b81d2ea --- /dev/null +++ b/libs/o-ten-one/logo-mask.png diff --git a/libs/o-ten-one/logo.png b/libs/o-ten-one/logo.png Binary files differnew file mode 100644 index 0000000..d3bfd49 --- /dev/null +++ b/libs/o-ten-one/logo.png diff --git a/libs/o-ten-one/timer.lua b/libs/o-ten-one/timer.lua new file mode 100644 index 0000000..ef4a750 --- /dev/null +++ b/libs/o-ten-one/timer.lua @@ -0,0 +1,197 @@ +--[[ +Copyright (c) 2010-2013 Matthias Richter + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +Except as contained in this notice, the name(s) of the above copyright holders +shall not be used in advertising or otherwise to promote the sale, use or +other dealings in this Software without prior written authorization. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. +]]-- + +local Timer = {} +Timer.__index = Timer + +local function _nothing_() end + +function Timer:update(dt) + local to_remove = {} + for handle, delay in pairs(self.functions) do + delay = delay - dt + if delay <= 0 then + to_remove[#to_remove+1] = handle + end + self.functions[handle] = delay + handle.func(dt, delay) + end + for _,handle in ipairs(to_remove) do + self.functions[handle] = nil + handle.after(handle.after) + end +end + +function Timer:during(delay, func, after) + local handle = {func = func, after = after or _nothing_} + self.functions[handle] = delay + return handle +end + +function Timer:after(delay, func) + return self:during(delay, _nothing_, func) +end + +function Timer:every(delay, func, count) + local count, handle = count or math.huge -- exploit below: math.huge - 1 = math.huge + + handle = self:after(delay, function(f) + if func(func) == false then return end + count = count - 1 + if count > 0 then + self.functions[handle] = delay + end + end) + return handle +end + +function Timer:cancel(handle) + self.functions[handle] = nil +end + +function Timer:clear() + self.functions = {} +end + +function Timer:script(f) + local co = coroutine.wrap(f) + co(function(t) + self:after(t, co) + coroutine.yield() + end) +end + +Timer.tween = setmetatable({ + -- helper functions + out = function(f) -- 'rotates' a function + return function(s, ...) return 1 - f(1-s, ...) end + end, + chain = function(f1, f2) -- concatenates two functions + return function(s, ...) return (s < .5 and f1(2*s, ...) or 1 + f2(2*s-1, ...)) * .5 end + end, + + -- useful tweening functions + linear = function(s) return s end, + quad = function(s) return s*s end, + cubic = function(s) return s*s*s end, + quart = function(s) return s*s*s*s end, + quint = function(s) return s*s*s*s*s end, + sine = function(s) return 1-math.cos(s*math.pi/2) end, + expo = function(s) return 2^(10*(s-1)) end, + circ = function(s) return 1 - math.sqrt(1-s*s) end, + + back = function(s,bounciness) + bounciness = bounciness or 1.70158 + return s*s*((bounciness+1)*s - bounciness) + end, + + bounce = function(s) -- magic numbers ahead + local a,b = 7.5625, 1/2.75 + return math.min(a*s^2, a*(s-1.5*b)^2 + .75, a*(s-2.25*b)^2 + .9375, a*(s-2.625*b)^2 + .984375) + end, + + elastic = function(s, amp, period) + amp, period = amp and math.max(1, amp) or 1, period or .3 + return (-amp * math.sin(2*math.pi/period * (s-1) - math.asin(1/amp))) * 2^(10*(s-1)) + end, +}, { + +-- register new tween +__call = function(tween, self, len, subject, target, method, after, ...) + -- recursively collects fields that are defined in both subject and target into a flat list + local function tween_collect_payload(subject, target, out) + for k,v in pairs(target) do + local ref = subject[k] + assert(type(v) == type(ref), 'Type mismatch in field "'..k..'".') + if type(v) == 'table' then + tween_collect_payload(ref, v, out) + else + local ok, delta = pcall(function() return (v-ref)*1 end) + assert(ok, 'Field "'..k..'" does not support arithmetic operations') + out[#out+1] = {subject, k, delta} + end + end + return out + end + + method = tween[method or 'linear'] -- see __index + local payload, t, args = tween_collect_payload(subject, target, {}), 0, {...} + + local last_s = 0 + return self:during(len, function(dt) + t = t + dt + local s = method(math.min(1, t/len), unpack(args)) + local ds = s - last_s + last_s = s + for _, info in ipairs(payload) do + local ref, key, delta = unpack(info) + ref[key] = ref[key] + delta * ds + end + end, after) +end, + +-- fetches function and generated compositions for method `key` +__index = function(tweens, key) + if type(key) == 'function' then return key end + + assert(type(key) == 'string', 'Method must be function or string.') + if rawget(tweens, key) then return rawget(tweens, key) end + + local function construct(pattern, f) + local method = rawget(tweens, key:match(pattern)) + if method then return f(method) end + return nil + end + + local out, chain = rawget(tweens,'out'), rawget(tweens,'chain') + return construct('^in%-([^-]+)$', function(...) return ... end) + or construct('^out%-([^-]+)$', out) + or construct('^in%-out%-([^-]+)$', function(f) return chain(f, out(f)) end) + or construct('^out%-in%-([^-]+)$', function(f) return chain(out(f), f) end) + or error('Unknown interpolation method: ' .. key) +end}) + +-- the module +local function new() + local timer = setmetatable({functions = {}, tween = Timer.tween}, Timer) + return setmetatable({ + new = new, + update = function(...) return timer:update(...) end, + during = function(...) return timer:during(...) end, + after = function(...) return timer:after(...) end, + every = function(...) return timer:every(...) end, + script = function(...) return timer:script(...) end, + cancel = function(...) return timer:cancel(...) end, + clear = function(...) return timer:clear(...) end, + tween = setmetatable({}, { + __index = Timer.tween, + __newindex = function(_,k,v) Timer.tween[k] = v end, + __call = function(t,...) return timer:tween(...) end, + }) + }, {__call = new}) +end + +return new() |