Skip to main content
Participating Frequently
October 19, 2021
Answered

Randomize selected solid color layers always with (S > 25% & B = 50%)

  • October 19, 2021
  • 1 reply
  • 451 views

Hello everyone. i need help


Thank you very much in advance

This topic has been closed for replies.
Correct answer jazz-y

hue need to be randomized?

 

#target photoshop

var s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('adjustment'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
var fill = executeActionGet(r).getList(p).getObjectValue(0).getObjectValue(s2t('color')),
    color = new SolidColor;
with (color.rgb) {
    red = fill.getDouble(s2t('red'))
    green = fill.getDouble(s2t('green'))
    blue = fill.getDouble(s2t('blue'))
}

with (color.hsb) {
    saturation = 25 + Math.random() * 75
    brightness = 50
}

(r = new ActionReference()).putEnumerated(s2t("contentLayer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("null"), r);
(d1 = new ActionDescriptor()).putDouble(s2t('red'), color.rgb.red);
d1.putDouble(s2t('grain'), color.rgb.green);
d1.putDouble(s2t('blue'), color.rgb.blue);
(d2 = new ActionDescriptor()).putObject(s2t("color"), s2t("RGBColor"), d1);
d.putObject(s2t("to"), s2t("solidColorLayer"), d2);
executeAction(s2t("set"), d, DialogModes.NO);

 

 

1 reply

jazz-yCorrect answer
Legend
October 19, 2021

hue need to be randomized?

 

#target photoshop

var s2t = stringIDToTypeID;

(r = new ActionReference()).putProperty(s2t('property'), p = s2t('adjustment'));
r.putEnumerated(s2t('layer'), s2t('ordinal'), s2t('targetEnum'));
var fill = executeActionGet(r).getList(p).getObjectValue(0).getObjectValue(s2t('color')),
    color = new SolidColor;
with (color.rgb) {
    red = fill.getDouble(s2t('red'))
    green = fill.getDouble(s2t('green'))
    blue = fill.getDouble(s2t('blue'))
}

with (color.hsb) {
    saturation = 25 + Math.random() * 75
    brightness = 50
}

(r = new ActionReference()).putEnumerated(s2t("contentLayer"), s2t("ordinal"), s2t("targetEnum"));
(d = new ActionDescriptor()).putReference(s2t("null"), r);
(d1 = new ActionDescriptor()).putDouble(s2t('red'), color.rgb.red);
d1.putDouble(s2t('grain'), color.rgb.green);
d1.putDouble(s2t('blue'), color.rgb.blue);
(d2 = new ActionDescriptor()).putObject(s2t("color"), s2t("RGBColor"), d1);
d.putObject(s2t("to"), s2t("solidColorLayer"), d2);
executeAction(s2t("set"), d, DialogModes.NO);

 

 

Kukurykus
Legend
October 19, 2021
Participating Frequently
October 20, 2021
Dear, @Kukurykus:
Yes i think it's the same idea