Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html>
- <head>
- <title>Conter-test</title>
- <canvas id="drawing"></canvas>
- <script src="processing-1.4.8.min.js"></script>
- <body>
- <script>
- var a0=0;
- var socket = new WebSocket('ws://127.0.0.1:7681',
- 'dumb-increment-protocol');
- // Add a connect listener
- socket.onmessage = function(event) {
- a0 = parseInt(event.data);
- console.log(event.data + ' ' + a0);
- // socket.send("reset\n");
- };
- function pad(num, size) {
- var s = "000000000" + num;
- return s.substr(s.length-size);
- }
- function sketch(p) {
- var minval = 9999;
- var maxval = 0;
- var r = 0;
- var f = null;
- p.setup = function() {
- p.background(0);
- p.size(600, 300);
- p.fill(202, 35, 55);
- p.textSize(80);
- p.text("Hello 1234!", 50, 100);
- }
- p.draw = function() {
- p.background(0);
- p.fill(0,127,127);
- p.text(pad(a0,4),p.width/4, p.height-110);
- if (p.__mousePressed) {
- minval = 9999; maxval = 0;
- p.text("MALAKIA",p.width/4,p.height-10);
- socket.send("reset\n");
- } else {
- p.text("MULUKULA",p.width/4,p.height-10);
- }
- }
- }
- var canvas = document.getElementById("drawing");
- var processingInstance = new Processing(canvas,sketch);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement