MCPcopy Create free account
hub / github.com/MankaiHuang/screen-visualization / updateGrid

Function updateGrid

public/iframe/lib/js/echarts-wordcloud.js:978–1014  ·  view source on GitHub ↗
(gx, gy, gw, gh, info, item)

Source from the content-addressed store, hash-verified

976 /* Update the filling information of the given space with occupied points.
977 Draw the mask on the canvas if necessary. */
978 var updateGrid = function updateGrid(gx, gy, gw, gh, info, item) {
979 var occupied = info.occupied;
980 var drawMask = settings.drawMask;
981 var ctx;
982 if (drawMask) {
983 ctx = elements[0].getContext('2d');
984 ctx.save();
985 ctx.fillStyle = settings.maskColor;
986 }
987
988 var dimension;
989 if (interactive) {
990 var bounds = info.bounds;
991 dimension = {
992 x: (gx + bounds[3]) * g,
993 y: (gy + bounds[0]) * g,
994 w: (bounds[1] - bounds[3] + 1) * g,
995 h: (bounds[2] - bounds[0] + 1) * g
996 };
997 }
998
999 var i = occupied.length;
1000 while (i--) {
1001 var px = gx + occupied[i][0];
1002 var py = gy + occupied[i][1];
1003
1004 if (px >= ngx || py >= ngy || px < 0 || py < 0) {
1005 continue;
1006 }
1007
1008 fillGridAt(px, py, drawMask, dimension, item);
1009 }
1010
1011 if (drawMask) {
1012 ctx.restore();
1013 }
1014 };
1015
1016 /* putWord() processes each item on the list,
1017 calculate it's size and determine it's position, and actually

Callers 1

tryToPutWordAtPointFunction · 0.85

Calls 1

fillGridAtFunction · 0.85

Tested by

no test coverage detected