1
Destacar 0
Fork 0

14 Commits (3f46284dbedce166c46b8b9a16a8c03598886a32)

Autor SHA1 Mensaje Fecha
  Lucas Stadler 9108c467b9 Listen only on localhost %!s(int64=9) %!d(string=hace) años
  Lucas Stadler bc730a6188 support listing the availlable scripts. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 75aa0c80f4 rename /script/* to /scripts/* for consistency. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 86cf6d152e initial support for scripts. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler a43bf573de allow cors requests for world and stats. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 1902cd3a26 serve websocket connections on separate path. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 4145f00578 serve trixl on a shorter url as well. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler e5775b46e0 expose time of last action in stats. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler d50abe128d add save and load api calls. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler b99be1407c add maintenance and monitoring routes. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 87cf1c4caa serve everything using express. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 7b5b532c73 be less annoying. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler d03cc45643 send and receive arrays of pixls. %!s(int64=12) %!d(string=hace) años
  Lucas Stadler 575fe87640 load and send pixls via websockets. %!s(int64=12) %!d(string=hace) años
lu/lp - git.papill0n.org

1 Commits (3efe3ad6ea9eef4a5a1af0d392868e0ee06a44cc)

Autor SHA1 Nachricht Datum
  Lucas Stadler 10c90f5a7f hello world using grammatical framework. vor 12 Jahren
lp - git.papill0n.org

Sin Descripción

index.html 7.8KB

    <!doctype html> <html> <head> <title>.pixl</title> <meta charset="utf-8" /> <style type="text/css"> body { overflow: hidden; } canvas { position: absolute; top: 0; left: 0; } #status { position: absolute; bottom: 0; right: 0; } #pos, #online { display: inline-block; vertical-align: bottom; } #online { width: 20px; height: 20px; background-color: green; } </style> </head> <body> <canvas id="stage"></canvas> <span id="status"> <span id="pos"></span> <span id="online"></span> </span> <script> window.polyfill = {}; polyfill.movement = function(ev) { ev.movementX = ev.movementX || ev.mozMovementX || ev.webkitMovementX; ev.movementY = ev.movementY || ev.mozMovementY || ev.webkitMovementY; return ev; }; Math.sign = Math.sign || function(n) { if (n < 0) { return -1; } else if (n > 0) { return 1; } else { return 0; } }; </script> <script> window.pixl = {}; pixl.stage = document.querySelector("#stage"); pixl.ctx = stage.getContext("2d"); pixl.status = { pos: document.querySelector("#pos"), online: document.querySelector("#online") }; pixl.window = {w: window.innerWidth, h: window.innerHeight}; pixl.world = {}; pixl.pos = {x: 0, y: 0}; pixl.color = "black"; pixl.size = 20; pixl.stage.width = pixl.window.w; pixl.stage.height = pixl.window.h; pixl.to_world = function(screen_pos) { return {x: Math.floor((screen_pos.x - pixl.window.w / 2 + pixl.pos.x * pixl.size) / pixl.size), y: Math.floor((screen_pos.y - pixl.window.h / 2 + pixl.pos.y * pixl.size) / pixl.size)}; } pixl.to_screen = function(world_pos) { return {x: pixl.window.w / 2 + (world_pos.x - pixl.pos.x) * pixl.size, y: pixl.window.h / 2 + (world_pos.y - pixl.pos.y) * pixl.size}; } pixl.area = {}; pixl.area.w2 = function() { return Math.round(pixl.window.w / pixl.size / 2); }; pixl.area.h2 = function() { return Math.round(pixl.window.h / pixl.size / 2); }; pixl.at = function(pos) { var p = pixl.world[pos.x + "," + pos.y]; return p !== undefined && p.color !== "white"; } pixl.draw_pixl = function(pos, color, options) { var color = color || pixl.color; pixl.ctx.fillStyle = color; var options = options || {}; var pos = options.rawValue ? pos : {x: Math.round(pos.x), y: Math.round(pos.y)}; var screen_pos = pixl.to_screen(pos); pixl.ctx.fillRect(screen_pos.x, screen_pos.y, pixl.size, pixl.size); pixl.world[pos.x + "," + pos.y] = {color: color}; var send = options.hasOwnProperty('send') ? options.send : true; if (pixl.online && send) { pixl.ws.send(JSON.stringify([{x: pos.x, y: pos.y, color: color}])); } } pixl.redraw = function() { pixl.ctx.clearRect(0, 0, pixl.window.w, pixl.window.h); var w2 = Math.round(pixl.window.w / pixl.size / 2); var h2 = Math.round(pixl.window.h / pixl.size / 2); for (var x = pixl.pos.x - w2; x < pixl.pos.x + w2; x++) { for (var y = pixl.pos.y - h2; y < pixl.pos.y + h2; y++) { var pt = pixl.world[[x, y]]; if (pt !== undefined) { pixl.draw_pixl({x: x, y: y}, pt.color, {send: false}); } } } } pixl.redraw(); pixl.stage.addEventListener("wheel", function(ev) { ev.preventDefault(); pixl.size += (pixl.size / 10) * Math.sign(ev.deltaY); if (pixl.size < 5) { pixl.size = 5; } else if (pixl.size > pixl.window.w / 2) { pixl.size = Math.round(pixl.window.w / 2); } requestAnimationFrame(pixl.redraw); }); window.addEventListener("resize", function(ev) { pixl.window.w = window.innerWidth; pixl.window.h = window.innerHeight; pixl.stage.width = pixl.window.w; pixl.stage.height = pixl.window.h; pixl.redraw(); }); pixl.status.online.addEventListener("click", function(ev) { if (pixl.online) { pixl.disconnect(); } else { pixl.connect(); } }); pixl.drag = {start: undefined, current: undefined}; pixl.stage.addEventListener("mousedown", function(ev) { /*if (document.mozPointerLockElement === null) { document.addEventListener("mozpointerlockerror", console.log.bind(console)); pixl.stage.mozRequestPointerLock(); }*/ pixl.drag.start = {x: ev.clientX, y: ev.clientY}; pixl.drag.pos = pixl.pos; }); pixl.stage.addEventListener("mousemove", function(ev) { if (pixl.drag.start !== undefined) { pixl.drag.current = {x: ev.clientX, y: ev.clientY}; } var hovered = pixl.to_world({x: ev.clientX, y: ev.clientY}); pixl.status.pos.textContent = hovered.x + "," + hovered.y; }); pixl.stage.addEventListener("mouseup", function(ev) { if (pixl.drag.current === undefined) { var ev = polyfill.movement(ev); var world_pos = pixl.to_world({x: ev.clientX, y: ev.clientY}); pixl.draw_pixl(world_pos, pixl.at(world_pos) ? "white" : pixl.color); } else { console.error("drag not implemented"); } pixl.drag = {}; }); document.addEventListener("keydown", function(ev) { if (ev.keyCode >= 37 && ev.keyCode <= 40) { switch (ev.keyCode) { case 37: // left pixl.pos.x -= 1; break; case 38: // up pixl.pos.y -= 1; break; case 39: // right pixl.pos.x += 1; break; case 40: // down pixl.pos.y += 1; break; } pixl.redraw(); } }); pixl.online = false; pixl.connect = function() { pixl.ws = new WebSocket('ws://' + (location.host || 'localhost:8001') + '/ws'); pixl.ws.onopen = function() { pixl.online = true; pixl.status.online.style.backgroundColor = "green"; }; pixl.ws.onclose = function() { pixl.online = false; pixl.status.online.style.backgroundColor = "red"; }; pixl.ws.onmessage = function(msg) { var obj = JSON.parse(msg.data); if (obj.length !== undefined) { obj.forEach(function(p) { pixl.draw_pixl(p, p.color, {send: false}); }); } else { pixl.world = obj; pixl.redraw(); } }; }; pixl.disconnect = function () { pixl.ws.close(); }; pixl.connect(); pixl.disconnectAndClear = function() { pixl.disconnect(); pixl.world = {}; pixl.redraw(); } </script> <script> pixl.scripts = {}; pixl.scripts.stringify = function(name, scriptObj) { var script = "window." + name + " = " + "{};\n"; for (var fnName in scriptObj) { var fn = scriptObj[fnName]; script += name + "." + fnName + " = " + fn.toString() + ";\n"; if (fn.doc) { script += name + "." + fnName + ".doc = " + JSON.stringify(fn.doc) + ";\n"; } } return script; }; pixl.scripts.save = function(name, scriptObj) { var xhr = new XMLHttpRequest(); xhr.open('POST', '/scripts/' + name); xhr.send(pixl.scripts.stringify(name, scriptObj)); }; pixl.scripts.load = function(name) { var xhr = new XMLHttpRequest(); xhr.open('GET', '/scripts/' + name); xhr.onreadystatechange = function(ev) { if (xhr.readyState == 4) { var code = xhr.responseText; eval(code); } } xhr.send(); }; pixl.scripts.list = function() { var xhr = new XMLHttpRequest(); xhr.open('GET', '/scripts'); xhr.onreadystatechange = function() { if (xhr.readyState == 4) { var scripts = xhr.responseText.split("\n"); for (var i = 0; i < scripts.length; i++) { console.log(scripts[i]); } } }; xhr.send(); } </script> </body> </html>
lu/lp - git.papill0n.org

4 次代码提交 (1e24d655b6f9935b92697191d1bfe5fe3640092f)

作者 SHA1 备注 提交日期
  Lucas Stadler 8008ab6291 add missing doctype 11 年之前
  Lucas Stadler 3a8728880a start working through the react tutorial 11 年之前
  Lucas Stadler b331cc5c29 fix whitespace in index.html 11 年之前
  Lucas Stadler ee9e35002c hello, es6 & webpack 11 年之前
lu/lp - git.papill0n.org

724 Commits (f85d3f6b5131a33a27b14b763405053916c9b268)

Autor SHA1 Mensaje Fecha
  Lucas Stadler eff7101602 Ignore compiled js, binaries and utility files %!s(int64=9) %!d(string=hace) años
  Lucas Stadler c70652c800 Add .vimrc to make syntastic work %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 8e959cc7d3 Add a Makefile %!s(int64=9) %!d(string=hace) años
  Lucas Stadler b87b8db485 Rename jsc-test to ton %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 688c69ed9c Port bootstrap from planck %!s(int64=9) %!d(string=hace) años
  Lucas Stadler be1d5b4aa0 Fix file reading and move it into a function %!s(int64=9) %!d(string=hace) años
  Lucas Stadler c7b52b09b1 Use evaluate_script instead of JSEvaluateScript %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 4ab9cbd6b3 Extract evaluation to a separate function %!s(int64=9) %!d(string=hace) años
  Lucas Stadler be70524e7c Print import errors when DEBUG is set %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 6763eedf44 Support importing scripts from disk %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 1534383cb9 Prefix jsc callbacks with `function_` %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 8d3c007a52 Make console_log look like console_error %!s(int64=9) %!d(string=hace) años
  Lucas Stadler aacc99e87b Provide console.log and console.error %!s(int64=9) %!d(string=hace) años
  Lucas Stadler a65348d504 Add a CONSOLE_ERROR function %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 896951e4ee Remove unnecessary newline %!s(int64=9) %!d(string=hace) años
  Lucas Stadler c630cf6b6b Add a neat little example of using JavaScriptCore %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 2e7e56f0ee A simple time-to-socket-printing server example %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 9675e544dd Support caching results %!s(int64=9) %!d(string=hace) años
  Lucas Stadler a9c121e78e Ignore the binary %!s(int64=9) %!d(string=hace) años
  Lucas Stadler b8d77af5b5 Don't panic if getting the info fails %!s(int64=9) %!d(string=hace) años
  Lucas Stadler d3ce7b4d7f Use http if no protocol was specified %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 40442c3eb1 inquire: A tiny program to get metadata about a url %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 7d4bd2f1d6 Use encrypted websocket if connected via https %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 60b203733d Fix printing the address we're listening on %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 304ca8447d Listen only on localhost %!s(int64=9) %!d(string=hace) años
  Lucas Stadler 9108c467b9 Listen only on localhost %!s(int64=9) %!d(string=hace) años
  Lucas Stadler d84545543b Note that it needs to be built with nightly %!s(int64=10) %!d(string=hace) años
  Lucas Stadler cd8a3f38e5 Add a tiny README.md %!s(int64=10) %!d(string=hace) años
  Lucas Stadler b030f12a8e Merge the two `impl` blocks for PNGImage %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 9716e26c45 Put message conversion into a method %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 6d9d9d168c Use an iterator to convert the message %!s(int64=10) %!d(string=hace) años
  Lucas Stadler f7ec2ddc92 Rename png_image to PNGImage %!s(int64=10) %!d(string=hace) años
  Lucas Stadler e158a91301 Use c_uint instead of uint32_t %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 53d3c41d97 Print empty line between the two examples %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 8e800af3c8 Remove debug println %!s(int64=10) %!d(string=hace) años
  Lucas Stadler ddca15b9cd Support getting the filename from the cmdline %!s(int64=10) %!d(string=hace) años
  Lucas Stadler e658f0c907 Move ffi call into a method on png_image %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 8c7c2d2feb Move png_image initialization into a function %!s(int64=10) %!d(string=hace) años
  Lucas Stadler fb389a2eb2 Implement Display for png_image %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 3943b76f19 Initialize the `.version` field correctly %!s(int64=10) %!d(string=hace) años
  Lucas Stadler a15fe17b56 Use a null-terminated string for the file name %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 6a04b2debb Add a printing function that displays png_image %!s(int64=10) %!d(string=hace) años
  Lucas Stadler e5ac979f6a Use libc::c_void for the opaque struct %!s(int64=10) %!d(string=hace) años
  Lucas Stadler a71e0aac9f Fix the opaque type %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 24965887e1 Use `zeroed` instead of `unitialized`. %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 6e15c8137c Add work-in-progress png example %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 416aa59f35 Initial commit: Hello FFI in Rust! %!s(int64=10) %!d(string=hace) años
  Lucas Stadler d767e2d6e8 Add Makefiles for unpaginate and stars %!s(int64=10) %!d(string=hace) años
  Lucas Stadler 7cc4dec177 Make the usage message prettier %!s(int64=10) %!d(string=hace) años
  Lucas Stadler e977e4e9ca Add an example for reading repos from a file %!s(int64=10) %!d(string=hace) años
lp - git.papill0n.org

Nessuna descrizione

.gitignore 94B

    /luajit /dynasm-driver.c /hello_jit /hello_dynasm /hello_dynasm.c /bf /bf.c /mandelbrot.bf