final int ScreenSize = 512; // width and height of screen final int minBorderWidth = 40; // min width of border around QR code int[][] ModuleArray; int[][] loadedQRCodePattern () { JSONArray ModuleArray = loadJSONArray("QR-Code.json"); int RowCount = ModuleArray.size(); int[][] Result = new int[RowCount][]; for (int y = 0; y < RowCount; y++) { Result[y] = ModuleArray.getJSONArray(y).getIntArray(); } return Result; } void setup () { size(512,512); // ScreenSize,ScreenSize background(255); fill(0); noStroke(); ModuleArray = loadedQRCodePattern(); int QRCodeSize = ModuleArray.length; int ModuleSize = max(1,floor((ScreenSize-2*minBorderWidth)/QRCodeSize)); int xOffset = floor((ScreenSize-QRCodeSize*ModuleSize)/2); int yOffset = xOffset; float xCenter = QRCodeSize/2; float maxR = sqrt(2)*QRCodeSize/2; float yCenter = QRCodeSize/2; float r = 1.0/8.0; colorMode(HSB, 2*PI,1,1); for (float R = r; R <= maxR; R += 2*r) { float dAlpha = 2*r/R; for (float alpha = 0; alpha < 2*PI; alpha += dAlpha) { float dX = R*cos(alpha); float DiscX = xCenter + dX; float dY = -R*sin(alpha); float DiscY = yCenter + dY; int x = round(DiscX); if ((x < 0) || (x >= QRCodeSize)) { continue; } int y = round(DiscY); if ((y < 0) || (y >= QRCodeSize)) { continue; } if (ModuleArray[y][x] > 0) { float Distance = sqrt(dX*dX+dY*dY); fill(color(alpha,Distance,0.5)); circle( xOffset+DiscX*ModuleSize,yOffset+DiscY*ModuleSize, 2.1*ModuleSize/8 ); } } } save("QRCode-with-combinedDots.png"); noLoop(); }