Hi, i write a code for make a QR code.
First i write it using selection... this is the relevant part:
for (var iy = 0; iy < riga; iy++){ //riga is the number of modules in a row of the QR
for (var ix = 0; ix < riga; ix++){ //QR is a square, same modules in a columns
if (qrcode[ix][iy] == true){ //qrcode is an array of an array... a matrix where the value is true if the square in that position is black
var _x = ix * s; //s is the size of qr code little squares unit, in this case its value is 8 pixel
var _y = iy * s;
selectedRegion =
[
[_x + 0 + x, _y + 0 + y],
[_x + 0 + x, _y + s + y],
[_x + s + x, _y + s + y],
[_x + s + x, _y + 0 + y]
];
//Add to selection
mydoc.selection.select(selectedRegion, SelectionType.EXTEND);
}
}
}
//Fill selection with solid color
var squareColor = new RGBColor;
squareColor.hexValue = "000000";
mydoc.selection.fill(squareColor);
mydoc.selection.deselect();
This work, but is very slow because it must create a selection square for more than 3000 times.
Now i'm trying to use path and crate all the path before drawing it in the document.
This is the code, but no work
/* | |
var lineArray = []; | |
var arrn = 0 |
for (iy = 0; iy < riga; iy++) {
for (var ix = 0; ix < riga; ix++){ | ||||||
if (qrcode[ix][iy] == true){ | ||||||
var _x = ix * s; | ||||||
var _y = iy * s; | ||||||
for (i=0;i<4;i++){ | ||||||
//alert(ix) | ||||||
//alert(i) | ||||||
lineArray[arrn+i] = new PathPointInfo; | ||||||
lineArray[arrn+i].kind = PointKind.CORNERPOINT; | ||||||
switch(i){ | ||||||
case 0: lineArray[arrn+i].anchor = [ parseInt(x + _x) , parseInt(y + _y)]; | ||||||
break; | ||||||
case 1: lineArray[arrn+i].anchor = [ parseInt(x + _x ), parseInt(y + _y + s)]; | ||||||
break; | ||||||
case 2: lineArray[arrn+i].anchor = [ parseInt(x + _x + s) , parseInt(y + _y + s)]; | ||||||
break; | ||||||
case 3: lineArray[arrn+i].anchor = [ parseInt(x + _x + s) , parseInt(y + _y)]; | ||||||
break; | ||||||
} | ||||||
//alert(lineArray[arrn+i].anchor) | ||||||
lineArray[arrn+i].leftDirection = lineArray[arrn+i].anchor; | ||||||
lineArray[arrn+i].rightDirection = lineArray[arrn+i].anchor; | ||||||
} | ||||||
//alert(arrn) | ||||||
arrn = arrn + 4; | ||||||
} | ||||||
} | ||||||
} |
var lineSubPathArray = new SubPathInfo();
lineSubPathArray.closed = true;
lineSubPathArray.operation = ShapeOperation.SHAPEADD;
lineSubPathArray.entireSubPath = lineArray;
var myPathItem = mydoc.pathItems.add("myPath", [lineSubPathArray]);*/
the error is parameter not valid in the last row. I know that it is incomplete because diagonal lines from a square to another...
i want only know if is possible or you have any idea to make this qr code generation more fast.. whit any method
Sorry for my poor english!