mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00

Also: - Cleans up color stop and linear gradient regular expressions. - Handles percentage-based linear gradient positions (fixes Firefox). Fixes niklasvh/html2canvas#469.
22 lines
679 B
JavaScript
22 lines
679 B
JavaScript
function GradientContainer(imageData) {
|
|
this.src = imageData.value;
|
|
this.colorStops = [];
|
|
this.type = null;
|
|
this.x0 = 0.5;
|
|
this.y0 = 0.5;
|
|
this.x1 = 0.5;
|
|
this.y1 = 0.5;
|
|
this.promise = Promise.resolve(true);
|
|
}
|
|
|
|
GradientContainer.TYPES = {
|
|
LINEAR: 1,
|
|
RADIAL: 2
|
|
};
|
|
|
|
// TODO: support hsl[a], negative %/length values
|
|
// TODO: support <angle> (e.g. -?\d{1,3}(?:\.\d+)deg, etc. : https://developer.mozilla.org/docs/Web/CSS/angle )
|
|
GradientContainer.REGEXP_COLORSTOP = /^\s*(rgba?\(\s*\d{1,3},\s*\d{1,3},\s*\d{1,3}(?:,\s*[0-9\.]+)?\s*\)|[a-z]{3,20}|#[a-f0-9]{3,6})(?:\s+(\d{1,3}(?:\.\d+)?)(%|px)?)?(?:\s|$)/i;
|
|
|
|
module.exports = GradientContainer;
|