How Do You Use "withMultipliedAlpha"?
-
How Do You Use "withMultipliedAlpha"? (I've read the docs, but am still unclear.) Thank you.
-
No idea, to me it seems to behave no differently than the
.withAlpha
function. Possibly this function is for use with images that have an alpha channel, but I'm just guessing.This is from the AI
withMultipliedAlpha is a method of the Colour class in JUCE (a cross-platform C++ library for audio processing and GUI development). It returns a new Colour object that is the same as the original, but with its alpha value multiplied by a given factor.
The alpha value of a Colour object represents its transparency, with a value of 1.0 being fully opaque and a value of 0.0 being fully transparent. Multiplying the alpha value by a factor less than 1.0 will reduce the overall transparency of the colour, while multiplying it by a factor greater than 1.0 will increase the transparency.
But my test project doesn't seem to do anything special compared to
withAlpha
HiseSnippet 1001.3ocsV8taaaCDmzIJq1aoXcnO.DEX.x.dt1qMYCnXnNwNovnKoByoA6aczRTVDlhTPjJItE8a64YuB6YYuA6MX6HkbrxpmWqAl+fgNd+62c7teRA4pPlVqxQ3lWrHigveg2jERSxvDJWhFOBguu2YTsgkSJO53EYTslEgv3cdg8.bycQte+4yOlJnxP1piPnKU7P1OxS4lUmFL3kbg3TZD6BdZMqe5fwgJ4PkPU.3YGudnLZ3b5L14TqYM7P38NIhaT4SLTCSC1brJZwjD00xR6ujq4SELqPezDHPkGiFlvEQAKqUMBg2MXUkuSYk+Puy3Q7aOeUG3KcJHq7ndO.2XSPp+m.jv0fztkP5AdSBy4YlUZr34y8FKgKjXJzpqCkRaQMjM7Fp.Kjltoz4rSyAga8v+vd85Pf+Z+rVsf1s1PthlSBnRlnO4GHK8bFyLTklojff+iJU+HqOkO1UyLAPCx7SpBCWx7iKjgFtR5Oqcq20poMlgtaRWLsOn6dM2jbjHKg5u7johBVGRutGz9YjG+3JCIbM4fdeMgZMsUyVMm0MFFXNRH7qGoyJDFdlfyhJiYY55PdoTMsuE+WRgn62tMf52e2p0Yx+Zw5z5pUtT.0FYYsQTRmNqa4JAjwJe5.QExkqxq5O4rLa6w2lbHRaLS1lYULGREhovTu+cSEDkZf3bkg8JouKcsdeKx+TUb7Z0UEKAKespsKi4axQeYQ5TVd8h0ZHLsd2Uf893VABKaI0LTIGK4lWkwpjOUIhri11m+vEFTUOEd50iGQMT6NT0YfcYrbC2BG7H1U.IT4FUSuQL8biJC3St8h.frwoc+k6a16PDGR887JuOQ2rhm5hAKVILZv07HSBB6gODiPIL9rDiUpC1AwaSw9ko39UoXhfGwxc43y7bW00Rw.VsT7K2LPaVX6e64LDkxihDr.klauepQ.+6.Oc1D9acbpu6g+1K9i29qOOsNGMBkRuoNkstHNleiibE1wR0F.aiSANWD9q7dslQhXwTXQinmCwA1FlyhtP4rWSuhMVFjyfoWK8C5C4u.lSUTgfZtKcp88FUJrEPcNLKOkDJrE0A4m.GauMxw9wBwG3EvMgIqGiMVCFgQu+OvX0al126j3XVnYE.206zedaeMz+Q5KIzmcFEFEfACuyKRm.7pgLH6RXUPaGtaXmsKk6YkscfILYjS3ufeUJ6akwUJ6uTILDFlqdSXIsh8ce2ycBfIo6U8Mgu4.jI8QNpFvOudc6YG74uILzV9eSeDZ897sagOOYK74oagOGrE9b3V3y2sE978azG6W.cTgQkVtN.GDbhiyEiOQRgIK2TH5uAfoXXKB
-
@d-healey It's pretty self explanatory - that's why ChatGPT managed to answer it correctly...
withAlpha()
sets the alpha value regarding of what alpha value was before, sowithAlpha(0x66000000, 0.5)
yields0x80000000
withMultipliedAlpha()
multiplies the existing alpha value, sowithMultipliedAlpha(0x66000000, 0.5)
yields0x33000000
-
@Christoph-Hart So why doesn't my example do anything interesting?
-
@Christoph-Hart said in How Do You Use "withMultipliedAlpha"?:
@d-healey It's pretty self explanatory - that's why ChatGPT managed to answer it correctly...
withAlpha()
sets the alpha value regarding of what alpha value was before, sowithAlpha(0x66000000, 0.5)
yields0x80000000
withMultipliedAlpha()
multiplies the existing alpha value, sowithMultipliedAlpha(0x66000000, 0.5)
yields0x33000000
What would the syntax be? I'm thinking something like this (but not this):
g.setColour(Colour::withMultipliedAlpha(g.get("itemColour"), 0.5);
-
@d-healey I think this is simply one of the Great Mysteries of HISE.
-
I know that HISE has a few places of mystery, but this isn't one of them.
You use the Colour class with
Colours.withXXX()
, the first argument is always a colour and the second a float number that does something with it. This is directly taken from the JUCE API and as self-explanatory as it can get.So why doesn't my example do anything interesting?
If you change the function to
withAlpha
, you'll notice that the blue gets 100% alpha, instead of 50% alpha max when the knob is turned up. -
@Christoph-Hart Thank you, Chris.
-
C clevername27 has marked this topic as solved on