20 มกราคม 2558

Use Processing.js

            Processing.js คือ ภาษาที่ใช้สำหรับพัฒนาโปรแกรม ดีไซน์มาสำหรับใช้กับเว็ปไซต์ โดย Processing.js สามารถนำมาสร้าง Data visualization, Digital art, Interactive animations, graphs และอื่นๆอีกมากมาย โดยที่สามารถทำงานได้กับเว็ปทั่วไป โดยไม่ต้องลงปลั๊กอินเพิ่ม ซึ่งสามารถเขียนโค้ดเป็นภาษา Processing เพื่อนำไปทำงานร่วมกับเว็ปไซต์ได้เลย

ตัวอย่างด้านล่าง คือตัวอย่างจากเวปไซต์ Processing js ซึ่งเป็นตัวอย่างใน tutorial ซึ่งนำสคริปมาเขียนร่วมกับ blogspot ได้ทันที 



ตัวอย่างด้านล่าง คือการนำ Processing js มาประยุกต์ใช้งานอย่างง่าย



<script>
size(200, 200);
background(150);
smooth();
noStroke();

int diameter = 150;
int[] angs = {-90,90+45,90,75,60};
float lastAng = 0;
color[] cx = {0, color(204,0,0), color(204,153,0), color(51,102,0), color(102,153,255)};

for (int i=0; i<angs.length; i++){
  fill(cx[i]);
  arc(width/2, height/2, diameter, diameter, lastAng, lastAng+radians(angs[i]));
  fill(255);
  ellipse(width/2, height/2, 40, 40);
  lastAng += radians(angs[i]);
}
</script>
Reference : http://processingjs.org/learning/

ไม่มีความคิดเห็น:

แสดงความคิดเห็น