ข้ามไปที่เนื้อหาหลัก

P5JS Socket.IO

test 


The video above will be about node servers and sending messages to screens of clients with JS.

Step 1: Add code to client to send a message, your code should look like this:

1  var socket;
2
3  function setup() {
4      createCanvas(width, height);
5      background(color);
6
7      socket = io.connect(link)
8  }
9
10  function draw() {
11      noStroke();
12      fill(color);
13      ellipse(mouseX, mouseY, width, height);
14  }

Step 2: Go to line 9 then add a new line of code called : function mouseDragged() {} and then add the following code inside the function: console.log('Sending: ' + mouseX + "," + mouseY);

When you move your mouse, you should a set of coordinates getting printed in the console,
(example: Sending: 305,273)
You will also have to add the entire function draw() into function MouseDragged()

Step 3: Go inside your function MouseDragged and then add this line of code
            var data = {
                x: mouseX,
                y: mouseY
           }

           socket.emit('mouse', data);

If you want to learn more please watch the video above.

ความคิดเห็น

โพสต์ยอดนิยมจากบล็อกนี้

เครื่องกัดแม่พิมพ์เหล็กขนาดเล็กสำหรับงานกัดแม่พิมพ์พระ

สำหรับงานกัดแม่พิมพ์พระ ราคา 180,000.00 บาท พร้อม อบรม ดูแล 1 ปี

ความรู้เบื้องต้นสำหรับการสร้างงาน 3 มิติ ด้วย Artcam

โปรแกรม Artcam เป็นโปรแกรมออกแบบ งานนูนสูงต่ำ และ สร้าง Code สำหรับควบคุมการกัดงานของ CNC ผู้เขียนขอเล่าประสพการณ์ การเรียนรู้ เกี่ยวกับการทำงาน 3 มิติ นูนสูงต่ำเพื่อเป็นประโยชน์ต่อ สาธารณะชน และ ประกอบการตัดสินใจการจัดซื้อ จัดหา โปรแกรมดังกล่าวใว้ใช้งาน พอสังเขบดังนี้ 1.คุณสามารถ Download ตัวทดลองใช้งาน ได้ตาม Link นี้ 2.คุณสามารถซื้อหา โปรแกรม Artcam ได้ตาม Link นี้    หรือ ติดต่อซื้อได้ที่  http://www.delcam.com/th/ 3.Artcam manual Link การใช้โปรแกรม Artcam ผู้ใช้จะมีความคาดหวังสูงว่า โปรแกรมนี้จะช่วยทำงานออก แบบ3มิติ สำหรับงาน CNC ให้เป็นเรื่องง่าย โดยผู้ใช้ไม่ต้องทำอะไรมาก นั่นเป็นความเข้าใจที่ยังไม่ถูกต้องทั้งหมด  บทความนี้จะอธิบายหลักการการทำงาน ของโปรแกรม Artcam และ การนำไปใช้งาน รวมถึงการ นำข้อมูลจากโปรแกรมอื่น มาใช้งานใน Artcam ด้วยเช่นกัน เทคนิคเหล่านี้ทำได้หลายวิธี ดังนั้นผู้ใช้จำเป็นต้องมีการฝึกฝน ทักษะเบื้องต้นมาก่อน เทคนิคที่1 การเขียน 3D เบื้องต้น จากเส้น Vector ใน Artcam9 ผู้ใช้ จะต้องมีความเข้าใจเกี่ยวกับ พื้นฐานเบื้องต้น เรื่อง การสร้าง ...

การแก้ปัญหาการติดตั้ง โปรแกรม Artcam Pro9 ใน Windows10

ใน windows10 การเรียกใช้งานโปรแกรม Artcam Pro9 อาจมีอาการค้างหรือ Hang เนื่องจากการเรียกใช้ โปรแกรมให้ ทดลองปรับแต่งตามนี้ครับ 1.  2.ที่ Short Cut Icon