我有这个codepen:https://codepen.io/giorgiomartini/pen/OjQpKd?editors=0010如何使混合模式乘不会在p5js所有图像黑色
如果我画一些形状和一些文字,现在我婉添加的形状和之间的径向覆盖文本。
所以我创建了一个drawgradient功能,并调用它形状和文本之间:
function drawGradient() {
blendMode(MULTIPLY)
for (let r = canvasX; r > 0; --r) {
let lightnes = map(r,0,canvasX,255,0)
fill(0, 0, lightnes)
ellipse(0, 0, r*1.8, r*2)
}
}
我想这个梯度有多重混合模式,所以,它使整个事情有点暗像素在渐变中较暗。
但我得到的是一个全黑覆盖...
在Photoshop或瘸子,如果添加了黑色和白色的径向渐变与乘法混合模式它使得背景暗的地方有在较暗pixles渐变......但是在p5js中它只是让所有的东西变黑。
任何想法我做错了什么?
这是的mouseClicked功能,并在底部可以看到被称为gradiend功能:
function mouseClicked(){
blendMode(BLEND)
const colsArray = randomColor({luminosity: 'light', format: 'hsl',count: 4})
background(colsArray[0])
translate(width/2, height/2)
////////////////////////////////////////////////////////////////// amt initial range
const arrayOfRandomNumsOfFirstProbStepX = createArrayOfRandomNums(amtOfSpotsInFirstProb,startProbStep,firstProbStepX)
const arrayOfRandomNumsOfFirstProbStepY = createArrayOfRandomNums(amtOfSpotsInFirstProb,startProbStep,firstProbStepY)
const arrayOfRandomNumsOfSecondProbStepX = createArrayOfRandomNums(amtOfSpotsInSecondProb,startProbStep,secondProbStepX)
const arrayOfRandomNumsOfSecondProbStepY = createArrayOfRandomNums(amtOfSpotsInSecondProb,startProbStep,secondProbStepY)
drawLinesAtRandomspots(6,random(50),colsArray)
//args => element, arrayOfRandomNumsOfProbStepX, arrayOfRandomNumsOfProbStepY, elmntSizeMin, elmntSizeMax,rot, colors
drawElmntsOnSomeProbabilityStep('ellipse',arrayOfRandomNumsOfFirstProbStepX, arrayOfRandomNumsOfFirstProbStepY , 10, 80, true, colsArray)
drawElmntsOnSomeProbabilityStep('rect',arrayOfRandomNumsOfSecondProbStepX, arrayOfRandomNumsOfSecondProbStepY, 5, 30, true, colsArray)
drawGradient()
addText()
}
感谢您的回答,但我确实想要一个径向渐变..像一个小插曲...虐待trz添加一个MVCE并发布..thx –
@GiorgioMartini请参阅我编辑的答案。 –
所以我创建了MCVE,它在这里:https://codepen.io/giorgiomartini/pen/GvQVxy?编辑器= 0010,我想要做的是有一个vigenette效果,如果我在photoshop中使用multiply模式混合背景和白色图像,我会让较亮的像素变得更透明,而更亲密的像素更不透明,但是在我codepen,如果你启用第17行,这是倍增blendmode allwe得到的是一个完整的黑色圆圈..在这个图像我visualy解释我想要的:http://imgur.com/a/H3H10希望你能帮助 –