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

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

不使用顏色混合創(chuàng)建LinearGradient

不使用顏色混合創(chuàng)建LinearGradient

陪伴而非守候 2024-01-18 14:41:22
使用 ,createLinearGradient我們可以根據(jù) 中的停止值創(chuàng)建顏色漸變和顏色混合addColorStop。var gradient = ctx.createLinearGradient(0, 0, 0, 400);     gradient.addColorStop(0, 'blue');        gradient.addColorStop(1, 'red');我們是否可以避免顏色混合并根據(jù)停止值具有不同的顏色而不使用混合或漸變。createLinearGradient也許這對(duì)于任何其他 API都是不可能的?fillRect我知道我們可以使用兩個(gè)不同的和來(lái)創(chuàng)建它fillStyle。
查看完整描述

1 回答

?
達(dá)令說(shuō)

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

我不是 100% 確定你的意思,但如果你想要兩種不同顏色的清晰停止,你可以簡(jiǎn)單地將兩種顏色設(shè)置在相同的停止位置:


const canvas = document.querySelector("canvas");

const ctx = canvas.getContext("2d");

const grad = ctx.createLinearGradient(0,0,0,150);

// implicit from -Infinity "green"

grad.addColorStop(0.33, "green");

grad.addColorStop(0.33, "yellow"); // same stop as previous color

grad.addColorStop(0.66, "yellow");

grad.addColorStop(0.66, "red");    // same stop as previous color

// implicit to +Infinity "red"

ctx.fillStyle = grad;

ctx.fillRect(0,0,300,150);

<canvas></canvas>


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

添加回答

舉報(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)