123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710 |
- /* This notice must be untouched at all times.
- wz_jsgraphics.js v. 3.05
- The latest version is available at
- http://www.walterzorn.com
- or http://www.devira.com
- or http://www.walterzorn.de
- Copyright (c) 2002-2009 Walter Zorn. All rights reserved.
- Created 3. 11. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
- Last modified: 2. 2. 2009
- Performance optimizations for Internet Explorer
- by Thomas Frank and John Holdsworth.
- fillPolygon method implemented by Matthieu Haller.
- High Performance JavaScript Graphics Library.
- Provides methods
- - to draw lines, rectangles, ellipses, polygons
- with specifiable line thickness,
- - to fill rectangles, polygons, ellipses and arcs
- - to draw text.
- NOTE: Operations, functions and branching have rather been optimized
- to efficiency and speed than to shortness of source code.
- LICENSE: LGPL
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License (LGPL) as published by the Free Software Foundation; either
- version 2.1 of the License, or (at your option) any later version.
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Lesser General Public License for more details.
- You should have received a copy of the GNU Lesser General Public
- License along with this library; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA,
- or see http://www.gnu.org/copyleft/lesser.html
- */
- var jg_ok, jg_ie, jg_fast, jg_dom, jg_moz;
- function _chkDHTM(wnd, x, i)
- // Under XUL, owner of 'document' must be specified explicitly
- {
- x = wnd.document.body || null;
- jg_ie = x && typeof x.insertAdjacentHTML != "undefined" && wnd.document.createElement;
- jg_dom = (x && !jg_ie &&
- typeof x.appendChild != "undefined" &&
- typeof wnd.document.createRange != "undefined" &&
- typeof (i = wnd.document.createRange()).setStartBefore != "undefined" &&
- typeof i.createContextualFragment != "undefined");
- jg_fast = jg_ie && wnd.document.all && !wnd.opera;
- jg_moz = jg_dom && typeof x.style.MozOpacity != "undefined";
- jg_ok = !!(jg_ie || jg_dom);
- };
- function _pntCnvDom()
- {
- var x = this.wnd.document.createRange();
- x.setStartBefore(this.cnv);
- x = x.createContextualFragment(jg_fast? this._htmRpc() : this.htm);
- if(this.cnv) this.cnv.appendChild(x);
- this.htm = "";
- };
- function _pntCnvIe()
- {
- if(this.cnv) this.cnv.insertAdjacentHTML("BeforeEnd", jg_fast? this._htmRpc() : this.htm);
- this.htm = "";
- };
- function _pntDoc()
- {
- this.wnd.document.write(jg_fast? this._htmRpc() : this.htm);
- this.htm = '';
- };
- function _pntN()
- {
- ;
- };
- function _mkDiv(x, y, w, h)
- {
- this.htm += '<div style="position:absolute;'+
- 'left:' + x + 'px;'+
- 'top:' + y + 'px;'+
- 'width:' + w + 'px;'+
- 'height:' + h + 'px;'+
- 'clip:rect(0,'+w+'px,'+h+'px,0);'+
- 'background-color:' + this.color +
- (!jg_moz? ';overflow:hidden' : '')+
- ';"><\/div>';
- };
- function _mkDivIe(x, y, w, h, nType) // DIV 마진을 주기 위하여 type 추가 - hjkim
- {
- this.htm += '%%'+this.color+';'+x+';'+y+';'+w+';'+h+';';
- };
- function _mkDivPrt(x, y, w, h)
- {
- this.htm += '<div style="position:absolute;'+
- 'border-left:' + w + 'px solid ' + this.color + ';'+
- 'left:' + x + 'px;'+
- 'top:' + y + 'px;'+
- 'width:0px;'+
- 'height:' + h + 'px;'+
- 'clip:rect(0,'+w+'px,'+h+'px,0);'+
- 'background-color:' + this.color +
- (!jg_moz? ';overflow:hidden' : '')+
- ';"><\/div>';
- };
- var _regex = /%%([^;]+);([^;]+);([^;]+);([^;]+);([^;]+);/g;
- function _htmRpc()
- {
- return this.htm.replace(
- _regex,
- '<div style="overflow:hidden;position:absolute;background-color:'+
- '$1;left:$2px;top:$3px;width:$4px;height:$5px"></div>\n');
- };
- function _htmPrtRpc()
- {
- return this.htm.replace(
- _regex,
- '<div style="overflow:hidden;position:absolute;background-color:'+
- '$1;left:$2px;top:$3px;width:$4px;height:$5px;border-left:$4px solid $1"></div>\n');
- };
- function _mkLin(x1, y1, x2, y2)
- {
- if(x1 > x2)
- {
- var _x2 = x2;
- var _y2 = y2;
- x2 = x1;
- y2 = y1;
- x1 = _x2;
- y1 = _y2;
- }
- var dx = x2-x1, dy = Math.abs(y2-y1),
- x = x1, y = y1,
- yIncr = (y1 > y2)? -1 : 1;
- if(dx >= dy)
- {
- var pr = dy<<1,
- pru = pr - (dx<<1),
- p = pr-dx,
- ox = x;
- while(dx > 0)
- {--dx;
- ++x;
- if(p > 0)
- {
- this._mkDiv(ox, y, x-ox, 1);
- y += yIncr;
- p += pru;
- ox = x;
- }
- else
- {
- p += pr;
- }
- }
- this._mkDiv(ox, y, x2-ox+1, 1);
- }
- else
- {
- var pr = dx<<1,
- pru = pr - (dy<<1),
- p = pr-dy,
- oy = y;
- if(y2 <= y1)
- {
- while(dy > 0)
- {--dy;
- if(p > 0)
- {
- this._mkDiv(x++, y, 1, oy-y+1);
- y += yIncr;
- p += pru;
- oy = y;
- }
- else
- {
- y += yIncr;
- p += pr;
- }
- }
- this._mkDiv(x2, y2, 1, oy-y2+1);
- }
- else
- {
- while(dy > 0)
- {--dy;
- y += yIncr;
- if(p > 0)
- {
- this._mkDiv(x++, oy, 1, y-oy);
- p += pru;
- oy = y;
- }
- else
- {
- p += pr;
- }
- }
- this._mkDiv(x2, oy, 1, y2-oy+1);
- }
- }
- };
- function _mkLin2D(x1, y1, x2, y2)
- {
- if(x1 > x2)
- {
- var _x2 = x2;
- var _y2 = y2;
- x2 = x1;
- y2 = y1;
- x1 = _x2;
- y1 = _y2;
- }
- var dx = x2-x1, dy = Math.abs(y2-y1),
- x = x1, y = y1,
- yIncr = (y1 > y2)? -1 : 1;
- var s = this.stroke;
- if(dx >= dy)
- {
- if(dx > 0 && s-3 > 0)
- {
- var _s = (s*dx*Math.sqrt(1+dy*dy/(dx*dx))-dx-(s>>1)*dy) / dx;
- _s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
- }
- else var _s = s;
- var ad = Math.ceil(s/2);
- var pr = dy<<1,
- pru = pr - (dx<<1),
- p = pr-dx,
- ox = x;
- while(dx > 0)
- {--dx;
- ++x;
- if(p > 0)
- {
- this._mkDiv(ox, y, x-ox+ad, _s);
- y += yIncr;
- p += pru;
- ox = x;
- }
- else
- {
- p += pr;
- }
- }
- this._mkDiv(ox, y, x2-ox+ad+1, _s);
- this.lineWidth = ox+(x2-ox+ad+1); // Margin 적용을 위해 추가 - hjkim
- this.lineHeight = _s;
- }
- else
- {
- if(s-3 > 0)
- {
- var _s = (s*dy*Math.sqrt(1+dx*dx/(dy*dy))-(s>>1)*dx-dy) / dy;
- _s = (!(s-4)? Math.ceil(_s) : Math.round(_s)) + 1;
- }
- else var _s = s;
- var ad = Math.round(s/2);
- var pr = dx<<1,
- pru = pr - (dy<<1),
- p = pr-dy,
- oy = y;
- if(y2 <= y1)
- {
- ++ad;
- while(dy > 0)
- {--dy;
- if(p > 0)
- {
- this._mkDiv(x++, y, _s, oy-y+ad);
- y += yIncr;
- p += pru;
- oy = y;
- }
- else
- {
- y += yIncr;
- p += pr;
- }
- }
- this._mkDiv(x2, y2, _s, oy-y2+ad);
- this.lineWidth = _s; // Margin 적용을 위해 추가 - hjkim
- this.lineHeight = Math.abs(y2-y1)+(oy-y2+ad);
- }
- else
- {
- while(dy > 0)
- {--dy;
- y += yIncr;
- if(p > 0)
- {
- this._mkDiv(x++, oy, _s, y-oy+ad);
- p += pru;
- oy = y;
- }
- else
- {
- p += pr;
- }
- }
- this._mkDiv(x2, oy, _s, y2-oy+ad+1);
- this.lineWidth = _s; // Margin 적용을 위해 추가 - hjkim
- this.lineHeight = oy+(y2-oy+ad+1);
- }
- }
- };
- function _mkLinDott(x1, y1, x2, y2)
- {
- if(x1 > x2)
- {
- var _x2 = x2;
- var _y2 = y2;
- x2 = x1;
- y2 = y1;
- x1 = _x2;
- y1 = _y2;
- }
- var dx = x2-x1, dy = Math.abs(y2-y1),
- x = x1, y = y1,
- yIncr = (y1 > y2)? -1 : 1,
- drw = true;
- if(dx >= dy)
- {
- var pr = dy<<1,
- pru = pr - (dx<<1),
- p = pr-dx;
- while(dx > 0)
- {--dx;
- if(drw) this._mkDiv(x, y, 1, 1);
- drw = !drw;
- if(p > 0)
- {
- y += yIncr;
- p += pru;
- }
- else
- {
- p += pr;
- }
- ++x;
- }
- }
- else
- {
- var pr = dx<<1,
- pru = pr - (dy<<1),
- p = pr-dy;
- while(dy > 0)
- {--dy;
- if(drw)
- {
- this._mkDiv(x, y, 1, 1);
- }
- drw = !drw;
- y += yIncr;
- if(p > 0)
- {
- ++x;
- p += pru;
- }
- else
- {
- p += pr;
- }
- }
- }
- if(drw)
- {
- this._mkDiv(x, y, 1, 1);
- }
- };
- function _mkOv(left, top, width, height)
- {
- var a = (++width)>>1, b = (++height)>>1,
- wod = width&1, hod = height&1,
- cx = left+a, cy = top+b,
- x = 0, y = b,
- ox = 0, oy = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- w, h;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- w = x-ox;
- h = oy-y;
- if((w&2) && (h&2))
- {
- this._mkOvQds(cx, cy, x-2, y+2, 1, 1, wod, hod);
- this._mkOvQds(cx, cy, x-1, y+1, 1, 1, wod, hod);
- }
- else this._mkOvQds(cx, cy, x-1, oy, w, h, wod, hod);
- ox = x;
- oy = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- }
- w = a-ox+1;
- h = (oy<<1)+hod;
- y = cy-oy;
- this._mkDiv(cx-a, y, w, h);
- this._mkDiv(cx+ox+wod-1, y, w, h);
- };
- function _mkOv2D(left, top, width, height)
- {
- var s = this.stroke;
- width += s+1;
- height += s+1;
- var a = width>>1, b = height>>1,
- wod = width&1, hod = height&1,
- cx = left+a, cy = top+b,
- x = 0, y = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1);
- if(s-4 < 0 && (!(s-2) || width-51 > 0 && height-51 > 0))
- {
- var ox = 0, oy = b,
- w, h,
- pxw;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- w = x-ox;
- h = oy-y;
- if(w-1)
- {
- pxw = w+1+(s&1);
- h = s;
- }
- else if(h-1)
- {
- pxw = s;
- h += 1+(s&1);
- }
- else pxw = h = s;
- this._mkOvQds(cx, cy, x-1, oy, pxw, h, wod, hod);
- ox = x;
- oy = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- }
- this._mkDiv(cx-a, cy-oy, s, (oy<<1)+hod);
- this._mkDiv(cx+a+wod-s, cy-oy, s, (oy<<1)+hod);
- }
- else
- {
- var _a = (width-(s<<1))>>1,
- _b = (height-(s<<1))>>1,
- _x = 0, _y = _b,
- _aa2 = (_a*_a)<<1, _aa4 = _aa2<<1, _bb2 = (_b*_b)<<1, _bb4 = _bb2<<1,
- _st = (_aa2>>1)*(1-(_b<<1)) + _bb2,
- _tt = (_bb2>>1) - _aa2*((_b<<1)-1),
- pxl = new Array(),
- pxt = new Array(),
- _pxb = new Array();
- pxl[0] = 0;
- pxt[0] = b;
- _pxb[0] = _b-1;
- while(y > 0)
- {
- if(st < 0)
- {
- pxl[pxl.length] = x;
- pxt[pxt.length] = y;
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- pxl[pxl.length] = x;
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- pxt[pxt.length] = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- if(_y > 0)
- {
- if(_st < 0)
- {
- _st += _bb2*((_x<<1)+3);
- _tt += _bb4*(++_x);
- _pxb[_pxb.length] = _y-1;
- }
- else if(_tt < 0)
- {
- _st += _bb2*((_x<<1)+3) - _aa4*(_y-1);
- _tt += _bb4*(++_x) - _aa2*(((_y--)<<1)-3);
- _pxb[_pxb.length] = _y-1;
- }
- else
- {
- _tt -= _aa2*((_y<<1)-3);
- _st -= _aa4*(--_y);
- _pxb[_pxb.length-1]--;
- }
- }
- }
- var ox = -wod, oy = b,
- _oy = _pxb[0],
- l = pxl.length,
- w, h;
- for(var i = 0; i < l; i++)
- {
- if(typeof _pxb[i] != "undefined")
- {
- if(_pxb[i] < _oy || pxt[i] < oy)
- {
- x = pxl[i];
- this._mkOvQds(cx, cy, x, oy, x-ox, oy-_oy, wod, hod);
- ox = x;
- oy = pxt[i];
- _oy = _pxb[i];
- }
- }
- else
- {
- x = pxl[i];
- this._mkDiv(cx-x, cy-oy, 1, (oy<<1)+hod);
- this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
- ox = x;
- oy = pxt[i];
- }
- }
- this._mkDiv(cx-a, cy-oy, 1, (oy<<1)+hod);
- this._mkDiv(cx+ox+wod, cy-oy, 1, (oy<<1)+hod);
- }
- };
- function _mkOvDott(left, top, width, height)
- {
- var a = (++width)>>1, b = (++height)>>1,
- wod = width&1, hod = height&1, hodu = hod^1,
- cx = left+a, cy = top+b,
- x = 0, y = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- drw = true;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- if(drw && y >= hodu) this._mkOvQds(cx, cy, x, y, 1, 1, wod, hod);
- drw = !drw;
- }
- };
- function _mkRect(x, y, w, h)
- {
- var s = this.stroke;
- this._mkDiv(x, y, w, s);
- this._mkDiv(x+w, y, s, h);
- this._mkDiv(x, y+h, w+s, s);
- this._mkDiv(x, y+s, s, h-s);
- };
- function _mkRectDott(x, y, w, h)
- {
- this.drawLine(x, y, x+w, y);
- this.drawLine(x+w, y, x+w, y+h);
- this.drawLine(x, y+h, x+w, y+h);
- this.drawLine(x, y, x, y+h);
- };
- function _mkRoundrect(left, top, width, height, ellipsewidth, ellipseheight)
- {
- if (ellipsewidth >= width)
- {
- ellipsewidth = width;
- }
- else
- {
- this._mkDiv(0+(ellipsewidth/2), 0, width-ellipsewidth, 1);
- this._mkDiv(0+(ellipsewidth/2), height-1, width-ellipsewidth, 1);
- }
-
- if (ellipseheight >= height)
- {
- ellipseheight = height;
- }
- else
- {
- this._mkDiv(0, 0+(ellipseheight/2), 1, height-ellipseheight);
- this._mkDiv(width-1, 0+(ellipseheight/2), 1, height-ellipseheight);
- }
- var a = (++ellipsewidth)>>1, b = (++ellipseheight)>>1,
- wod = ellipsewidth&1, hod = ellipseheight&1;
- for (var i = 0; i < 4 ; i++)
- {
- var cx = left+a, cy = top+b,
- x = 0, y = b,
- ox = 0, oy = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- w, h;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- w = x-ox;
- h = oy-y;
- var cxTemp, cyTemp;
- if (i == 0)
- {
- cxTemp = cx;
- cyTemp = cy;
- }
- else if (i == 1)
- {
- cxTemp = cx+width-ellipsewidth;
- cyTemp = cy;
- }
- else if (i == 2)
- {
- cxTemp = cx+width-ellipsewidth;
- cyTemp = cy+height-ellipseheight;
- }
- else if (i == 3)
- {
- cxTemp = cx;
- cyTemp = cy+height-ellipseheight;
- }
- if((w&2) && (h&2))
- {
- this._mkRoundrectQds(cxTemp, cyTemp, x-2, y+2, 1, 1, wod, hod, i);
- this._mkRoundrectQds(cxTemp, cyTemp, x-1, y+1, 1, 1, wod, hod, i);
- }
- else
- {
- this._mkRoundrectQds(cxTemp, cyTemp, x-1, oy, w, h, wod, hod, i);
- }
- ox = x;
- oy = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- }
- w = a-ox+1;
- h = ((oy<<1)+hod)/2;
- y = cy-oy;
- if (i == 0)
- {
- this._mkDiv(cx-a, y, w, h);
- }
- else if (i == 1)
- {
- this._mkDiv(cx+ox+wod-1+width-ellipsewidth, y, w, h);
- }
- else if (i == 2)
- {
- this._mkDiv(cx+ox+wod-1+width-ellipsewidth, height-Math.floor(ellipseheight/2), w, h);
- }
- else if (i == 3)
- {
- this._mkDiv(cx-a, height-Math.floor(ellipseheight/2), w, h);
- }
- }
- };
- function _mkRoundrect2D(left, top, width, height, ellipsewidth, ellipseheight)
- {
- var s = this.stroke;
- if (ellipsewidth >= width)
- {
- ellipsewidth = width;
- }
- else
- {
- this._mkDiv(ellipsewidth/2, -(s/2), width-ellipsewidth, s);
- this._mkDiv(ellipsewidth/2, height-(s/2), width-ellipsewidth, s);
- }
-
- if (ellipseheight >= height)
- {
- ellipseheight = height;
- }
- else
- {
- this._mkDiv(-(s/2), ellipsewidth/2, s, height-ellipsewidth);
- this._mkDiv(width-(s/2), ellipsewidth/2, s, height-ellipsewidth);
- }
- ellipsewidth += s+1;
- ellipseheight += s+1;
- var a = ellipsewidth>>1, b = ellipseheight>>1,
- wod = ellipsewidth&1, hod = ellipseheight&1;
- if(s-4 < 0 && (!(s-2) || ellipsewidth-51 > 0 && ellipseheight-51 > 0))
- {
- for (var i = 0; i < 4 ; i++)
- {
- var cx = left+a, cy = top+b,
- x = 0, y = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1);
- var ox = 0, oy = b,
- w, h,
- pxw;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- w = x-ox;
- h = oy-y;
- if(w-1)
- {
- pxw = w+1+(s&1);
- h = s;
- }
- else if(h-1)
- {
- pxw = s;
- h += 1+(s&1);
- }
- else
- {
- pxw = h = s;
- }
- var cxTemp, cyTemp;
- if (i == 0)
- {
- cxTemp = cx;
- cyTemp = cy;
- }
- else if (i == 1)
- {
- cxTemp = cx+width-ellipsewidth+s-(s%2);
- cyTemp = cy;
- }
- else if (i == 2)
- {
- cxTemp = cx+width-ellipsewidth+s-(s%2);
- cyTemp = cy+height-ellipseheight+s-(s%2);
- }
- else if (i == 3)
- {
- cxTemp = cx;
- cyTemp = cy+height-ellipseheight+s-(s%2);
- }
-
- this._mkRoundrectQds(cxTemp, cyTemp, x-1, oy, pxw, h, wod, hod, i);
- ox = x;
- oy = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- }
- if (i == 0)
- {
- this._mkDiv(cx-a, cy-oy, s, ((oy<<1)+hod)/2);
- }
- else if (i == 1)
- {
- this._mkDiv(cx+a+wod-s+width-ellipsewidth+s-(s%2), cy-oy, s, ((oy<<1)+hod)/2);
- }
- else if (i == 2)
- {
- this._mkDiv(cx+a+wod-s+width-ellipsewidth+s-(s%2), height-Math.floor(ellipseheight/2), s, ((oy<<1)+hod)/2);
- }
- else if (i == 3)
- {
- this._mkDiv(cx-a, height-Math.floor(ellipseheight/2), s, ((oy<<1)+hod)/2);
- }
- }
- }
- else
- {
- for (var i = 0; i < 4 ; i++)
- {
- var cx = left+a, cy = top+b,
- x = 0, y = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1);
- var _a = (ellipsewidth-(s<<1))>>1,
- _b = (ellipseheight-(s<<1))>>1,
- _x = 0, _y = _b,
- _aa2 = (_a*_a)<<1, _aa4 = _aa2<<1, _bb2 = (_b*_b)<<1, _bb4 = _bb2<<1,
- _st = (_aa2>>1)*(1-(_b<<1)) + _bb2,
- _tt = (_bb2>>1) - _aa2*((_b<<1)-1),
- pxl = new Array(),
- pxt = new Array(),
- _pxb = new Array();
- pxl[0] = 0;
- pxt[0] = b;
- _pxb[0] = _b-1;
- while(y > 0)
- {
- if(st < 0)
- {
- pxl[pxl.length] = x;
- pxt[pxt.length] = y;
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- pxl[pxl.length] = x;
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- pxt[pxt.length] = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- if(_y > 0)
- {
- if(_st < 0)
- {
- _st += _bb2*((_x<<1)+3);
- _tt += _bb4*(++_x);
- _pxb[_pxb.length] = _y-1;
- }
- else if(_tt < 0)
- {
- _st += _bb2*((_x<<1)+3) - _aa4*(_y-1);
- _tt += _bb4*(++_x) - _aa2*(((_y--)<<1)-3);
- _pxb[_pxb.length] = _y-1;
- }
- else
- {
- _tt -= _aa2*((_y<<1)-3);
- _st -= _aa4*(--_y);
- _pxb[_pxb.length-1]--;
- }
- }
- }
- var ox = -wod, oy = b,
- _oy = _pxb[0],
- l = pxl.length,
- w, h;
-
- var cxTemp, cyTemp;
- if (i == 0)
- {
- cxTemp = cx;
- cyTemp = cy;
- }
- else if (i == 1)
- {
- cxTemp = cx+width-ellipsewidth+s-(s%2);
- cyTemp = cy;
- }
- else if (i == 2)
- {
- cxTemp = cx+width-ellipsewidth+s-(s%2);
- cyTemp = cy+height-ellipseheight+s-(s%2);
- }
- else if (i == 3)
- {
- cxTemp = cx;
- cyTemp = cy+height-ellipseheight+s-(s%2);
- }
-
- for(var j = 0; j < l; j++)
- {
- if(typeof _pxb[j] != "undefined")
- {
- if(_pxb[j] < _oy || pxt[j] < oy)
- {
- x = pxl[j];
- this._mkRoundrectQds(cxTemp, cyTemp, x, oy, x-ox, oy-_oy, wod, hod, i);
- ox = x;
- oy = pxt[j];
- _oy = _pxb[j];
- }
- }
- else
- {
- x = pxl[j];
- if (i == 0)
- {
- this._mkDiv(cxTemp-x, cyTemp-oy, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 1)
- {
- this._mkDiv(cxTemp+ox+wod, cyTemp-oy, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 2)
- {
- this._mkDiv(cxTemp+ox+wod, cyTemp, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 3)
- {
- this._mkDiv(cxTemp-x, cyTemp, 1, ((oy<<1)+hod)/2);
- }
- ox = x;
- oy = pxt[j];
- }
- }
- if (i == 0)
- {
- this._mkDiv(cxTemp-a, cyTemp-oy, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 1)
- {
- this._mkDiv(cxTemp+ox+wod, cyTemp-oy, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 2)
- {
- this._mkDiv(cxTemp+ox+wod, cyTemp, 1, ((oy<<1)+hod)/2);
- }
- else if (i == 3)
- {
- this._mkDiv(cxTemp-a, cyTemp, 1, ((oy<<1)+hod)/2);
- }
- }
- }
- };
- function _mkRoundrectDott(left, top, width, height, ellipsewidth, ellipseheight)
- {
- if (ellipsewidth >= width)
- {
- ellipsewidth = width;
- }
- else
- {
- this.drawLine(ellipsewidth/2, 0, width-(ellipsewidth/2)-1, 0);
- this.drawLine(ellipsewidth/2, height-1, width-(ellipsewidth/2)-1, height-1);
- }
-
- if (ellipseheight >= height)
- {
- ellipseheight = height;
- }
- else
- {
- this.drawLine(width-1, ellipseheight/2, width-1, height-(ellipseheight/2)-1);
- this.drawLine(0, ellipseheight/2, 0, height-(ellipseheight/2)-1);
- }
- var a = (++ellipsewidth)>>1, b = (++ellipseheight)>>1,
- wod = ellipsewidth&1, hod = ellipseheight&1, hodu = hod^1;
- for (var i = 0; i < 4 ; i++)
- {
- var cx = left+a, cy = top+b,
- x = 0, y = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- drw = true;
- while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- var cxTemp, cyTemp;
- if (i == 0)
- {
- cxTemp = cx;
- cyTemp = cy;
- }
- else if (i == 1)
- {
- cxTemp = cx+width-ellipsewidth;
- cyTemp = cy;
- }
- else if (i == 2)
- {
- cxTemp = cx+width-ellipsewidth;
- cyTemp = cy+height-ellipseheight;
- }
- else if (i == 3)
- {
- cxTemp = cx;
- cyTemp = cy+height-ellipseheight;
- }
- if(drw && y >= hodu)
- {
- this._mkRoundrectQds(cxTemp, cyTemp, x, y, 1, 1, wod, hod, i);
- }
- drw = !drw;
- }
- }
- };
- function jsgFont()
- {
- this.PLAIN = 'font-weight:normal;';
- this.BOLD = 'font-weight:bold;';
- this.ITALIC = 'font-style:italic;';
- this.ITALIC_BOLD = this.ITALIC + this.BOLD;
- this.BOLD_ITALIC = this.ITALIC_BOLD;
- };
- var Font = new jsgFont();
- function jsgStroke()
- {
- this.DOTTED = -1;
- };
- var Stroke = new jsgStroke();
- function jsGraphics(cnv, wnd)
- {
- this.setColor = function(x)
- {
- this.color = x.toLowerCase();
- };
- this.setStroke = function(x)
- {
- this.stroke = x;
- if(!(x+1))
- {
- this.drawLine = _mkLinDott;
- this._mkOv = _mkOvDott;
- this.drawRect = _mkRectDott;
- this.drawRoundrect = _mkRoundrectDott;
- }
- else if(x-1 > 0)
- {
- this.drawLine = _mkLin2D;
- this._mkOv = _mkOv2D;
- this.drawRect = _mkRect;
- this.drawRoundrect = _mkRoundrect2D;
- }
- else
- {
- this.drawLine = _mkLin;
- this._mkOv = _mkOv;
- this.drawRect = _mkRect;
- this.drawRoundrect = _mkRoundrect;
- }
- };
- this.setPrintable = function(arg)
- {
- this.printable = arg;
- if(jg_fast)
- {
- this._mkDiv = _mkDivIe;
- this._htmRpc = arg? _htmPrtRpc : _htmRpc;
- }
- else
- {
- this._mkDiv = arg? _mkDivPrt : _mkDiv;
- }
- };
- this.setFont = function(fam, sz, sty)
- {
- this.ftFam = fam;
- this.ftSz = sz;
- this.ftSty = sty || Font.PLAIN;
- };
- this.drawPolyline = this.drawPolyLine = function(x, y)
- {
- for (var i=x.length - 1; i;)
- {--i;
- this.drawLine(x[i], y[i], x[i+1], y[i+1]);
- }
- };
- this.fillRect = function(x, y, w, h)
- {
- this._mkDiv(x, y, w, h);
- };
- this.drawPolygon = function(x, y)
- {
- this.drawPolyline(x, y);
- this.drawLine(x[x.length-1], y[x.length-1], x[0], y[0]);
- };
- this.drawEllipse = this.drawOval = function(x, y, w, h)
- {
- this._mkOv(x, y, w, h);
- };
- this.fillEllipse = this.fillOval = function(left, top, w, h)
- {
- var a = w>>1, b = h>>1,
- wod = w&1, hod = h&1,
- cx = left+a, cy = top+b,
- x = 0, y = b, oy = b,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- xl, dw, dh;
- if(w) while(y > 0)
- {
- if(st < 0)
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0)
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- xl = cx-x;
- dw = (x<<1)+wod;
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- dh = oy-y;
- this._mkDiv(xl, cy-oy, dw, dh);
- this._mkDiv(xl, cy+y+hod, dw, dh);
- oy = y;
- }
- else
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- }
- }
- this._mkDiv(cx-a, cy-oy, w, (oy<<1)+hod);
- };
- this.fillArc = function(iL, iT, iW, iH, fAngA, fAngZ)
- {
- var a = iW>>1, b = iH>>1,
- iOdds = (iW&1) | ((iH&1) << 16),
- cx = iL+a, cy = iT+b,
- x = 0, y = b, ox = x, oy = y,
- aa2 = (a*a)<<1, aa4 = aa2<<1, bb2 = (b*b)<<1, bb4 = bb2<<1,
- st = (aa2>>1)*(1-(b<<1)) + bb2,
- tt = (bb2>>1) - aa2*((b<<1)-1),
- // Vars for radial boundary lines
- xEndA, yEndA, xEndZ, yEndZ,
- iSects = (1 << (Math.floor((fAngA %= 360.0)/180.0) << 3))
- | (2 << (Math.floor((fAngZ %= 360.0)/180.0) << 3))
- | ((fAngA >= fAngZ) << 16),
- aBndA = new Array(b+1), aBndZ = new Array(b+1);
-
- // Set up radial boundary lines
- fAngA *= Math.PI/180.0;
- fAngZ *= Math.PI/180.0;
- xEndA = cx+Math.round(a*Math.cos(fAngA));
- yEndA = cy+Math.round(-b*Math.sin(fAngA));
- _mkLinVirt(aBndA, cx, cy, xEndA, yEndA);
- xEndZ = cx+Math.round(a*Math.cos(fAngZ));
- yEndZ = cy+Math.round(-b*Math.sin(fAngZ));
- _mkLinVirt(aBndZ, cx, cy, xEndZ, yEndZ);
- while(y > 0)
- {
- if(st < 0) // Advance x
- {
- st += bb2*((x<<1)+3);
- tt += bb4*(++x);
- }
- else if(tt < 0) // Advance x and y
- {
- st += bb2*((x<<1)+3) - aa4*(y-1);
- ox = x;
- tt += bb4*(++x) - aa2*(((y--)<<1)-3);
- this._mkArcDiv(ox, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
- oy = y;
- }
- else // Advance y
- {
- tt -= aa2*((y<<1)-3);
- st -= aa4*(--y);
- if(y && (aBndA[y] != aBndA[y-1] || aBndZ[y] != aBndZ[y-1]))
- {
- this._mkArcDiv(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
- ox = x;
- oy = y;
- }
- }
- }
- this._mkArcDiv(x, 0, oy, cx, cy, iOdds, aBndA, aBndZ, iSects);
- if(iOdds >> 16) // Odd height
- {
- if(iSects >> 16) // Start-angle > end-angle
- {
- var xl = (yEndA <= cy || yEndZ > cy)? (cx - x) : cx;
- this._mkDiv(xl, cy, x + cx - xl + (iOdds & 0xffff), 1);
- }
- else if((iSects & 0x01) && yEndZ > cy)
- this._mkDiv(cx - x, cy, x, 1);
- }
- };
- /* fillPolygon method, implemented by Matthieu Haller.
- This javascript function is an adaptation of the gdImageFilledPolygon for Walter Zorn lib.
- C source of GD 1.8.4 found at http://www.boutell.com/gd/
- THANKS to Kirsten Schulz for the polygon fixes!
- The intersection finding technique of this code could be improved
- by remembering the previous intertersection, and by using the slope.
- That could help to adjust intersections to produce a nice
- interior_extrema. */
- this.fillPolygon = function(array_x, array_y)
- {
- var i;
- var y;
- var miny, maxy;
- var x1, y1;
- var x2, y2;
- var ind1, ind2;
- var ints;
- var n = array_x.length;
- if(!n) return;
- miny = array_y[0];
- maxy = array_y[0];
- for(i = 1; i < n; i++)
- {
- if(array_y[i] < miny)
- miny = array_y[i];
- if(array_y[i] > maxy)
- maxy = array_y[i];
- }
- for(y = miny; y <= maxy; y++)
- {
- var polyInts = new Array();
- ints = 0;
- for(i = 0; i < n; i++)
- {
- if(!i)
- {
- ind1 = n-1;
- ind2 = 0;
- }
- else
- {
- ind1 = i-1;
- ind2 = i;
- }
- y1 = array_y[ind1];
- y2 = array_y[ind2];
- if(y1 < y2)
- {
- x1 = array_x[ind1];
- x2 = array_x[ind2];
- }
- else if(y1 > y2)
- {
- y2 = array_y[ind1];
- y1 = array_y[ind2];
- x2 = array_x[ind1];
- x1 = array_x[ind2];
- }
- else continue;
- // Modified 11. 2. 2004 Walter Zorn
- if((y >= y1) && (y < y2))
- {
- polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
- }
- else if((y == maxy) && (y > y1) && (y <= y2))
- {
- polyInts[ints++] = Math.round((y-y1) * (x2-x1) / (y2-y1) + x1);
- }
- }
- polyInts.sort(_CompInt);
- for(i = 0; i < ints; i+=2)
- {
- this._mkDiv(polyInts[i], y, polyInts[i+1]-polyInts[i]+1, 1);
- }
- }
- };
- this.drawString = function(txt, x, y)
- {
- this.htm += '<div style="position:absolute;white-space:nowrap;'+
- 'left:' + x + 'px;'+
- 'top:' + y + 'px;'+
- 'font-family:' + this.ftFam + ';'+
- 'font-size:' + this.ftSz + ';'+
- 'color:' + this.color + ';' + this.ftSty + '">'+
- txt +
- '<\/div>';
- };
- /* drawStringRect() added by Rick Blommers.
- Allows to specify the size of the text rectangle and to align the
- text both horizontally (e.g. right) and vertically within that rectangle */
- this.drawStringRect = function(txt, x, y, width, halign)
- {
- this.htm += '<div style="position:absolute;overflow:hidden;'+
- 'left:' + x + 'px;'+
- 'top:' + y + 'px;'+
- 'width:'+width +'px;'+
- 'text-align:'+halign+';'+
- 'font-family:' + this.ftFam + ';'+
- 'font-size:' + this.ftSz + ';'+
- 'color:' + this.color + ';' + this.ftSty + '">'+
- txt +
- '<\/div>';
- };
- this.drawImage = function(imgSrc, x, y, w, h, a)
- {
- this.htm += '<div style="position:absolute;'+
- 'left:' + x + 'px;'+
- 'top:' + y + 'px;'+
- // w (width) and h (height) arguments are now optional.
- // Added by Mahmut Keygubatli, 14.1.2008
- (w? ('width:' + w + 'px;') : '') +
- (h? ('height:' + h + 'px;'):'')+'">'+
- '<img src="' + imgSrc +'"'+ (w ? (' width="' + w + '"'):'')+ (h ? (' height="' + h + '"'):'') + (a? (' '+a) : '') + '>'+
- '<\/div>';
- };
- this.clear = function()
- {
- this.htm = "";
- if(this.cnv) this.cnv.innerHTML = "";
- };
- this._mkOvQds = function(cx, cy, x, y, w, h, wod, hod)
- {
- var xl = cx - x, xr = cx + x + wod - w, yt = cy - y, yb = cy + y + hod - h;
- if(xr > xl+w)
- {
- this._mkDiv(xr, yt, w, h);
- this._mkDiv(xr, yb, w, h);
- }
- else
- {
- w = xr - xl + w;
- }
- this._mkDiv(xl, yt, w, h);
- this._mkDiv(xl, yb, w, h);
- };
-
- this._mkRoundrectQds = function(cx, cy, x, y, w, h, wod, hod, position)
- {
- var xl = cx - x, xr = cx + x + wod - w, yt = cy - y, yb = cy + y + hod - h;
- if (position == 0) this._mkDiv(xl, yt, w, h);
- if (position == 1) this._mkDiv(xr, yt, w, h);
- if (position == 2) this._mkDiv(xr, yb, w, h);
- if (position == 3) this._mkDiv(xl, yb, w, h);
- };
- this._mkArcDiv = function(x, y, oy, cx, cy, iOdds, aBndA, aBndZ, iSects)
- {
- var xrDef = cx + x + (iOdds & 0xffff), y2, h = oy - y, xl, xr, w;
- if(!h) h = 1;
- x = cx - x;
- if(iSects & 0xff0000) // Start-angle > end-angle
- {
- y2 = cy - y - h;
- if(iSects & 0x00ff)
- {
- if(iSects & 0x02)
- {
- xl = Math.max(x, aBndZ[y]);
- w = xrDef - xl;
- if(w > 0) this._mkDiv(xl, y2, w, h);
- }
- if(iSects & 0x01)
- {
- xr = Math.min(xrDef, aBndA[y]);
- w = xr - x;
- if(w > 0) this._mkDiv(x, y2, w, h);
- }
- }
- else
- {
- this._mkDiv(x, y2, xrDef - x, h);
- }
- y2 = cy + y + (iOdds >> 16);
- if(iSects & 0xff00)
- {
- if(iSects & 0x0100)
- {
- xl = Math.max(x, aBndA[y]);
- w = xrDef - xl;
- if(w > 0) this._mkDiv(xl, y2, w, h);
- }
- if(iSects & 0x0200)
- {
- xr = Math.min(xrDef, aBndZ[y]);
- w = xr - x;
- if(w > 0) this._mkDiv(x, y2, w, h);
- }
- }
- else
- {
- this._mkDiv(x, y2, xrDef - x, h);
- }
- }
- else
- {
- if(iSects & 0x00ff)
- {
- if(iSects & 0x02)
- {
- xl = Math.max(x, aBndZ[y]);
- }
- else
- {
- xl = x;
- }
- if(iSects & 0x01)
- {
- xr = Math.min(xrDef, aBndA[y]);
- }
- else
- {
- xr = xrDef;
- }
- y2 = cy - y - h;
- w = xr - xl;
- if(w > 0)
- {
- this._mkDiv(xl, y2, w, h);
- }
- }
- if(iSects & 0xff00)
- {
- if(iSects & 0x0100)
- {
- xl = Math.max(x, aBndA[y]);
- }
- else
- {
- xl = x;
- }
- if(iSects & 0x0200)
- {
- xr = Math.min(xrDef, aBndZ[y]);
- }
- else
- {
- xr = xrDef;
- }
- y2 = cy + y + (iOdds >> 16);
- w = xr - xl;
- if(w > 0)
- {
- this._mkDiv(xl, y2, w, h);
- }
- }
- }
- };
- this.fillRoundrect = function(left, top, width, height, ellipsewidth, ellipseheight)
- {
- if (ellipsewidth >= width)
- {
- ellipsewidth = width;
- }
- else
- {
- this._mkDiv(0+(ellipsewidth/2), 0, width-ellipsewidth, height);
- }
-
- if (ellipseheight >= height)
- {
- ellipseheight = height;
- }
- else
- {
- this._mkDiv(0, 0+(ellipseheight/2), Math.round(ellipsewidth/2), height-ellipseheight);
- this._mkDiv(width-(ellipsewidth/2), 0+(ellipseheight/2), Math.round(ellipsewidth/2), height-ellipseheight);
- }
- this.fillEllipse(0,0,ellipsewidth,ellipseheight);
- this.fillEllipse(width-ellipsewidth,0,ellipsewidth,ellipseheight);
- this.fillEllipse(width-ellipsewidth,height-ellipseheight,ellipsewidth,ellipseheight);
- this.fillEllipse(0,height-ellipseheight,ellipsewidth,ellipseheight);
- };
- this.setStroke(1);
- this.setFont("verdana,geneva,helvetica,sans-serif", "12px", Font.PLAIN);
- this.color = "#000000";
- this.htm = "";
- this.wnd = wnd || window;
- if(!jg_ok) _chkDHTM(this.wnd);
- if(jg_ok)
- {
- if(cnv)
- {
- if(typeof(cnv) == "string")
- {
- this.cont = document.all? (this.wnd.document.all[cnv] || null)
- : document.getElementById? (this.wnd.document.getElementById(cnv) || null) : null;
- }
- else if(cnv == window.document)
- {
- this.cont = document.getElementsByTagName("body")[0];
- }
- // If cnv is a direct reference to a canvas DOM node
- // (option suggested by Andreas Luleich)
- else
- {
- this.cont = cnv;
- }
- // Create new canvas inside container DIV. Thus the drawing and clearing
- // methods won't interfere with the container's inner html.
- // Solution suggested by Vladimir.
- this.cnv = this.wnd.document.createElement("div");
- this.cnv.style.fontSize=0;
- this.cont.appendChild(this.cnv);
- this.paint = jg_dom? _pntCnvDom : _pntCnvIe;
- }
- else
- {
- this.paint = _pntDoc;
- }
- }
- else
- {
- this.paint = _pntN;
- }
- this.setPrintable(false);
- };
- function _mkLinVirt(aLin, x1, y1, x2, y2)
- {
- var dx = Math.abs(x2-x1), dy = Math.abs(y2-y1),
- x = x1, y = y1,
- xIncr = (x1 > x2)? -1 : 1,
- yIncr = (y1 > y2)? -1 : 1,
- p,
- i = 0;
- if(dx >= dy)
- {
- var pr = dy<<1,
- pru = pr - (dx<<1);
- p = pr-dx;
- while(dx > 0)
- {--dx;
- if(p > 0) // Increment y
- {
- aLin[i++] = x;
- y += yIncr;
- p += pru;
- }
- else
- {
- p += pr;
- }
- x += xIncr;
- }
- }
- else
- {
- var pr = dx<<1,
- pru = pr - (dy<<1);
- p = pr-dy;
- while(dy > 0)
- {--dy;
- y += yIncr;
- aLin[i++] = x;
- if(p > 0) // Increment x
- {
- x += xIncr;
- p += pru;
- }
- else
- {
- p += pr;
- }
- }
- }
- for(var len = aLin.length, i = len-i; i;)
- {
- aLin[len-(i--)] = x;
- }
- };
- function _CompInt(x, y)
- {
- return(x - y);
- };
|