mask drawing script sometimes not quite pixel perfect... is 3762 a problem number ?
hi all
I have a simple script to draw rectangular masks on a layer, it works a treat, but this morning I noticed one mask that wasn't quite pixel perfect. All of the other masks are fine but one mask has 2 vertices with an X value of 3762 and when they are set it results in a vertex actually being placed at 3762.00024414062
The wierd thing is that if I try and fix it via the UI, the same thing happens ?
3762 set via UI results in 3762.0002
3761 works
3763 also wigs out to 3762.9998
3764 works
3765 works
what's going on, is this some kind of binary rounding error ?
visually, it's not really an issue but it throws a bit of spanner in the rest of the scripting oprations...
any suggestions greatly appreciated
// apply to a solid layer that is 6256 x 3600
// in a comp of the same dimensions
app.beginUndoGroup("add masks");
var C = app.project.activeItem;
var L = C.selectedLayers[0];
//A2 (4vertices) *** WORKS PERFECTLY
var myShape = new Shape()
myShape.vertices = [[1090,437],[1540,437],[1540,3297],[1090,3297]]
myShape.inTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.outTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.closed = true
var newMask = L.Masks.addProperty("mask");
newMask.maskShape.setValue(myShape);
newMask.name = "A2";
newMask.color = [0.16078431372549,0.43921568627451,0.70588235294118];
newMask.maskFeather.setValue([0,0]);
newMask.locked = false
newMask.maskMode = MaskMode.ADD;
//B1 (4vertices) *** ALSO WORKS PERFECTLY
var myShape = new Shape()
myShape.vertices = [[1552,3297],[1552,1088],[1660,1088],[1660,3297]]
myShape.inTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.outTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.closed = true
var newMask = L.Masks.addProperty("mask");
newMask.maskShape.setValue(myShape);
newMask.name = "B1";
newMask.color = [0.1843137254902,0.71372549019608,0.16078431372549];
newMask.maskFeather.setValue([0,0]);
newMask.locked = false
newMask.maskMode = MaskMode.ADD;
//B4 (4vertices) **** THIS ONE WIGS OUT on both vertices with an X value of 3762 ???
var myShape = new Shape()
myShape.vertices = [[3762,3297],[3762,2074],[4214,2074],[4214,3297]]
myShape.inTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.outTangents = [[0,0],[0,0],[0,0],[0,0]]
myShape.closed = true
var newMask = L.Masks.addProperty("mask");
newMask.maskShape.setValue(myShape);
newMask.name = "B4";
newMask.color = [0.70196078431373,0.71372549019608,0.16078431372549];
newMask.maskFeather.setValue([0,0]);
newMask.locked = false
newMask.maskMode = MaskMode.ADD;
app.endUndoGroup();