mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
"renamed getColorStopsFromGradient to parseGradient"
This commit is contained in:
parent
75ba867988
commit
a4f13de455
@ -25,7 +25,7 @@ var reGradients = [
|
|||||||
// ["-webkit-linear-gradient(left, rgb(206, 219, 233) 0%, rgb(170, 197, 222) 17%, rgb(97, 153, 199) 50%, rgb(58, 132, 195) 51%, rgb(65, 154, 214) 59%, rgb(75, 184, 240) 71%, rgb(58, 139, 194) 84%, rgb(38, 85, 139) 100%)", "-webkit-linear-gradient", "left", ", rgb(206, 219, 233) 0%, rgb(170, 197, 222) 17%, rgb(97, 153, 199) 50%, rgb(58, 132, 195) 51%, rgb(65, 154, 214) 59%, rgb(75, 184, 240) 71%, rgb(58, 139, 194) 84%, rgb(38, 85, 139) 100%"]
|
// ["-webkit-linear-gradient(left, rgb(206, 219, 233) 0%, rgb(170, 197, 222) 17%, rgb(97, 153, 199) 50%, rgb(58, 132, 195) 51%, rgb(65, 154, 214) 59%, rgb(75, 184, 240) 71%, rgb(58, 139, 194) 84%, rgb(38, 85, 139) 100%)", "-webkit-linear-gradient", "left", ", rgb(206, 219, 233) 0%, rgb(170, 197, 222) 17%, rgb(97, 153, 199) 50%, rgb(58, 132, 195) 51%, rgb(65, 154, 214) 59%, rgb(75, 184, 240) 71%, rgb(58, 139, 194) 84%, rgb(38, 85, 139) 100%"]
|
||||||
// ["-webkit-gradient(linear, 0% 0, 0% 100%, from(rgb(252, 252, 252)), to(rgb(232, 232, 232)))", "-webkit-gradient", "linear", "0% 0", "0% 100%", ", from(rgb(252, 252, 252)), to(rgb(232, 232, 232))"]
|
// ["-webkit-gradient(linear, 0% 0, 0% 100%, from(rgb(252, 252, 252)), to(rgb(232, 232, 232)))", "-webkit-gradient", "linear", "0% 0", "0% 100%", ", from(rgb(252, 252, 252)), to(rgb(232, 232, 232))"]
|
||||||
|
|
||||||
_html2canvas.Generate.getColorStopsFromGradient = function(css, bounds) {
|
_html2canvas.Generate.parseGradient = function(css, bounds) {
|
||||||
var gradient, i, len = reGradients.length, m1, stop, m2, m2Len, step, m3;
|
var gradient, i, len = reGradients.length, m1, stop, m2, m2Len, step, m3;
|
||||||
|
|
||||||
for(i = 0; i < len; i+=1){
|
for(i = 0; i < len; i+=1){
|
||||||
@ -111,7 +111,7 @@ _html2canvas.Generate.Gradient = function(src, bounds) {
|
|||||||
canvas.width = bounds.width;
|
canvas.width = bounds.width;
|
||||||
canvas.height = bounds.height;
|
canvas.height = bounds.height;
|
||||||
|
|
||||||
gradient = _html2canvas.Generate.getColorStopsFromGradient(src, bounds);
|
gradient = _html2canvas.Generate.parseGradient(src, bounds);
|
||||||
|
|
||||||
img = new Image();
|
img = new Image();
|
||||||
|
|
||||||
|
@ -13,9 +13,9 @@ $(function() {
|
|||||||
numDivs = {},
|
numDivs = {},
|
||||||
expected = {};
|
expected = {};
|
||||||
|
|
||||||
propsToTest['Generate.getColorStopsFromGradient'] = ["backgroundImage"];
|
propsToTest['Generate.parseGradient'] = ["backgroundImage"];
|
||||||
numDivs['Generate.getColorStopsFromGradient'] = $('#backgroundGradients div').length;
|
numDivs['Generate.parseGradient'] = $('#backgroundGradients div').length;
|
||||||
expected['Generate.getColorStopsFromGradient'] = [
|
expected['Generate.parseGradient'] = [
|
||||||
{
|
{
|
||||||
type: 'linear',
|
type: 'linear',
|
||||||
x0: 0,
|
x0: 0,
|
||||||
@ -80,23 +80,23 @@ $(function() {
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
test('Generate.getColorStopsFromGradient', propsToTest['Generate.getColorStopsFromGradient'].length * numDivs['Generate.getColorStopsFromGradient'], function() {
|
test('Generate.parseGradient', propsToTest['Generate.parseGradient'].length * numDivs['Generate.parseGradient'], function() {
|
||||||
|
|
||||||
$('#backgroundGradients div').each(function(i, el) {
|
$('#backgroundGradients div').each(function(i, el) {
|
||||||
$.each(propsToTest['Generate.getColorStopsFromGradient'], function(s, prop) {
|
$.each(propsToTest['Generate.parseGradient'], function(s, prop) {
|
||||||
var src, gradient, exptd;
|
var src, gradient, exptd;
|
||||||
|
|
||||||
src = _html2canvas.Util.getCSS(el, prop);
|
src = _html2canvas.Util.getCSS(el, prop);
|
||||||
|
|
||||||
if (/^(-webkit|-o|-moz|-ms|linear)-/.test(src)) {
|
if (/^(-webkit|-o|-moz|-ms|linear)-/.test(src)) {
|
||||||
|
|
||||||
gradient = _html2canvas.Generate.getColorStopsFromGradient(src, {
|
gradient = _html2canvas.Generate.parseGradient(src, {
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50
|
height: 50
|
||||||
});
|
});
|
||||||
|
|
||||||
// compare
|
// compare
|
||||||
exptd = expected['Generate.getColorStopsFromGradient'][i];
|
exptd = expected['Generate.parseGradient'][i];
|
||||||
|
|
||||||
QUnit.deepEqual(gradient, exptd, 'Parsed gradient; got: ' + JSON.stringify(gradient));
|
QUnit.deepEqual(gradient, exptd, 'Parsed gradient; got: ' + JSON.stringify(gradient));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user