Skip to content

Commit

Permalink
feat(fill): add graphicscontextsettings to fill (#132)
Browse files Browse the repository at this point in the history
* fix: add opacity via args to GraphicsContextSettings
* feat: add contextsettings to fill and pass opacity
  • Loading branch information
kgoedecke committed Jul 30, 2020
1 parent 4d5b4f6 commit ff99391
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions models/Fill/Fill.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

const Color = require('../Color');
const Gradient = require('../Gradient');
const GraphicsContextSettings = require('../GraphicsContextSettings');

/**
*
Expand All @@ -26,6 +27,7 @@ class Fill {
* @property {integer} noiseIntensity
* @property {integer} patternFillType
* @property {integer} patternTileScale
* @property {GraphicsContextSettings.Model} contextSettings
*/
static get Model() {
return {
Expand All @@ -38,13 +40,15 @@ class Fill {
patternFillType: 0,
patternTileScale: 1,
gradient: Gradient.Model,
contextSettings: GraphicsContextSettings.Model,
};
}

/**
*
* @param {Object} args
* @param {String|Object} args.color Passed to {@link Color} constructor
* @param {float|Object} args.opacity Passed to {@link GraphicsContextSettings} constructor
* @param {Fill.Model} json
*/
constructor(args = {}, json) {
Expand All @@ -69,6 +73,7 @@ class Fill {
patternFillType: args.patternFillType || 0,
patternTileScale: args.patternTileScale || 1,
gradient: args.gradient ? new Gradient(args.gradient) : undefined,
contextSettings: new GraphicsContextSettings({ opacity: args.opacity }),
});
}
return this;
Expand Down
2 changes: 2 additions & 0 deletions models/Fill/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Color from '../Color';
import Gradient from '../Gradient';
import GraphicsContextSettings from '../GraphicsContextSettings';

declare const enum FillType {
Color = 0,
Expand All @@ -20,6 +21,7 @@ declare class Fill {
patternFillType: number;
patternTileScale: number;
gradient: Gradient;
contextSettings: GraphicsContextSettings;

constructor(args?: any, json?: any);
}
Expand Down
1 change: 1 addition & 0 deletions models/GraphicsContextSettings/GraphicsContextSettings.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class GraphicsContextSettings {
} else {
Object.assign(this, GraphicsContextSettings.Model, args, {
blendMode: blendModeMap[args.blendMode || 'normal'],
opacity: args.opacity || 1,
});
}
return this;
Expand Down

0 comments on commit ff99391

Please sign in to comment.