// === Author data Author Name: "Phil Considine" Script Name: "Previous Blend Mode" Comment: "Cycle the selected layer backwards through the available blend modes." Script Type: "" Script Feature Flags: 0x000000000
// These are the return values from LayerBlendMode() intarray blendModes = { 0, // Normal 25, // Tint 23, // Highlight 24, // Shadow 27, // Watercolor -- why not 26? 9, // Dissolve 1, // Darken 7, // Multiply 16, // Color Burn 17, // Linear Burn 2, // Lighten 8, // Screen 15, // Color Dodge 18, // Linear Dodge 10, // Overlay 12, // Soft Light 11, // Hard Light 19, // Vivid Light 20, // Linear Light 21, // Pin Light 22, // Hard Mix 13, // Difference 14, // Exclusion 3, // Hue 4, // Saturation 5, // Color 6 // Luminosity } // These are the corresponding command ids... intarray blendIds = { 3000000169, // 0 Normal 3000000194, // 25 Tint 3000000192, // 23 Highlight 3000000193, // 24 Shadow 3000000195, // 27 Watercolor -- why not 26? 3000000178, // 9 Dissolve 3000000170, // 1 Darken 3000000176, // 7 Multiply 3000000185, // 16 Color Burn 3000000186, // 17 Linear Burn 3000000171, // 2 Lighten 3000000177, // 8 Screen 3000000184, // 15 Color Dodge 3000000187, // 18 Linear Dodge 3000000179, // 10 Overlay 3000000181, // 12 Soft Light 3000000180, // 11 Hard Light 3000000188, // 19 Vivid Light 3000000189, // 20 Linear Light 3000000190, // 21 Pin Light 3000000191, // 22 Hard Mix 3000000182, // 13 Difference 3000000183, // 14 Exclusion 3000000172, // 3 Hue 3000000173, // 4 Saturation 3000000174, // 5 Color 3000000175, // 6 Luminosity } // ...and the names stringarray blendNames = { "Normal", "Tint", "Highlight", "Shadow", "Watercolor", //-- why not 26? "Dissolve", "Darken", "Multiply", "Color Burn", "Linear Burn", "Lighten", "Screen", "Color Dodge", "Linear Dodge", "Overlay", "Soft Light", "Hard Light", "Vivid Light", "Linear Light", "Pin Light", "Hard Mix", "Difference", "Exclusion", "Hue", "Saturation", "Color", "Luminosity" } /*------------------------------------------------------------------------------------------- Generally LayerBlendMode() + 3000000169 == command but Watercolor doesn't follow this rule. We could add special handling for Watercolor and then add 3000000169 but then we'd cycle through the modes in the wrong order, so we'll use the return value to look up the command in another array. Doing it this way means we go through in the same order as the modes menu. -------------------------------------------------------------------------------------------*/ int numModes = blendModes.GetSize(); int currentLayer = CurrentLayerIndex(); int currentMode = LayerBlendMode(currentLayer); string msg = "Nothing happened"; // Find the current mode int id = -1; int c = blendModes.GetSize(); int i; for(i = 0; i < c; i++) { if(blendModes[i] == currentMode) { id = i; break; } } if(id > -1) // If we found an id { // Go back to the previous mode in the list id = (id - 1 + numModes) % numModes; // Subtract one, wrapping back to the end if we undershoot. // Fetch the right command id int newMode = blendIds[id]; // Apply the new mode Wait: 0.000s EvType: Command CommandID: CID_SetSpecificLayerBlend ParamType: LayerTwoOp Value: { currentLayer, newMode } // Brag about it msg = "Blend mode set to %%blendNames[id]."; } //MessageTip(msg); // MessageTip() seems to be broken //MessageBox(msg); // and MessageBox is a bit intrusive so let's just not bother.