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。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。
