p5.js中的sphere()函數用於繪製具有給定半徑的球體。
用法:
sphere( radius )
參數:該函數接受單個參數的半徑,該半徑存儲球體的半徑。
以下程序說明了p5.js中的sphere()函數:
示例1:本示例使用sphere()函數繪製圓。
function setup() {
// Create Canvas of size 600*600
createCanvas(600, 600, WEBGL);
}
function draw() {
// Set background color
background(200);
// Set filled color of sphere
fill('green');
// sphere() function called
sphere(100);
}
輸出:
示例2:本示例使用sphere()函數繪製圓。
function setup() {
// Create Canvas of size 600*600
createCanvas(600, 600, WEBGL);
}
function draw() {
// Set background color
background(200);
// Set filled color of sphere
fill('yellow');
// Rotate
rotateX(frameCount * 0.01);
rotate(frameCount*0.03);
// sphere() function called
sphere(140);
}
輸出:
參考: https://p5js.org/reference/#/p5/sphere
相關用法
- PHP Ds\Map get()用法及代碼示例
- d3.js d3.hcl()用法及代碼示例
- d3.js d3.lab()用法及代碼示例
- PHP min( )用法及代碼示例
- p5.js int()用法及代碼示例
- CSS hsl()用法及代碼示例
- CSS url()用法及代碼示例
- PHP max( )用法及代碼示例
- PHP dir()用法及代碼示例
- p5.js arc()用法及代碼示例
- p5.js tan()用法及代碼示例
- PHP end()用法及代碼示例
注:本文由純淨天空篩選整理自sarthak_ishu11大神的英文原創作品 p5.js | sphere() function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。