Closed joedf closed 1 year ago
// spc = spot-profile Circle/Ellipse
// scl = spot-content Ellipse
// sci = spot-content Image
// either spc or scl can be used, since the ellipse
// in spot-content is cloned and mirrors Spot profile
var cellWidth = sci.width() / Utils.getColsInput();
var cellHeight = sci.height() / Utils.getRowsInput();
var spotWidth = (spc.width() * spc.scaleX()) / (sci.scaleX() * cellWidth);
var spotHeight = (spc.height() * spc.scaleY()) / (sci.scaleY() * cellHeight);
var scaleEcc = Math.max(spc.scaleX(), spc.scaleY());
var spotWidthOrHeight = (spc.width() * spc.scaleX()) / (sci.scaleX() * sci.width() / Utils.getColsInput()) / scaleEcc;
Reliable formula is available already in Utils.updateDisplayBeamParams()
...
Important comment on "maxScale" or Math.max(beam.scaleX(), beam.scaleY())
here:
var spotWidth = (spc.width() / sci.scaleX()) / (sci.width() / Utils.getColsInput()) * spc.scaleX() / Math.max(spc.scaleX(), spc.scaleY())
spc = stages[2].getLayers()[0].getChildren()[0]
sci = stages[3].getLayers()[0].getChildren()[1]
var spotWidth = 0.1550688; // 15.50688 %
var cellWidth = sci.width() / Utils.getColsInput();
// sci.scaleX()
var scaleX_to_use_for_sci = ((scl.width() * scl.scaleX()) / spotWidth) / cellWidth;
G_SETW = function(wp=100){
/* eslint-disable */
var beam = compositeBeam;
var userImage = userScaledImage;
// calculate the new scale for spot-content image, based on the given spot width
var cellSize = Utils.computeCellSize(userImage, Utils.getRowsInput(), Utils.getColsInput());
var maxScale = Math.max(beam.scaleX(), beam.scaleY());
var eccScaled = beam.scaleX() / maxScale;
var newScale = ((beam.width() * eccScaled) / (wp/100)) / cellSize.w;
// userImage.scale({x: newScale, y: newScale});
Utils.centeredScale(userImage, newScale);
// propagate changes and update stages
updateBeams();
doUpdate();
/* eslint-enable */
};
Adding prompt for spot width %