使用ExtendscriptJavaScript增量更改Indesign Swatch

问题描述

我有一个InDesign文档,其色板名为“ mySwatch” ,即@Bean public CircuitBreaker fooCircuitBreaker() { CircuitBreakerConfig.Builder builder = CircuitBreakerConfig.custom(). slidingWindowSize(xxx). failureRateThreshold(xxx). waitDurationInopenState(xxx)). ignoreException(e -> { if (e instanceof HttpStatusCodeException) { HttpStatusCodeException httpStatusCodeException = (HttpStatusCodeException) e; if (httpStatusCodeException.getStatusCode().is4xxClientError()) { return true; } } return false; }); circuitBreakerRegistry.addConfiguration(xxx,builder.build()); return circuitBreakerRegistry.circuitBreaker(xxx,xxx); } 。我已经写过了:

C10 M20 Y30 K40

将其更改为一组特定的值(app.activeDocument.colors.item("mySwatch").colorValue = [9,19,30,41]; ),但我想从现有值中添加或减去,例如[9,41-1,{ {1}},-1]。

这可能吗?

解决方法

您必须通过将值分配给新变量来获取这些值。

var myvalues = app.activeDocument.colors.item("mySwatch").colorValue

对它们进行操作。

myvalues[0] = myvalues[0] - 1

将它们重新分配给您的色板。

app.activeDocument.colors.item("mySwatch").colorValue = myvalues 

(未经测试)

,
function change_color(a,b) {
    return [a[0] += b[0],a[1] += b[1],a[2] += b[2],a[3] += b[3]];
}

var color  = app.activeDocument.colors.item("mySwatch").colorValue; // [10,20,30,40]
var change = [-1,-1,1];
app.activeDocument.colors.item("mySwatch").colorValue = change_color(color,change); // [9,19,41];

经过测试。