Add support to extend for extendWith, allows copy/mirror/repeat (#3556)

This commit is contained in:
Tomasz Janowski
2023-02-18 01:01:24 +11:00
committed by GitHub
parent ebf4ccd124
commit 6f0e6f2e65
25 changed files with 134 additions and 65 deletions

View File

@@ -36,6 +36,18 @@ const position = {
'left top': 8
};
/**
* How to extend the image.
* @member
* @private
*/
const extendWith = {
background: 'background',
copy: 'copy',
repeat: 'repeat',
mirror: 'mirror'
};
/**
* Strategies for automagic cover behaviour.
* @member
@@ -393,6 +405,13 @@ function extend (extend) {
}
}
this._setBackgroundColourOption('extendBackground', extend.background);
if (is.defined(extend.extendWith)) {
if (is.string(extendWith[extend.extendWith])) {
this.options.extendWith = extendWith[extend.extendWith];
} else {
throw is.invalidParameterError('extendWith', 'valid value', extend.extendWith);
}
}
} else {
throw is.invalidParameterError('extend', 'integer or object', extend);
}