hosomi += 0.4 * (1 - Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1)) / 50);\r
}\r
\r
+ //---------------------------------------------------------------\r
+ \r
poly = new Polygon();\r
poly2 = new Polygon();\r
\r
- for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
- t = tt / 1000;\r
- \r
- if(sx1 == sx2 && sy1 == sy2){ // Spline\r
- //calculate a dot\r
- x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * sx1 + t * t * x2);\r
- y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * sy1 + t * t * y2);\r
+ if(sx1 == sx2 && sy1 == sy2){ // Spline\r
+ if(kage.kUseCurve){\r
+ // generating fatten curve -- begin\r
+ var kage2 = new Kage();\r
+ kage2.kRate = 10;\r
\r
- //KATAMUKI of vector by BIBUN\r
- ix = (x1 - 2.0 * sx1 + x2) * 2.0 * t + (-2.0 * x1 + 2.0 * sx1);\r
- iy = (y1 - 2.0 * sy1 + y2) * 2.0 * t + (-2.0 * y1 + 2.0 * sy1);\r
- } else { // Bezier\r
- //calculate a dot\r
+ var curve = new Array(2); // L and R\r
+ get_candidate(kage2, curve, a1, a2, x1, y1, sx1, sy1, x2, y2);\r
+ \r
+ var dcl12_34 = new Array(2);\r
+ var dcr12_34 = new Array(2);\r
+ var dpl12_34 = new Array(2);\r
+ var dpr12_34 = new Array(2);\r
+ divide_curve(kage2, x1, y1, sx1, sy1, x2, y2, curve[0], dcl12_34, dpl12_34);\r
+ divide_curve(kage2, x1, y1, sx1, sy1, x2, y2, curve[1], dcr12_34, dpr12_34);\r
+ \r
+ var ncl1 = new Array(7);\r
+ var ncl2 = new Array(7);\r
+ find_offcurve(kage2, dcl12_34[0], dpl12_34[0][2], dpl12_34[0][3], ncl1);\r
+ find_offcurve(kage2, dcl12_34[1], dpl12_34[1][2], dpl12_34[1][3], ncl2);\r
+ \r
+ poly.push(ncl1[0], ncl1[1]);\r
+ poly.push(ncl1[2], ncl1[3], 1);\r
+ poly.push(ncl1[4], ncl1[5]);\r
+ poly.push(ncl2[2], ncl2[3], 1);\r
+ poly.push(ncl2[4], ncl2[5]);\r
+ \r
+ poly2.push(dcr12_34[0][0][0], dcr12_34[0][0][1]);\r
+ poly2.push(dpr12_34[0][2] - (ncl1[2] - dpl12_34[0][2]), dpl12_34[0][3] - (ncl1[3] - dpl12_34[0][3]), 1);\r
+ poly2.push(dcr12_34[0][dcr12_34[0].length - 1][0], dcr12_34[0][dcr12_34[0].length - 1][1]);\r
+ poly2.push(dpr12_34[1][2] - (ncl2[2] - dpl12_34[1][2]), dpl12_34[1][3] - (ncl2[3] - dpl12_34[1][3]), 1);\r
+ poly2.push(dcr12_34[1][dcr12_34[1].length - 1][0], dcr12_34[1][dcr12_34[1].length - 1][1]);\r
+ \r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ // generating fatten curve -- end\r
+ } else {\r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = tt / 1000;\r
+ \r
+ // calculate a dot\r
+ x = ((1.0 - t) * (1.0 - t) * x1 + 2.0 * t * (1.0 - t) * sx1 + t * t * x2);\r
+ y = ((1.0 - t) * (1.0 - t) * y1 + 2.0 * t * (1.0 - t) * sy1 + t * t * y2);\r
+ \r
+ // KATAMUKI of vector by BIBUN\r
+ ix = (x1 - 2.0 * sx1 + x2) * 2.0 * t + (-2.0 * x1 + 2.0 * sx1);\r
+ iy = (y1 - 2.0 * sy1 + y2) * 2.0 * t + (-2.0 * y1 + 2.0 * sy1);\r
+ \r
+ // line SUICHOKU by vector\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1);\r
+ ia = Math.sin(ir) * (kage.kMinWidthT);\r
+ ib = Math.cos(ir) * (kage.kMinWidthT);\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ \r
+ if(a1 == 7 && a2 == 0){ // L2RD: fatten\r
+ deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;\r
+ }\r
+ else if(a1 == 7){\r
+ deltad = Math.pow(t, hosomi);\r
+ }\r
+ else if(a2 == 7){\r
+ deltad = Math.pow(1.0 - t, hosomi);\r
+ }\r
+ else{ deltad = 1; }\r
+ \r
+ if(deltad < 0.15){\r
+ deltad = 0.15;\r
+ }\r
+ ia = ia * deltad;\r
+ ib = ib * deltad;\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //copy to polygon structure\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
+ }\r
+ \r
+ // suiheisen ni setsuzoku\r
+ if(a1 == 132){\r
+ var index = 0;\r
+ while(true){\r
+ if(poly2.array[index].y <= y1 && y1 <= poly2.array[index + 1].y){\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ newx1 = poly2.array[index + 1].x + (poly2.array[index].x - poly2.array[index + 1].x) *\r
+ (poly2.array[index + 1].y - y1) / (poly2.array[index + 1].y - poly2.array[index].y);\r
+ newy1 = y1;\r
+ newx2 = poly.array[0].x + (poly.array[0].x - poly.array[1].x) * (poly.array[0].y - y1) /\r
+ (poly.array[1].y - poly.array[0].y);\r
+ newy2 = y1;\r
+ \r
+ for(var i = 0; i < index; i++){\r
+ poly2.shift();\r
+ }\r
+ poly2.set(0, newx1, newy1);\r
+ poly.unshift(newx2, newy2);\r
+ }\r
+ \r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
+ }\r
+ } else { // Bezier\r
+ for(tt = 0; tt <= 1000; tt = tt + kage.kRate){\r
+ t = tt / 1000;\r
+ \r
+ // calculate a dot\r
x = (1.0 - t) * (1.0 - t) * (1.0 - t) * x1 + 3.0 * t * (1.0 - t) * (1.0 - t) * sx1 + 3 * t * t * (1.0 - t) * sx2 + t * t * t * x2;\r
y = (1.0 - t) * (1.0 - t) * (1.0 - t) * y1 + 3.0 * t * (1.0 - t) * (1.0 - t) * sy1 + 3 * t * t * (1.0 - t) * sy2 + t * t * t * y2;\r
- //KATAMUKI of vector by BIBUN\r
+ // KATAMUKI of vector by BIBUN\r
ix = t * t * (-3 * x1 + 9 * sx1 + -9 * sx2 + 3 * x2) + t * (6 * x1 + -12 * sx1 + 6 * sx2) + -3 * x1 + 3 * sx1;\r
iy = t * t * (-3 * y1 + 9 * sy1 + -9 * sy2 + 3 * y2) + t * (6 * y1 + -12 * sy1 + 6 * sy2) + -3 * y1 + 3 * sy1;\r
- }\r
- //line SUICHOKU by vector\r
- if(ix != 0 && iy != 0){\r
- ir = Math.atan(iy / ix * -1);\r
- ia = Math.sin(ir) * (kage.kMinWidthT);\r
- ib = Math.cos(ir) * (kage.kMinWidthT);\r
- }\r
- else if(ix == 0){\r
- ia = kage.kMinWidthT;\r
- ib = 0;\r
- }\r
- else{\r
- ia = 0;\r
- ib = kage.kMinWidthT;\r
- }\r
- \r
- if(a1 == 7 && a2 == 0){ // L2RD: fatten\r
- deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;\r
- }\r
- else if(a1 == 7){\r
- deltad = Math.pow(t, hosomi);\r
- }\r
- else if(a2 == 7){\r
- deltad = Math.pow(1.0 - t, hosomi);\r
- }\r
- else{ deltad = 1; }\r
- \r
- if(deltad < 0.15){\r
- deltad = 0.15;\r
- }\r
- ia = ia * deltad;\r
- ib = ib * deltad;\r
- \r
- //reverse if vector is going 2nd/3rd quadrants\r
- if(ix <= 0){\r
- ia = ia * -1;\r
- ib = ib * -1;\r
+ \r
+ // line SUICHOKU by vector\r
+ if(ix != 0 && iy != 0){\r
+ ir = Math.atan(iy / ix * -1);\r
+ ia = Math.sin(ir) * (kage.kMinWidthT);\r
+ ib = Math.cos(ir) * (kage.kMinWidthT);\r
+ }\r
+ else if(ix == 0){\r
+ ia = kage.kMinWidthT;\r
+ ib = 0;\r
+ }\r
+ else{\r
+ ia = 0;\r
+ ib = kage.kMinWidthT;\r
+ }\r
+ \r
+ if(a1 == 7 && a2 == 0){ // L2RD: fatten\r
+ deltad = Math.pow(t, hosomi) * kage.kL2RDfatten;\r
+ }\r
+ else if(a1 == 7){\r
+ deltad = Math.pow(t, hosomi);\r
+ }\r
+ else if(a2 == 7){\r
+ deltad = Math.pow(1.0 - t, hosomi);\r
+ }\r
+ else{ deltad = 1; }\r
+ \r
+ if(deltad < 0.15){\r
+ deltad = 0.15;\r
+ }\r
+ ia = ia * deltad;\r
+ ib = ib * deltad;\r
+ \r
+ //reverse if vector is going 2nd/3rd quadrants\r
+ if(ix <= 0){\r
+ ia = ia * -1;\r
+ ib = ib * -1;\r
+ }\r
+ \r
+ //copy to polygon structure\r
+ poly.push(x - ia, y - ib);\r
+ poly2.push(x + ia, y + ib);\r
}\r
\r
- //copy to polygon structure\r
- poly.push(x - ia, y - ib);\r
- poly2.push(x + ia, y + ib);\r
- }\r
- \r
- // suiheisen ni setsuzoku\r
- if(a1 == 132){\r
- var index = 0;\r
- while(true){\r
- if(poly2.array[index].y <= y1 && y1 <= poly2.array[index + 1].y){\r
- break;\r
+ // suiheisen ni setsuzoku\r
+ if(a1 == 132){\r
+ var index = 0;\r
+ while(true){\r
+ if(poly2.array[index].y <= y1 && y1 <= poly2.array[index + 1].y){\r
+ break;\r
+ }\r
+ index++;\r
+ }\r
+ newx1 = poly2.array[index + 1].x + (poly2.array[index].x - poly2.array[index + 1].x) *\r
+ (poly2.array[index + 1].y - y1) / (poly2.array[index + 1].y - poly2.array[index].y);\r
+ newy1 = y1;\r
+ newx2 = poly.array[0].x + (poly.array[0].x - poly.array[1].x) * (poly.array[0].y - y1) /\r
+ (poly.array[1].y - poly.array[0].y);\r
+ newy2 = y1;\r
+ \r
+ for(var i = 0; i < index; i++){\r
+ poly2.shift();\r
}\r
- index++;\r
+ poly2.set(0, newx1, newy1);\r
+ poly.unshift(newx2, newy2);\r
}\r
- newx1 = poly2.array[index + 1].x + (poly2.array[index].x - poly2.array[index + 1].x) *\r
- (poly2.array[index + 1].y - y1) / (poly2.array[index + 1].y - poly2.array[index].y);\r
- newy1 = y1;\r
- newx2 = poly.array[0].x + (poly.array[0].x - poly.array[1].x) * (poly.array[0].y - y1) /\r
- (poly.array[1].y - poly.array[0].y);\r
- newy2 = y1;\r
\r
- for(var i = 0; i < index; i++){\r
- poly2.shift();\r
- }\r
- poly2.set(0, newx1, newy1);\r
- poly.unshift(newx2, newy2);\r
+ poly2.reverse();\r
+ poly.concat(poly2);\r
+ polygons.push(poly);\r
}\r
\r
- poly2.reverse();\r
- poly.concat(poly2);\r
- polygons.push(poly);\r
- \r
//process for head of stroke\r
rad = Math.atan((sy1 - y1) / (sx1 - x1));\r
if(x1 < sx1){ v = 1; } else{ v = -1; }\r
}\r
}\r
\r
+ var type;\r
+ var pm = 0;\r
if(a1 == 0){\r
if(y1 <= y2){ //from up to bottom\r
+ type = (Math.atan2(Math.abs(y1 - sy1), Math.abs(x1 - sx1)) / Math.PI * 2 - 0.4);\r
+ if(type > 0){\r
+ type = type * 2;\r
+ } else {\r
+ type = type * 16;\r
+ }\r
+ if(type < 0){\r
+ pm = -1;\r
+ } else {\r
+ pm = 1;\r
+ }\r
if(x1 == sx1){\r
poly = new Polygon();\r
poly.push(x1 - kage.kMinWidthT, y1);\r
poly.push(x1 + kage.kMinWidthT, y1);\r
- poly.push(x1 - kage.kMinWidthT, y1 - kage.kMinWidthY);\r
+ poly.push(x1 - kage.kMinWidthT * pm, y1 - kage.kMinWidthY * type * pm);\r
polygons.push(poly);\r
}\r
else{\r
poly = new Polygon();\r
poly.push(x1 - kage.kMinWidthT * XX, y1 - kage.kMinWidthT * XY);\r
poly.push(x1 + kage.kMinWidthT * XX, y1 + kage.kMinWidthT * XY);\r
- poly.push(x1 - kage.kMinWidthT * XX - kage.kMinWidthY * YX, y1 - kage.kMinWidthT * XY - kage.kMinWidthY * YY);\r
+ poly.push(x1 - kage.kMinWidthT * pm * XX - kage.kMinWidthY * type * pm * YX, y1 - kage.kMinWidthT * pm * XY - kage.kMinWidthY * type * pm * YY);\r
polygons.push(poly);\r
}\r
}\r
\r
if(a1 == 0){ //beginning of the stroke\r
if(y1 <= y2){ //from up to bottom\r
+ if(pm > 0){\r
+ type = 0;\r
+ }\r
+ var move = kage.kMinWidthY * type * pm;\r
if(x1 == sx1){\r
poly = new Polygon();\r
- poly.push(x1 + kage.kMinWidthT, y1);\r
- poly.push(x1 + kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY);\r
- poly.push(x1 + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3);\r
+ poly.push(x1 + kage.kMinWidthT, y1 - move);\r
+ poly.push(x1 + kage.kMinWidthT * 1.5, y1 + kage.kMinWidthY - move);\r
+ poly.push(x1 + kage.kMinWidthT * 0.5, y1 + kage.kMinWidthY * 3 - move / 2);\r
polygons.push(poly);\r
}\r
else{\r
poly = new Polygon();\r
- poly.push(x1 + kage.kMinWidthT * XX,\r
- y1 + kage.kMinWidthT * XY);\r
- poly.push(x1 + kage.kMinWidthT * 1.5 * XX + kage.kMinWidthY * YX,\r
- y1 + kage.kMinWidthT * 1.5 * XY + kage.kMinWidthY * YY);\r
- poly.push(x1 + kage.kMinWidthT * 0.5 * XX + kage.kMinWidthY * 3 * YX,\r
- y1 + kage.kMinWidthT * 0.5 * XY + kage.kMinWidthY * 3 * YY);\r
+ poly.push(x1 + kage.kMinWidthT * XX - move * YX,\r
+ y1 + kage.kMinWidthT * XY - move * YY);\r
+ poly.push(x1 + kage.kMinWidthT * 1.5 * XX + (kage.kMinWidthY - move * 1.2) * YX,\r
+ y1 + kage.kMinWidthT * 1.5 * XY + (kage.kMinWidthY - move * 1.2) * YY);\r
+ poly.push(x1 + kage.kMinWidthT * 0.5 * XX + (kage.kMinWidthY * 3 - move * 0.8) * YX,\r
+ y1 + kage.kMinWidthT * 0.5 * XY + (kage.kMinWidthY * 3 - move * 0.8) * YY);\r
polygons.push(poly);\r
}\r
}\r
if(a2 == 1 || a2 == 8 || a2 == 15){ //the last filled circle ... it can change 15->5\r
if(sx2 == x2){\r
poly = new Polygon();\r
- poly.push(x2 - kage.kMinWidthT, y2);\r
- poly.push(x2 - kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
- poly.push(x2, y2 + kage.kMinWidthT);\r
- poly.push(x2 + kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
- poly.push(x2 + kage.kMinWidthT, y2);\r
+ if(kage.kUseCurve){\r
+ // by curve path\r
+ poly.push(x2 - kage.kMinWidthT, y2);\r
+ poly.push(x2 - kage.kMinWidthT, y2 + kage.kMinWidthT, 1);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT, y2 + kage.kMinWidthT, 1);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ } else {\r
+ // by polygon\r
+ poly.push(x2 - kage.kMinWidthT, y2);\r
+ poly.push(x2 - kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ }\r
polygons.push(poly);\r
}\r
else if(sy2 == y2){\r
poly = new Polygon();\r
- poly.push(x2, y2 - kage.kMinWidthT);\r
- poly.push(x2 + kage.kMinWidthT * 0.7, y2 - kage.kMinWidthT * 0.7);\r
- poly.push(x2 + kage.kMinWidthT, y2);\r
- poly.push(x2 + kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
- poly.push(x2, y2 + kage.kMinWidthT);\r
+ if(kage.kUseCurve){\r
+ // by curve path\r
+ poly.push(x2 - kage.kMinWidthT, y2);\r
+ poly.push(x2 - kage.kMinWidthT, y2 + kage.kMinWidthT, 1);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT, y2 + kage.kMinWidthT, 1);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ } else {\r
+ // by polygon\r
+ poly.push(x2, y2 - kage.kMinWidthT);\r
+ poly.push(x2 + kage.kMinWidthT * 0.7, y2 - kage.kMinWidthT * 0.7);\r
+ poly.push(x2 + kage.kMinWidthT, y2);\r
+ poly.push(x2 + kage.kMinWidthT * 0.7, y2 + kage.kMinWidthT * 0.7);\r
+ poly.push(x2, y2 + kage.kMinWidthT);\r
+ }\r
polygons.push(poly);\r
}\r
else{\r
poly = new Polygon();\r
- poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
- poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,\r
- y2 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);\r
- poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);\r
- poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,\r
- y2 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);\r
- poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ if(kage.kUseCurve){\r
+ poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.9 * v + Math.sin(rad) * kage.kMinWidthT * 0.9 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.9 * v - Math.cos(rad) * kage.kMinWidthT * 0.9 * v, 1);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.9 * v - Math.sin(rad) * kage.kMinWidthT * 0.9 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.9 * v + Math.cos(rad) * kage.kMinWidthT * 0.9 * v, 1);\r
+ poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ } else {\r
+ poly.push(x2 + Math.sin(rad) * kage.kMinWidthT * v, y2 - Math.cos(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v + Math.sin(rad) * kage.kMinWidthT * 0.7 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v - Math.cos(rad) * kage.kMinWidthT * 0.7 * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * v, y2 + Math.sin(rad) * kage.kMinWidthT * v);\r
+ poly.push(x2 + Math.cos(rad) * kage.kMinWidthT * 0.7 * v - Math.sin(rad) * kage.kMinWidthT * 0.7 * v,\r
+ y2 + Math.sin(rad) * kage.kMinWidthT * 0.7 * v + Math.cos(rad) * kage.kMinWidthT * 0.7 * v);\r
+ poly.push(x2 - Math.sin(rad) * kage.kMinWidthT * v, y2 + Math.cos(rad) * kage.kMinWidthT * v);\r
+ }\r
polygons.push(poly);\r
}\r
}\r
} else {\r
type = type * 3;\r
}\r
- var pm;\r
+ var pm = 0;\r
if(type < 0){\r
pm = -1;\r
} else {\r