FqAutoLayers: Difference between revisions

From FetishQuest Wiki
Jump to navigation Jump to search
JasX (talk | contribs)
Created page with "This script will automatically try to remove unchanged pixels. <pre> var startRulesUnits = preferences.rulerUnits; var doc = activeDocument; var bgLayer; var allLayers = []; var layerNames = { stains : 55, sling_heavy: 25, sling_med : 25, sling_leather : {alias:"sling_med", num:25}, sling_light : 25, sling_cloth : {alias:"sling_light", num:25}, bodysuit_med : 25, bodysuit_leather : {alias:"bodysuit_med", num:25}, bodysuit_light : 25, bodysuit_cloth : {..."
 
JasX (talk | contribs)
No edit summary
Line 1: Line 1:
This script will automatically try to remove unchanged pixels.
This script will automatically try to remove unchanged pixels. Save it as fqAutoLayers.jsx and import into photoshop.


<pre>
<pre>

Revision as of 11:55, 27 March 2025

This script will automatically try to remove unchanged pixels. Save it as fqAutoLayers.jsx and import into photoshop.

var startRulesUnits = preferences.rulerUnits;
var doc = activeDocument;
var bgLayer;
var allLayers = [];

var layerNames = {
	stains : 55,
	
	sling_heavy: 25,
	sling_med : 25,
	sling_leather : {alias:"sling_med", num:25},
	sling_light : 25,
	sling_cloth : {alias:"sling_light", num:25},
	
	bodysuit_med : 25,
	bodysuit_leather : {alias:"bodysuit_med", num:25},	
	
	bodysuit_light : 25,
	bodysuit_cloth : {alias:"bodysuit_light", num:25},
	
	heavy : {alias:"heavy_ub",num:35},
	
	leather : {alias:"med_ub", num:35},
	med : {alias:"med_ub", num:35},
	medium : {alias:"med_ub", num:35},
	
	
	armor : {alias:"light_ub",num:35}, // Used for NPCs with only one armor set
	cloth : {alias:"light_ub", num:35},
	light : {alias:"light_ub", num:35},
	
	collar : 23,
	nipple_studs : 22,
	stocks_aroused : {alias:"aroused", num:10},
	aroused : 10,
	stocks_pain : {alias:"pain", num:10},
	pain : 10,
	stocks_orgasm : {alias:"orgasm", num:5},
	orgasm : 5,
	stocks_pain_heavy : {alias:"pain_heavy", num:15},
	pain_heavy: 15,
	stocks_aroused_heavy : {alias:"aroused_heavy", num:15},
	aroused_heavy: 15
};

function exec(){

	fetchLayers(doc);

	for( var i = 0; i < allLayers.length; ++i ){
		
		hideAllLayers();

		var l = allLayers[i];
		activeDocument.activeLayer = l;
		l.visible = true;
		
		l.blendMode = BlendMode.DIFFERENCE;
		
		quickSel(0,0,1);
		doc.selection.clear();
		doc.selection.deselect();
		
		l.blendMode = BlendMode.NORMAL;
	}
	
}

function quickSel (x, y, tol){

	var idsetd = charIDToTypeID( "setd" );
	var desc2 = new ActionDescriptor();
	var idnull = charIDToTypeID( "null" );
		var ref1 = new ActionReference();
		var idChnl = charIDToTypeID( "Chnl" );
		var idfsel = charIDToTypeID( "fsel" );
		ref1.putProperty( idChnl, idfsel );
	desc2.putReference( idnull, ref1 );
	var idT = charIDToTypeID( "T   " );
		var desc3 = new ActionDescriptor();
		var idHrzn = charIDToTypeID( "Hrzn" );
		var idPxl = charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( idHrzn, idPxl, x );
		var idVrtc = charIDToTypeID( "Vrtc" );
		var idPxl = charIDToTypeID( "#Pxl" );
		desc3.putUnitDouble( idVrtc, idPxl, y);
	var idPnt = charIDToTypeID( "Pnt " );
	desc2.putObject( idT, idPnt, desc3 );
	var idTlrn = charIDToTypeID( "Tlrn" );
	desc2.putInteger( idTlrn, tol);
	var idAntA = charIDToTypeID( "AntA" );
	desc2.putBoolean( idAntA, true );
	var idCntg = charIDToTypeID( "Cntg" );
	desc2.putBoolean( idCntg, true );
	var idMrgd = charIDToTypeID( "Mrgd" );
	desc2.putBoolean( idMrgd, true );
	executeAction( idsetd, desc2, DialogModes.NO );

};

function hideAllLayers(){
	for( var i = 0; i < allLayers.length; ++i )
		allLayers[i].visible = false;

}

// Fetches all viable art layers
function fetchLayers( parentLayer, ignore ){
	
	for( var i = 0; i < parentLayer.layers.length; ++i ){
		
		var l = parentLayer.layers[i];
		
		var ign = ignore;
		var isBg = l.name == "Background";
		if( !ignore )
			ign = ( l.name.substring(0,1) == "#" || isBg || l.name.substring(0,1) == "." );
		if( isBg )
			bgLayer = l;

		if( l.typename == "LayerSet" ){
			fetchLayers(l, ign);
			continue;
		}
		
		if( !isBg ){
			
			var subname = l.name.split('.');
			subname.pop();
			subname = subname.join(".").toLowerCase();
			var itm = layerNames[subname];			
			if( itm !== undefined ){
				if( typeof itm === "object" ){
					subname = itm.alias;
					itm = itm.num;
				}
				l.name = itm+"_"+subname;
			}
		}
		
		if( !ign ){
			allLayers.push(l);
		}
	}
	
}

exec();