mirror of
https://github.com/lalbornoz/roar.git
synced 2024-12-22 20:36:37 +00:00
js/{blit,shader}.js: merged into js/gfx.js.
index.html: updates script URIs.
This commit is contained in:
parent
88f8efe56c
commit
72aa916dc8
@ -138,9 +138,8 @@
|
||||
|
||||
<script src="js/lex.js"></script>
|
||||
<script src="js/matrix.js"></script>
|
||||
<script src="js/blit.js"></script>
|
||||
<script src="js/gfx.js"></script>
|
||||
<script src="js/tool.js"></script>
|
||||
<script src="js/shader.js"></script>
|
||||
<script src="js/draw.js"></script>
|
||||
|
||||
<script src="js/ui/brush.js"></script>
|
||||
|
@ -1,3 +1,62 @@
|
||||
var shader = (function(){
|
||||
var fn_str, fn, lex
|
||||
var exports = {}
|
||||
var animating = false
|
||||
|
||||
exports.init = function(){
|
||||
lex = new Lex (0, 0)
|
||||
exports.build(demo_shader.innerHTML)
|
||||
}
|
||||
exports.build = function (fn_str){
|
||||
try {
|
||||
new_fn = new Function('lex', 'x', 'y', 'w', 'h', 't', fn_str)
|
||||
new_fn(lex, 0, 0, 1, 1, 0)
|
||||
}
|
||||
catch (e) {
|
||||
throw 'Shader execution error'
|
||||
}
|
||||
exports.fn = fn = new_fn
|
||||
return fn
|
||||
}
|
||||
exports.run = function(canvas){
|
||||
var t = +new Date
|
||||
shader.canvas = shader.canvas || canvas
|
||||
var w = shader.canvas.w, h = shader.canvas.h
|
||||
shader.canvas.forEach(function(lex, x, y){
|
||||
fn(lex, x, y, w, h, t)
|
||||
lex.build()
|
||||
})
|
||||
}
|
||||
exports.toggle = function(state){
|
||||
animating = typeof state == "boolean" ? state : ! animating
|
||||
shader_fps_el.classList.toggle('hidden')
|
||||
return animating
|
||||
}
|
||||
exports.pause = function(){
|
||||
animating = false
|
||||
shader_fps_el.classList.add('hidden')
|
||||
shader.fps_time = 0
|
||||
}
|
||||
exports.play = function(){
|
||||
animating = true
|
||||
shader_fps_el.classList.remove('hidden')
|
||||
}
|
||||
exports.animate = function (t){
|
||||
requestAnimationFrame(exports.animate)
|
||||
if (! animating) { return }
|
||||
if (shader.fps_time){
|
||||
var ms = Date.now() - shader.fps_time
|
||||
fps = 1000 / ms
|
||||
shader_fps_el.innerHTML = (fps | 0) + ' fps'
|
||||
}
|
||||
shader.fps_time = Date.now()
|
||||
exports.run(canvas)
|
||||
}
|
||||
|
||||
return exports
|
||||
|
||||
})()
|
||||
|
||||
var blit = (function(){
|
||||
var blit = {}
|
||||
blit.and = blit.atop = function(A, B, x, y){
|
58
js/shader.js
58
js/shader.js
@ -1,58 +0,0 @@
|
||||
var shader = (function(){
|
||||
var fn_str, fn, lex
|
||||
var exports = {}
|
||||
var animating = false
|
||||
|
||||
exports.init = function(){
|
||||
lex = new Lex (0, 0)
|
||||
exports.build(demo_shader.innerHTML)
|
||||
}
|
||||
exports.build = function (fn_str){
|
||||
try {
|
||||
new_fn = new Function('lex', 'x', 'y', 'w', 'h', 't', fn_str)
|
||||
new_fn(lex, 0, 0, 1, 1, 0)
|
||||
}
|
||||
catch (e) {
|
||||
throw 'Shader execution error'
|
||||
}
|
||||
exports.fn = fn = new_fn
|
||||
return fn
|
||||
}
|
||||
exports.run = function(canvas){
|
||||
var t = +new Date
|
||||
shader.canvas = shader.canvas || canvas
|
||||
var w = shader.canvas.w, h = shader.canvas.h
|
||||
shader.canvas.forEach(function(lex, x, y){
|
||||
fn(lex, x, y, w, h, t)
|
||||
lex.build()
|
||||
})
|
||||
}
|
||||
exports.toggle = function(state){
|
||||
animating = typeof state == "boolean" ? state : ! animating
|
||||
shader_fps_el.classList.toggle('hidden')
|
||||
return animating
|
||||
}
|
||||
exports.pause = function(){
|
||||
animating = false
|
||||
shader_fps_el.classList.add('hidden')
|
||||
shader.fps_time = 0
|
||||
}
|
||||
exports.play = function(){
|
||||
animating = true
|
||||
shader_fps_el.classList.remove('hidden')
|
||||
}
|
||||
exports.animate = function (t){
|
||||
requestAnimationFrame(exports.animate)
|
||||
if (! animating) { return }
|
||||
if (shader.fps_time){
|
||||
var ms = Date.now() - shader.fps_time
|
||||
fps = 1000 / ms
|
||||
shader_fps_el.innerHTML = (fps | 0) + ' fps'
|
||||
}
|
||||
shader.fps_time = Date.now()
|
||||
exports.run(canvas)
|
||||
}
|
||||
|
||||
return exports
|
||||
|
||||
})()
|
Loading…
Reference in New Issue
Block a user