02進階及教學網

回覆文章
cajhbb
系統管理員
文章: 903
註冊時間: 2018年 6月 30日, 02:16

02進階及教學網

文章 cajhbb »

02進階及教學網
https://www.bilibili.com/video/BV1Kt4y1 ... 37b371e9ce
map函數

代碼: 選擇全部

//滑鼠左右移動灰階變化
//map的寫法--> 映射值=map(被映射值,a,b,A,B)  a,b原區間 A,B欲求區間
float c=0;
void setup(){
  size(800,800);
}
void draw(){
  c=map(mouseX,0,width,0,255);//size宣告後才能變數 width 寛 height 高
  background(c);
}
random函數

代碼: 選擇全部

//random的寫法
float t=0;
void setup(){
  size(300,300);
  frameRate(1);
}
void draw(){
  background(255);
  for(int i=0;i<width;i+=5)
  {
    stroke(0);
    strokeWeight(3);
    line(i,0,i,random(0,height));
    //line(x1,y1,x2,y2);
  }
}
random001.png
random001.png (7.24 KiB) 已瀏覽 839 次
回覆文章