[英]Is there a way to create a gradient in basiljs?
這是一個不言自明的問題。
我很好奇為什么沒有內置函數創建漸變。 我發現“偽造”的唯一方法是創建一系列線條或矩形,每個線條或矩形都具有使用b.lerpColor計算的唯一顏色。
我看到InDesign對象模型當然具有漸變類,但我不知道如何使用basiljs訪問它。
也許有人可以告訴我? 非常感謝。
查看此參考http://jongware.mit.edu/idcs6js/pc_Gradient.html
並嘗試這樣:
#includepath "~/Documents/;%USERPROFILE%Documents";
#include "basiljs/bundle/basil.js";
function draw() {
var d = b.doc();
var r = b.rect(0, 0, b.width, b.height);
var myGrad = d.gradients.add({
name: "Col " + (parseInt(Math.random() * 10000)),
type: GradientType.linear
});
myGrad.gradientStops[0].properties = {
stopColor: d.colors.item(2),
location: Math.random() * 50
};
myGrad.gradientStops[1].properties = {
stopColor: d.colors.item(4),
location: 50 + Math.random() * 50
};
r.fillColor = myGrad;
// to set the fill of the gradient use the following line
r.gradientFillAngle = 50;//b.random(-180,180);
}
b.go();
腳本每次運行時都會創建一個新的漸變色板。
編輯:添加了漸變填充角度
在這里看看。
gradientFillAngle number r / w應用於Rectangle填充的線性漸變的角度。 (范圍:-180至180)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.