1
A
回答
3
您可以不畫它們,既可以使用如(阿爾法/ 透明度)參數爲fill功能
不拉絲:
int numVisible = 0;
for(int i = 0 ; i < 20 ; i++) {
boolean visible = random(1) > .5;
if(visible) {
rect(random(100),random(100),random(10),random(10));
numVisible++;
}
}
println(numVisible+" boxes are visible");
繪製透明(只有筆畫可見):
for(int i = 0 ; i < 20 ; i++) {
boolean visible = random(1) > .5;
fill(255,255,255,visible ? 255 : 0);
rect(random(100),random(100),random(10),random(10));
}
如果有幫助,這是同樣的一個更長的版本:
void setup(){
size(400,400,P2D);
smooth();
noStroke();
background(255);
for(int i = 0; i < 200 ; i++){
Rect r = new Rect(random(width),random(height),random(10,20),random(10,20),color(random(255),random(255),random(255),random(1) > .5 ? 255 : 64));
r.draw();
}
}
class Rect{
color c;
float w,h,x,y;
Rect(float x,float y,float w,float h,color c){
this.c = c;
this.w = w;
this.h = h;
this.x = x;
this.y = y;
}
void draw(){
fill(c);
rect(x,y,w,h);
}
}
貝婁是可以運行的代碼段:
function setup(){
createCanvas(400,400);
smooth();
noStroke();
background(255);
for(var i = 0; i < 200 ; i++){
var r = new Rect(random(width),random(height),random(10,20),random(10,20),color(random(255),random(255),random(255),random(1) > .5 ? 255 : 64));
r.draw();
}
}
function Rect(x,y,w,h,c){
this.c = c;
this.w = w;
this.h = h;
this.x = x;
this.y = y;
this.draw = function(){
fill(c);
rect(x,y,w,h);
}
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.4.4/p5.min.js"></script>
1
你可以在繪製函數中放入一個var控制它是否必須顯示你想要的。
void draw()
{
if (showThis)
{
image(image);
}
}
0
添加noStroke();並使顏色與背景顏色相同?
相關問題
- 1. XNA如何使對象不可見
- 2. 電影在處理中不可見
- 3. 如何使矩形對象可見?
- 4. 如何在繪製線條之後使對象不可見?
- 5. 使可見對象隱藏和隱藏對象可見
- 6. JavaScript如何處理函數對象?見例如
- 7. asp:驗證器在不可見元素+不可見對象
- 8. 如何使對象在整個頁面中可見?
- 9. 如何處理XMLDocument對象
- 10. 如何處理googlemap對象?
- 11. PHP如何處理對象
- 12. 如何處理對象
- 13. 如何在處理JSON流中處理嵌套對象
- 14. 如何在Flex中處理非可視對象的事件
- 15. 如何在Java中處理對象的可選變量?
- 16. 如何在刪除行時處理不可見的行。 (UITableViews)
- 17. 如何使用jQuery處理iframe對象
- 18. 如何處理PHP對象使用jQuery
- 19. 如何使用PHP處理此對象?
- 20. 如何使用JavaScript處理COM對象?
- 21. 如何在android中的mapview中處理ItemizedOverlay的可見性?
- 22. 如何處理多個相關對象(在對象中嵌套)
- 23. 在Android中處理對象
- 24. 在SharePoint中處理對象?
- 25. 在池中處理對象
- 26. 在.NET中處理對象?
- 27. 如何在不使用ORM時處理嵌套對象?
- 28. 如何使標籤可見/不可見?
- 29. 如何獲取IE7中不可見框架中對象的.height()?
- 30. 如何在處理對象時在java中使用地圖
不要猜測(在答案的末尾添加'?') – 2017-10-25 17:59:12