Page 1 of 1

[CS2] layer.opacity 100% bug

Posted: Thu Aug 06, 2009 12:17 am
by SzopeN
Making the script backward compatible with CS2 is really frustrating... :/ Active layer opacity is set to 100%.

Code: Select all$.writeln(app.activeDocument.activeLayer.opacity)
// 100

app.activeDocument.activeLayer.opacity=app.activeDocument.activeLayer.opacity
// Throws an error: Specified value greater than maximum allowed value

$.writeln(app.activeDocument.activeLayer.opacity==100)
// false (?!)

$.writeln(app.activeDocument.activeLayer.opacity==100.00000000000001)
// true (?!!)

$.writeln(app.activeDocument.activeLayer.opacity-.00000000000001)
// 100 (still)

app.activeDocument.activeLayer.opacity=app.activeDocument.activeLayer.opacity-.00000000000001;
// OK

// so the final solution when reading layer opacity...
var op = Math.min(app.activeDocument.activeLayer.opacity,100);
// it is faster than if and ?:

[CS2] layer.opacity 100% bug

Posted: Fri Aug 07, 2009 3:40 am
by xbytor
I documented this one somewhere before. This was one of the more painful PS bugs I've come across.

[CS2] layer.opacity 100% bug

Posted: Fri Aug 07, 2009 4:44 pm
by SzopeN
xbytor wrote:I documented this one somewhere before. This was one of the more painful PS bugs I've come across.
I've done quick forum search for 'cs2 opacity 100%' but found nothing

[CS2] layer.opacity 100% bug

Posted: Fri Aug 07, 2009 4:51 pm
by xbytor