How to use the @sketch-hq/sketch-file-format-ts.FileFormat1.BlendMode function in @sketch-hq/sketch-file-format-ts

To help you get started, we’ve selected a few @sketch-hq/sketch-file-format-ts examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github airbnb / react-sketchapp / src / jsonUtils / style.ts View on Github external
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[];
    }
github airbnb / react-sketchapp / src / jsonUtils / models.ts View on Github external
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,
});
github airbnb / react-sketchapp / src / jsonUtils / borders.ts View on Github external
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 };
};
github airbnb / react-sketchapp / src / jsonUtils / shapeLayers.ts View on Github external
): 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;
};