summaryrefslogtreecommitdiff
path: root/tests/auto/quick/qquickcanvasitem/data/testhelper.js
blob: bac0210e164497e53fc7bdd113c2e58547210b7b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function comparePixel(ctx,x,y,r,g,b,a, d)
{
   var c = ctx.getImageData(x,y,1,1).data;
   if (d === undefined)
      d = 0;
   r = Math.round(r);
   g = Math.round(g);
   b = Math.round(b);
   a = Math.round(a);

   if (Math.abs(c[0]-r)>d || Math.abs(c[1]-g)>d || Math.abs(c[2]-b)>d || Math.abs(c[3]-a)>d) {
      console.log('Pixel compare fail:\nactual  :[' + c[0]+','+c[1]+','+c[2]+','+c[3] + ']\nexpected:['+r+','+g+','+b+','+a+'] +/- '+d);
      return false;
   }
   return true;
}