Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
saturation: 1,
},
};
if (fills && fills.length) {
json.fills = json.fills.concat(fills);
}
if (!style) {
return json;
}
if (style.opacity) {
json.contextSettings = {
_class: 'graphicsContextSettings',
blendMode: FileFormat.BlendMode.Normal,
opacity: style.opacity,
};
}
if (style.backgroundColor) {
const fill = makeColorFill(style.backgroundColor);
json.fills.unshift(fill);
}
if (hasAnyDefined(style, SHADOW_STYLES)) {
const shadow = [makeShadow(style)];
if (style.shadowInner) {
json.innerShadows = shadow as FileFormat.InnerShadow[];
} else {
json.shadows = shadow as FileFormat.Shadow[];
}
export const makeImageFill = (
image: FileFormat.ImageDataRef,
patternFillType: FileFormat.PatternFillType = FileFormat.PatternFillType.Fill,
): FileFormat.Fill => ({
_class: 'fill',
isEnabled: true,
fillType: FileFormat.FillType.Pattern,
color: makeColorFromCSS('white'),
image,
noiseIndex: 0,
noiseIntensity: 0,
patternFillType,
patternTileScale: 1,
contextSettings: {
_class: 'graphicsContextSettings',
blendMode: FileFormat.BlendMode.Normal,
opacity: 1,
},
gradient: emptyGradient,
});
lineCapStyle: FileFormat.LineCapStyle = FileFormat.LineCapStyle.Butt,
lineJoinStyle: FileFormat.LineJoinStyle = FileFormat.LineJoinStyle.Miter,
): { borderOptions: FileFormat.BorderOptions; borders: FileFormat.Border[] } => {
const borderOptions = makeBorderOptions(style, width, lineCapStyle, lineJoinStyle);
const borders: FileFormat.Border[] = [
{
_class: 'border',
isEnabled: true,
color: makeColorFromCSS(color),
fillType: FileFormat.FillType.Color,
position,
thickness: width,
contextSettings: {
_class: 'graphicsContextSettings',
blendMode: FileFormat.BlendMode.Normal,
opacity: 1,
},
gradient: emptyGradient,
},
];
return { borderOptions, borders };
};
): FileFormat.ShapeGroup => {
const frame = makeRect(x, y, length, thickness);
const shapeFrame = makeRect(0, 0, length, thickness);
const shapePath = makeShapePath(shapeFrame, makeHorizontalPath());
const content = makeShapeGroup(frame, [shapePath]);
content.style.borders = [
{
_class: 'border',
isEnabled: true,
color: makeColorFromCSS(color),
fillType: FileFormat.FillType.Color,
position: FileFormat.BorderPosition.Center,
thickness,
contextSettings: {
_class: 'graphicsContextSettings',
blendMode: FileFormat.BlendMode.Normal,
opacity: 1,
},
gradient: emptyGradient,
},
];
return content;
};