point()函數是p5.js中的內置函數,用於在給定坐標位置繪製點。
用法:
point( x, y, [z])
參數:該函數接受以下三個參數
- x:用於設置點的x坐標。
- y:用於設置點的y坐標。
- z:它用於在WebGL模式下設置z坐標。
示例1:
function setup() {
// Create Canvas of given size
createCanvas(400, 300);
}
function draw() {
// Use point() function to draw point
point(50, 50);
point(150, 50);
point(50, 150);
point(150, 150);
// Use strokeWeight() function to set
// the weight of point
strokeWeight(10);
}
輸出:
示例2:
function setup() {
// Create Canvas of given size
createCanvas(400, 300);
}
function draw() {
// Set the background color
background('green');
// Set the stroke weight
strokeWeight(10);
// Set stroke color
stroke('white');
// Draw point
point(50, 50);
point(50, 250);
point(350, 50);
point(350, 250);
point(200, 150);
}
輸出:
參考: https://p5js.org/reference/#/p5/point
相關用法
- PHP GmagickDraw point()用法及代碼示例
- PHP ImagickDraw point()用法及代碼示例
- d3.js d3.max()用法及代碼示例
- d3.js d3.rgb()用法及代碼示例
- p5.js int()用法及代碼示例
- PHP min( )用法及代碼示例
- p5.js tan()用法及代碼示例
- PHP pos()用法及代碼示例
- d3.js d3.min()用法及代碼示例
注:本文由純淨天空篩選整理自jit_t大神的英文原創作品 p5.js | point() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。