第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

在 HSB 顏色模式中更改不透明度

在 HSB 顏色模式中更改不透明度

絕地?zé)o雙 2022-01-12 17:12:24
我正在嘗試更改筆畫(huà)的不透明度,但不確定如何在 HSB 顏色模式下進(jìn)行?;蛘撸绻仪袚Q到 RGB 模式,如何讓顏色隨時(shí)間變化?這是我的代碼:(任何幫助將不勝感激)float rainbow=0;int dir=1;void setup() {  size(600, 600);  background(0);  colorMode(HSB, 255); } void draw() {  if ( rainbow < 255 && dir==1) {     rainbow++;  }  if ( rainbow > 0 && dir==-1) {    rainbow--;  }  if ( rainbow == 255) {    dir*= -1;  }  if ( rainbow == 0) {    dir*= -1;  }  stroke(rainbow, 255, 200);  line(mouseX,mouseY,width/2,height/2);   if (mousePressed){  stroke(rainbow, 255, 200);  line(mouseX,mouseY,0,mouseX);  }  if (mousePressed){  stroke(rainbow, 100, 200);  line(mouseX,mouseY,600,mouseX);  }}
查看完整描述

1 回答

?
慕的地10843

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊

您可以給stroke()orfill()函數(shù)指定不透明度的第四個(gè)參數(shù)。這是一個(gè)例子:


void setup(){

  size(500, 500);

  colorMode(HSB, 255);

  background(255);

}


void draw(){

  fill(0, 255, 200, 100);

  ellipse(mouseX, mouseY, 20, 20);

}

請(qǐng)注意,您還可以使用 RGB 模式并隨著時(shí)間的推移修改 R、G 和 B 參數(shù)。這比循環(huán) HSB 值要復(fù)雜一些,但您可以創(chuàng)建任何您想要的模式。這是一個(gè)例子:


float r = 0;

float g = 0;

float b = 0;


float deltaR = 1;

float deltaG = 2;

float deltaB = 4;


void setup(){

  size(500, 500);

  background(255);

}


void draw(){

  

  r += deltaR;

  g += deltaG;

  b += deltaB;

  

  if(r < 0 || r > 255){

    deltaR *= -1;

    r = constrain(r, 0, 255);

  }

  

  if(g < 0 || g > 255){

   deltaG *= -1;

   g = constrain(g, 0, 255);

  }

  

  if(b < 0 || b > 255){

    deltaB *= -1;

    b = constrain(b, 0, 255);

  }

  

  fill(r, g, b);

  ellipse(mouseX, mouseY, 20, 20);

}


查看完整回答
反對(duì) 回復(fù) 2022-01-12
  • 1 回答
  • 0 關(guān)注
  • 191 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)