ffnord-con-2015-2 hinzugefügt
This commit is contained in:
commit
de72f31357
18 changed files with 217 additions and 0 deletions
2
ffnord-con-2015-2/29c3/LICENSE.txt
Normal file
2
ffnord-con-2015-2/29c3/LICENSE.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
Font is Source Code Pro:
|
||||
http://store1.adobe.com/cfusion/store/html/index.cfm?event=displayFont&code=SOUC10003050
|
||||
BIN
ffnord-con-2015-2/29c3/bold.ttf
Normal file
BIN
ffnord-con-2015-2/29c3/bold.ttf
Normal file
Binary file not shown.
BIN
ffnord-con-2015-2/29c3/light.ttf
Normal file
BIN
ffnord-con-2015-2/29c3/light.ttf
Normal file
Binary file not shown.
26
ffnord-con-2015-2/29c3/node.lua
Normal file
26
ffnord-con-2015-2/29c3/node.lua
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
gl.setup(1280, 720)
|
||||
|
||||
local scramble = require "scramble"
|
||||
|
||||
util.auto_loader(_G)
|
||||
|
||||
function write(font, x, y, text, size, r, g, b, a)
|
||||
local s = scramble.scramble(text)
|
||||
return function()
|
||||
font:write(x, y, s(), size, r, g, b, a)
|
||||
end
|
||||
end
|
||||
|
||||
local lines = {
|
||||
write(light, 350, 0 * 144, "f/f.n[o", 140, 1 ,.706,0 ,.8),
|
||||
write(light, 50 , 1 * 144, "r.d/-]>", 140, .8 ,.8 ,.7 ,.8),
|
||||
write(light, 600, 2 * 144, "c.o-n/ ", 140, .863,0 ,.404,.8),
|
||||
write(light, 50 , 3 * 144, " / -2.0", 140, .7 ,.7 ,.7 ,.8),
|
||||
write(bold, 350, 4 * 144, "1(5).-2", 140, 0 ,.62 ,.878,.8),
|
||||
}
|
||||
|
||||
function node.render()
|
||||
for i = 1, #lines do
|
||||
lines[i]()
|
||||
end
|
||||
end
|
||||
90
ffnord-con-2015-2/29c3/scramble.lua
Normal file
90
ffnord-con-2015-2/29c3/scramble.lua
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
local sys = require "sys"
|
||||
local math = require "math"
|
||||
local table = require "table"
|
||||
local base = _G
|
||||
|
||||
module("scramble")
|
||||
|
||||
function scramble(text)
|
||||
local all_breaks = '/.-{}()[]<>|,;!?'
|
||||
local breaks = {}
|
||||
for idx = 1, #all_breaks do
|
||||
breaks[all_breaks:sub(idx, idx)]=true
|
||||
end
|
||||
-- print(#breaks)
|
||||
local mode = "up"
|
||||
local interval = 0.2
|
||||
local swap_end
|
||||
local next_action = sys.now() + interval
|
||||
local stack = {}
|
||||
|
||||
local function is_break(text, pos)
|
||||
local char = text:sub(pos, pos)
|
||||
local is_break = breaks[char]
|
||||
-- print(char, is_break)
|
||||
return is_break, char
|
||||
end
|
||||
local function random_break()
|
||||
local pos = math.random(1, #all_breaks)
|
||||
return all_breaks:sub(pos, pos)
|
||||
end
|
||||
local function replace2(text, pos, c1, c2)
|
||||
return text:sub(1, pos-1) .. c1 .. c2 .. text:sub(pos+2)
|
||||
end
|
||||
local function replace(text, pos, c)
|
||||
return text:sub(1, pos-1) .. c .. text:sub(pos+1)
|
||||
end
|
||||
|
||||
local function get()
|
||||
local now = sys.now()
|
||||
if now > next_action then
|
||||
-- print(mode)
|
||||
if mode == "up" then
|
||||
local pos, is_1_break, is_2_break, char_1, char_2
|
||||
repeat
|
||||
pos = math.random(1, #text-1)
|
||||
is_1_break, char_1 = is_break(text, pos)
|
||||
is_2_break, char_2 = is_break(text, pos+1)
|
||||
until is_1_break ~= is_2_break
|
||||
-- print(pos, is_1_break, is_2_break)
|
||||
|
||||
if is_1_break then
|
||||
table.insert(stack, {pos, random_break(), char_2})
|
||||
text = replace2(text, pos, char_2, random_break())
|
||||
else
|
||||
table.insert(stack, {pos, char_1, random_break()})
|
||||
text = replace2(text, pos, random_break(), char_1)
|
||||
end
|
||||
interval = interval - 0.01
|
||||
if interval < 0.02 then
|
||||
mode = "down"
|
||||
end
|
||||
elseif mode == "down" then
|
||||
local pos, char1, char2 = base.unpack(table.remove(stack, #stack))
|
||||
text = replace2(text, pos, char1, char2)
|
||||
interval = interval + 0.01
|
||||
if #stack == 0 then
|
||||
mode = "swap"
|
||||
swap_end = now + 15
|
||||
interval = 2
|
||||
end
|
||||
elseif mode == "swap" then
|
||||
local pos, is_break_char, _
|
||||
repeat
|
||||
pos = math.random(1, #text-1)
|
||||
is_break_char, _ = is_break(text, pos)
|
||||
until is_break_char
|
||||
text = replace(text, pos, random_break())
|
||||
if now > swap_end then
|
||||
interval = 0.2
|
||||
mode = "up"
|
||||
end
|
||||
end
|
||||
next_action = now + interval
|
||||
end
|
||||
return text
|
||||
end
|
||||
return get
|
||||
end
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue