home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 October
/
Chip_2002-10_cd1.bin
/
zkuste
/
dwarf
/
download
/
_SETUP.1
/
vmsvg23.js
< prev
next >
Wrap
Text File
|
2001-09-20
|
47KB
|
1,842 lines
//*********************************************************************************//
// (C) Copyright Virtual Mechanics 1999-2001 Version 2.4, All rights reserved. //
// All copies of any portions of this software must include this Copyright notice. //
//*********************************************************************************//
objStep = new Array();
objTime = new Array();
noStep = new Array();
TotTime = new Array();
maxTime = new Array();
noStep = new Array();
Mctl = new Array();
var Version = 0;
var newPage = 0;
var pgScObj =-1;
var Svgdoc;
nm = new Array();
Active = new Array();
ob = new Array();
cpox = new Array();
cpoy = new Array();
spox = new Array();
spoy = new Array();
epox = new Array();
epoy = new Array();
crot = new Array();
cscx = new Array();
cscy = new Array();
cjtx = new Array();
cjty = new Array();
cshd = new Array();
rate = new Array();
rotate= new Array();
scale= new Array();
shade= new Array();
var Lpox;
var Lpoy;
dpox = new Array();
dpoy = new Array();
atDis = new Array();
DisPt = new Array();
disStep = new Array();
Plen = new Array();
Path = new Array();
obRef= new Array();
Gtyp = new Array();
Gnpt = new Array();
Gnam = new Array();
Glen = new Array();
Gszx = new Array();
Gszy = new Array();
Gpxl = new Array();
Gpyl = new Array();
Gbrl = new Array();
Gbrt = new Array();
Gbrr = new Array();
Gbrb = new Array();
Grps = new Array();
Grpl = new Array();
Gspt = new Array();
Snam = new Array();
Scnt = new Array();
PathCount = new Array();
LastPt = new Array();
lstVal = new Array();
TimeLeft = new Array();
AEvent = new Array();
WDEvent = new Array();
WAEvent = new Array();
AValue = new Array();
ATime = new Array();
AEnter = new Array();
ALeave = new Array();
AKey = new Array();
IKey = new Array();
DEvent = new Array();
DValue = new Array();
DTime = new Array();
DEnter = new Array();
DLeave = new Array();
DAKey = new Array();
DIKey = new Array();
WASOp = new Array();
WAGOp = new Array();
OpForm = new Array();
WAAObj = new Array();
WADObj = new Array();
WAForm = new Array();
WASVal = new Array();
WAGVal = new Array();
WACgeo = new Array();
WACsnd = new Array();
WACact = new Array();
WACevt = new Array();
WACatt = new Array();
WACobj = new Array();
WANobj = new Array();
WALink = new Array();
WDAObj = new Array();
WDDObj = new Array();
EndPath = new Array();
MType = new Array();
ATyp = new Array();
ACol = new Array();
ATrn = new Array();
AVc1x = new Array();
AVc1y = new Array();
ACol2 = new Array();
ATrn2 = new Array();
AVc2x = new Array();
AVc2y = new Array();
Aid1 = new Array();
Aid2 = new Array();
Agrd = new Array();
Astp1 = new Array();
Astp2 = new Array();
Astp3 = new Array();
MPath = new Array();
MRate = new Array();
MTime = new Array();
MDelay = new Array();
MStart = new Array();
MRepeat= new Array();
MCount = new Array();
MPLen = new Array();
MDir = new Array();
MGWst = new Array();
MGNth = new Array();
MGEst = new Array();
MGSth = new Array();
MALst = new Array();
MRotate= new Array();
MScale = new Array();
MFlags = new Array();
MShade = new Array();
eDELAY = (1);
eDELAY_TIME = (2);
eMOUSE = (4);
eMOUSE_OVER = (8);
eLMOUSE = (16);
eRMOUSE = (32);
eKEY = (64);
eOBJECT_ENTER = (128);
eOBJECT_ENTER_LIST = (256);
eOBJECT_LEAVE = (512);
eOBJECT_LEAVE_LIST = (1024);
eLT_VALUE = (2048);
eEQ_VALUE = (4096);
eGT_VALUE = (8192);
eVALUE = (16384);
eENDPATH = (32768);
eACTIVATE_1 = (65536);
eACTIVATE_2 = (131072);
eANDtest = (1<<30);
var pageTime = -1;
var Cobj;
var Coid;
var Csty;
var Catt;
var Cact;
var Cevt;
var Cgrp;
var Cgeo;
var Csnd;
var Cpob;
var Gpgo;
var gcx;
var gcy;
var gcx;
var gcy;
var cmx = 300;
var cmy = 200;
var smx = -9999;
var smy = -9999;
var slm = 0;
var llm = -9999;
var sky = " ";
var lstsnd = -1;
var red;
var grn;
var blu;
var alp;
var fact;
var ifact;
var lmx = -9999;
var lmy = -9999;
var lky = 0;
var totObj;
var mS;
var mW;
var fps = 15;
var waitTime = 40;
var tickTime = 1;
var strDate;
var curDate;
var GEO_TYPE = 7;
var GEO_OPEN = 8;
var GEO_COUNT= 32;
ACT_XPATH_STOP =(0);
ACT_XPATH_OBJPTH =(1<<0);
ACT_XPATH_OBJXYZ =(1<<1);
ACT_XPATH_LEFT =(1<<2);
ACT_XPATH_RIGHT =(1<<3);
ACT_XPATH_MOUSE =(1<<4);
ACT_XPATH_KEYPTH =(1<<5);
ACT_YPATH_STOP =(0);
ACT_YPATH_OBJPTH =(1<<8);
ACT_YPATH_OBJXYZ =(1<<9);
ACT_YPATH_UP =(1<<10);
ACT_YPATH_DOWN =(1<<11);
ACT_YPATH_MOUSE =(1<<12);
ACT_ZPATH_STOP =(0);
ACT_ZPATH_OBJPTH =(1<<16);
ACT_ZPATH_OBJXYZ =(1<<17);
ACT_ZPATH_IN =(1<<18);
ACT_ZPATH_OUT =(1<<19);
ACT_ZPATH_KEY =(1<<20);
ACT_PATH_STOP =(0);
ACT_PATH_START =(1<<24);
ACT_PATH_CENTER =(1<<25);
ACT_PATH_END =(1<<26);
ACT_GEO_WEST =(1<<28);
ACT_GEO_EAST =(1<<29);
ACT_GEO_NORTH =(1<<30);
ACT_GEO_SOUTH =(1<<31);
ACT_SETX =(0xffffff00);
ACT_SETY =(0xffff00ff);
ACT_SETZ =(0xff00ffff);
ACT_SETO =(0xf0ffffff);
ACT_SETF =(0x0fffffff);
ACT_GETX =(0x000000ff);
ACT_GETY =(0x0000ff00);
ACT_GETZ =(0x00ff0000);
ACT_GETO =(0x0f000000);
ACT_GETF =(0xf0000000);
/**************************************************************************/
function min(x,y) {if(x < y) return x; return y;}
function max(x,y) {if(y > x) return y; return x;}
function mouseMove(evt) {
cmx = evt.getClientX();
cmy = evt.getClientY();
sclx = 0;
scly = 0;
}
function mouseDown(evt) {
slm = slm | 1;
smx=evt.getClientX();
smy=evt.getClientY();
return true;
}
function enddrag(evt) {
slm = slm | 2;
smx = evt.getClientX();
smy = evt.getClientY();
evt.onmousemove=0;
return false;
}
function drag(evt) {
cmx = evt.getClientX();
cmy = evt.getClientY();
}
function mouseUp(evt) {
slm = slm | 2 + window.pageXOffset;
smx = evt.pageX + window.pageXOffset;
smy = evt.pageY + window.pageYOffset;
}
function keyPress(evt) {
sky = evt.getCharCode();
}
function Setup(svgdoc) {
// setup defaults
Svgdoc = svgdoc;
tmCount=0;
strDate = new Date();
waitTime = 1000 / fps;
frmTime = 0;
tickTime = 0;
ob[0] = new Array();
ob[0] = 0;
ob[0].obj = 0;
ob[0].sty = 0;
ob[0].name = "Geo0";
ob[0].geo = 0;
ob[0].att = 0;
ob[0].evt = 0;
ob[0].act = 0;
ob[0].grp = 0;
ob[0].cpox =0.000000;
ob[0].cpoy =0.000000;
ob[0].cscx =1.000000;
ob[0].cscy =1.000000;
ob[0].crot =0.000000;
ob[0].flg = 0;
MPath[0] = 0;
MStart[0] = 0;
MCount[0] = 0;
red = 255;
grn = 255;
blu = 255;
alp = 1.;
fact = 1.0;
ifact= 0.0;
for(nob=0; nob< pageObj; nob++) {
Cobj = pObjLst[nob];
spox[Cobj] = ob[Cobj].cpox;
spoy[Cobj] = ob[Cobj].cpoy;
SetPath(Cobj);
if(ob[Cobj].grp == 0)
reset(Cobj);
if(ob[Cobj].flg & 16)
Active[Cobj] = 4; // set to initial active state
}
}
function doObjectList() {
curDate = new Date();
tickTime = (curDate - strDate) * 0.1;
frmTime++;
// if(newPage != 0) window.location=WALink[newPage];
newPage = 0;
if(pageTime >= 0)
{
tmCount++;
if(tmCount > pageTime)
{
window.location=pgLink;
pageTime = -1;
}
}
if(lmx == smx) smx = -99999;
if(lmy == smy) smy = -99999;
if(lky == sky) sky = " ";
llt = 0;
if((llm & 2) == (slm & 2)) slm = (slm & ~2);
if((llm & 1) == (slm & 1)) slm = (slm & ~1);
lmx = smx;
lmy = smy;
lky = sky;
llm = slm;
MoOvrTst();
for(nob=0; nob< pageObj; nob++) {
// ref = pObjLst[nob];
gcx = 0;
gcy = 0;
cobj = pObjLst[nob];
Cgrp = ob[cobj].grp;
if(!Cgrp) doObject(cobj);
}
}
function doObject(cobj)
{
Cobj = cobj;
Coid = ob[Cobj].obj;
Csty = ob[Cobj].sty
Cgeo = ob[Cobj].geo;
Csnd = ob[Cobj].snd;
Cevt = ob[Cobj].evt;
Catt = ob[Cobj].att;
Cact = ob[Cobj].act;
Gpgo = ob[Cobj].gem;
if(Cact)
{
Cpob = MPath[Cact];
if(Cpob)
Cpgo = ob[Cpob].geo;
else
Cpgo = 0;
}
else
{
Cpob = 0;
Cpgo = 0;
}
if(Cevt) Evtest();
if (Active[Cobj] == 4) whenActive();
else if(Active[Cobj] == 2) whenDeactive();
else if(Active[Cobj] == 1) isActive();
else if(Active[Cobj] == 0) isDeactive();
// if(Cgeo && (Gtyp[Cgeo] & (1<<4)))
// {
// doGroup(Cgeo);
// return;
// }
}
function doGroup(cgrp)
{
var gobj;
gcx = cpox[Cobj];
gcy = cpoy[Cobj];
gobj = Cobj;
for(i = 0; i < Grps[cgrp]; i++)
{
doObject(Grpl[cgrp][i]);
ob[Cobj].sty.left=gcx+cpox[Cobj] - Gszx[Cgeo] * ob[Cobj].cscx;
ob[Cobj].sty.top =gcy+cpoy[Cobj] - Gszy[Cgeo] * ob[Cobj].cscy;
}
return;
}
function setVisibility(code)
{
// if(Cgeo && (Gtyp[Cgeo] & (1<<4))) {
// for(i = 0; i < Grps[Cgeo]; i++) {
// ob[Grpl[Cgeo][i]].obj.setProperty('visibility',code);
// }
// }
// else
// ob[Cobj].sty.setProperty('visibility', 'hidden');
//window.status = " Cobj=" + Cobj + " Coid=" + Coid + " Csty=" + Csty;
// ob[Cobj].obj.setProperty('visibility', 'visible');
Csty.setProperty('visibility', code);
}
function UpdGeo() {
var drx = Lpox - cpox[Cobj];
var dry = Lpoy - cpoy[Cobj];
if(Math.abs(dry) > Math.abs(drx))
{
if ((dry < 0) && (MDir[Cobj] != 270))
{
if(MType[Cact] & (ACT_GEO_SOUTH))
{
ob[Cobj].image.src = Gspt[MGSth[Cact]].src;
}
MDir[Cobj] = 270;
}
else if((dry >= 0) && MDir[Cobj] != 90)
{
if(MType[Cact] & (ACT_GEO_NORTH))
{
ob[Cobj].image.src = Gspt[MGNth[Cact]].src;
}
MDir[Cobj] = 90;
}
}
else
{
if ((drx > 0) && (MDir[Cobj] != 0))
{
if(MType[Cact] & (ACT_GEO_WEST))
{
ob[Cobj].image.src = Gspt[MGWst[Cact]].src;
}
MDir[Cobj] = 0;
}
else if((drx <= 0) && MDir[Cobj] != 180)
{
if(MType[Cact] & (ACT_GEO_EAST))
{
ob[Cobj].image.src = Gspt[MGEst[Cact]].src;
}
MDir[Cobj] = 180;
}
}
return;
}
function UpdStr() {
if(lstVal[Cobj] == ob[Cobj].val) return;
lstVal[Cobj] = ob[Cobj].val;
if(isIE4 || isIE5)
ob[Cobj].name.innerText = ob[Cobj].val;
else
window.status = "Object " + ob[Cobj].name + " Counter=" + ob[Cobj].val;
return;
}
function UpdAudio(on)
{
if(on > 0)
{
if(Scnt[Csnd] < 0) Scnt[Csnd] = 9999;
SoundEffect.loop= Scnt[Csnd];
SoundEffect.src = Snam[Csnd];
// SoundEffect.autostart=1;
lstsnd = Csnd;
}
else
{
if(lstsnd != Csnd) return;
SoundEffect.src= " ";
SoundEffect.loop= 0;
SoundEffect.autostart=0;
}
}
function Evtest()
{
if(Active[Cobj] == 0)
{
if(AEvent[Cevt] & eANDtest)
ActANDTest();
else
ActORTest();
}
else if(Active[Cobj] == 1) {
if(DEvent[Cevt] & eANDtest)
DeactANDTest();
else
DeactORTest();
}
return;
}
//*********************************************************************************//
function ActORTest()
{
if(((AEvent[Cevt] & eDELAY) && TimeCount() <= 0 ) ||
( (AEvent[Cevt] & eOBJECT_ENTER) && ObjectEnter(AEnter[Cevt]) ) ||
( (AEvent[Cevt] & eOBJECT_LEAVE) && ObjectLeave(ALeave[Cevt]) ) ||
( (AEvent[Cevt] & eMOUSE) && MouseSelect() > 0 ) ||
( (AEvent[Cevt] & eMOUSE_OVER) && MouseOver() ) ||
( (AEvent[Cevt] & eLMOUSE) && IsMouseLClick() ) ||
( (AEvent[Cevt] & eRMOUSE) && IsMouseRClick() ) ||
( (AEvent[Cevt] & eKEY) && KeyChar() ) ||
( (AEvent[Cevt] & eLT_VALUE) && ob[Cobj].val < AValue[Cevt]) ||
( (AEvent[Cevt] & eEQ_VALUE) && ob[Cobj].val == AValue[Cevt]) ||
( (AEvent[Cevt] & eGT_VALUE) && ob[Cobj].val > AValue[Cevt]) ||
( (AEvent[Cevt] & eENDPATH) && EndPath[Cobj] ) )
Active[Cobj] = 4;
}
function ActANDTest()
{
if(((AEvent[Cevt] & eDELAY) && !(TimeCount() <= 0) ) ||
( (AEvent[Cevt] & eOBJECT_ENTER) && !ObjectEnter(AEnter[Cevt]) ) ||
( (AEvent[Cevt] & eOBJECT_LEAVE) && !ObjectLeave(ALeave[Cevt]) ) ||
( (AEvent[Cevt] & eMOUSE) && !(MouseSelect() > 0) ) ||
( (AEvent[Cevt] & eMOUSE_OVER) && !MouseOver() ) ||
( (AEvent[Cevt] & eLMOUSE) && !IsMouseLClick() ) ||
( (AEvent[Cevt] & eRMOUSE) && !IsMouseRClick() ) ||
( (AEvent[Cevt] & eKEY) && !KeyChar() ) ||
( (AEvent[Cevt] & eLT_VALUE) && !(ob[Cobj].val < AValue[Cevt])) ||
( (AEvent[Cevt] & eEQ_VALUE) && !(ob[Cobj].val == AValue[Cevt])) ||
( (AEvent[Cevt] & eGT_VALUE) && !(ob[Cobj].val > AValue[Cevt])) ||
( (AEvent[Cevt] & eENDPATH) && !EndPath[Cobj] ) )
{} else Active[Cobj] = 4;
}
function DeactORTest()
{
if(((DEvent[Cevt] & eDELAY) && TimeCount() <= 0 ) ||
( (DEvent[Cevt] & eOBJECT_ENTER) && ObjectEnter(DEnter[Cevt]) ) ||
( (DEvent[Cevt] & eOBJECT_LEAVE) && ObjectLeave(DLeave[Cevt]) ) ||
( (DEvent[Cevt] & eMOUSE) && MouseSelect() > 0 ) ||
( (DEvent[Cevt] & eMOUSE_OVER) && !MouseOver() ) ||
( (DEvent[Cevt] & eLMOUSE) && IsMouseLClick() ) ||
( (DEvent[Cevt] & eRMOUSE) && IsMouseRClick() ) ||
( (DEvent[Cevt] & eKEY) && DKeyChar() ) ||
( (DEvent[Cevt] & eLT_VALUE) && ob[Cobj].val < AValue[Cevt]) ||
( (DEvent[Cevt] & eEQ_VALUE) && ob[Cobj].val == AValue[Cevt]) ||
( (DEvent[Cevt] & eGT_VALUE) && ob[Cobj].val > AValue[Cevt]) ||
( (DEvent[Cevt] & eENDPATH) && EndPath[Cobj] ) )
Active[Cobj] = 2;
}
function DeactANDTest()
{
if(((DEvent[Cevt] & eDELAY) && !(TimeCount() <= 0) ) ||
( (DEvent[Cevt] & eOBJECT_ENTER) && !ObjectEnter(DEnter[Cevt]) ) ||
( (DEvent[Cevt] & eOBJECT_LEAVE) && !ObjectLeave(DLeave[Cevt]) ) ||
( (DEvent[Cevt] & eMOUSE) && !(MouseSelect() > 0) ) ||
( (DEvent[Cevt] & eMOUSE_OVER) && !MouseOver() ) ||
( (DEvent[Cevt] & eLMOUSE) && !IsMouseLClick() ) ||
( (DEvent[Cevt] & eRMOUSE) && !IsMouseRClick() ) ||
( (DEvent[Cevt] & eKEY) && !DKeyChar() ) ||
( (DEvent[Cevt] & eLT_VALUE) && !(ob[Cobj].val < AValue[Cevt])) ||
( (DEvent[Cevt] & eEQ_VALUE) && !(ob[Cobj].val == AValue[Cevt])) ||
( (DEvent[Cevt] & eGT_VALUE) && !(ob[Cobj].val > AValue[Cevt])) ||
( (DEvent[Cevt] & eENDPATH) && !EndPath[Cobj] ) )
{} else Active[Cobj] = 2;
}
/**************************************************************************/
function TimeCount() {
return (TimeLeft[Cobj] - tickTime);
}
function ObjectEnter(eobj) {
//if(1) return;
x = Gszx[Cgeo] * ob[Cobj].cscx;
y = Gszy[Cgeo] * ob[Cobj].cscy;
if ( cpox[eobj] >= (cpox[Cobj] - x) && cpox[eobj] <= (cpox[Cobj]) + x &&
cpoy[eobj] >= (cpoy[Cobj] - y) && cpoy[eobj] <= (cpoy[Cobj]) + y )
return 1;
return 0;
}
function ObjectLeave(eobj) {
//if(1) return;
x = Gszx[Cgeo] * ob[Cobj].cscx;
y = Gszy[Cgeo] * ob[Cobj].cscy;
if ( cpox[eobj] >= cpox[Cobj] - x && cpox[eobj] <= cpox[Cobj] + x &&
cpoy[eobj] >= cpoy[Cobj] - y && cpoy[eobj] <= cpoy[Cobj] + y )
return 0;
return 1;
}
function MouseSelect() {
var val = 0;
if(smx == -99999) return val;
x = Gszx[Cgeo] * ob[Cobj].cscx;
y = Gszy[Cgeo] * ob[Cobj].cscy;
if ( smx >= cpox[Cobj] - x && smx <= cpox[Cobj] + x &&
smy >= cpoy[Cobj] - y && smy <= cpoy[Cobj] + y )
return val = 1;
return val;
}
function MouseOver() {
x = Gszx[Cgeo] * ob[Cobj].cscx;
y = Gszy[Cgeo] * ob[Cobj].cscy;
if ( cmx >= cpox[Cobj] - x && cmx <= cpox[Cobj] + x &&
cmy >= cpoy[Cobj] - y && cmy <= cpoy[Cobj] + y ) {
return 1;}
return 0;
}
function IsMouseLClick() {
return (slm && 1);
}
function IsMouseRClick() {
return (slm && 2);
}
function KeyChar() {
if(!sky) return 0;
if(IKey[Cevt] == lky) return 1;
return 0;
}
function DKeyChar() {
if(!sky) return 0;
if(DIKey[Cevt] == sky) return 1;
return 0;
}
function MoOvrTst() {
for(i=0; i < MoLNo; i++) {
Cobj = Molst[i];
Cgeo = ob[Cobj].geo;
Csty = ob[Cobj].sty;
if(ob[Cobj].flg & 512) {
if(MouseOver() == 1)
{
if(ob[Cobj].flg & 128) setVisibility("visible");
else setVisibility("hidden");
}
else
{
if(ob[Cobj].flg & 256) setVisibility("visible");
else setVisibility("hidden");
}
}
}}
/***************************************************************************/
function isDeactive() {
if(PathCount[Cobj] != 0)
UpdPos();
else if(ob[Cobj].jnt)
UpdKpt()
if(Gtyp[Cgeo] & GEO_COUNT) UpdStr();
return;
}
function isActive() {
if(PathCount[Cobj] != 0)
UpdPos();
else if(ob[Cobj].jnt)
UpdKpt()
if(Gtyp[Cgeo] & GEO_COUNT) UpdStr();
return;
}
function whenActive()
{
Active[Cobj] = 1;
EndPath[Cobj] = 0;
// set default active events
if(!Cevt)
{
TimeLeft[Cobj] = 0;
PathCount[Cobj] = 0;
setVisibility("visible")
}
else
{
// if(WAEvent[Cevt] & (1<<14)) window.location=WALink[Cevt];
// if(WAEvent[Cevt] & (1<<15)) window.location=WALink[Cevt];
if(WAEvent[Cevt] & (1<<14) || WAEvent[Cevt] & (1<<15))
{
newPage = Cevt;
}
if(Csnd > 0) UpdAudio((WAEvent[Cevt] & 16));
// if(WAEvent[Cevt] & 16) UpdAudio(); //sound
if(WAEvent[Cevt] & 8) setVisibility("visible");
else setVisibility("hidden");
TimeLeft[Cobj] = tickTime + (DTime[Cevt]);
if(WAEvent[Cevt] & (1<<5)) Active[WAAObj[Cevt]] = 4;
if(WAEvent[Cevt] & (1<<7)) Active[WADObj[Cevt]] = 2;
// apply value
if(WAEvent[Cevt] & (1<<13)) {
if ((OpForm[Cevt] & 0x000f) == 0)
ob[Cobj].val = WAForm[Cevt];
else if((OpForm[Cevt] & 0x000f) == 1)
ob[Cobj].val += WAForm[Cevt];
else if((OpForm[Cevt] & 0x000f) == 2)
ob[Cobj].val -= WAForm[Cevt];
else if((OpForm[Cevt] & 0x000f) == 3)
ob[Cobj].val *= WAForm[Cevt];
else if((OpForm[Cevt] & 0x000f) == 4)
if(WAForm[Cevt] != 0) ob[Cobj].val /= WAForm[Cevt];
}
// get value
if(WAEvent[Cevt] & (1<<11)) {
if ((WAGOp[Cevt] & 0x000f) == 0)
ob[Cobj].val = ob[WAGVal[Cevt]].val;
else if((WAGOp[Cevt] & 0x000f) == 1)
ob[Cobj].val += ob[WAGVal[Cevt]].val;
else if((WAGOp[Cevt] & 0x000f) == 2)
ob[Cobj].val -= ob[WAGVal[Cevt]].val;
else if((WAGOp[Cevt] & 0x000f) == 3)
ob[Cobj].val*= ob[WAGVal[Cevt]].val;
else if((WAGOp[Cevt] & 0x000f) == 4)
if(ob[WAGVal[Cevt]].val != 0) ob[Cobj].val /= ob[WAGVal[Cevt]].val;
}
// send result
if(WAEvent[Cevt] & (1<<9)) {
if ((WASOp[Cevt] & 0x000f) == 0)
ob[WASVal[Cevt]].val = ob[Cobj].val;
else if((WASOp[Cevt] & 0x000f) == 1)
ob[WASVal[Cevt]].val += ob[Cobj].val;
else if((WASOp[Cevt] & 0x000f) == 2)
ob[WASVal[Cevt]].val -= ob[Cobj].val;
else if((WASOp[Cevt] & 0x000f) == 3)
ob[WASVal[Cevt]].val *= ob[Cobj].val;
else if((WASOp[Cevt] & 0x000f) == 4)
if(ob[Cobj].val != 0) ob[WASVal[Cobj]].val /= ob[Cobj].val;
}
if(WAEvent[Cevt] & 4) PathCount[Cobj] = MCount[Cact]; // motion
// replace current object components
if(WAEvent[Cevt] & (1<<17))
{
if(WAEvent[Cevt] & (1<<18)) {
ob[Cobj].name = Gnam[WACgeo[Cevt]];
ob[Cobj].geo = WACgeo[Cevt];
}
if(WAEvent[Cevt] & (1<<18)) ob[Cobj].geo = WACgeo[Cevt];
if(WAEvent[Cevt] & (1<<18)) ob[Cobj].image.src = Gspt[ob[Cobj].geo].src;
if(WAEvent[Cevt] & (1<<19)) ob[Cobj].att = WACatt[Cevt];
if(WAEvent[Cevt] & (1<<20)) ob[Cobj].act = WACact[Cevt];
if(WAEvent[Cevt] & (1<<22)) ob[Cobj].evt = WACevt[Cevt];
spox[Cobj] = cpox[Cobj];
spoy[Cobj] = cpoy[Cobj];
SetPath(Cobj);
}
// replace additional object components
for(ref=0; ref< WACobj[Cevt]; ref++) {
if(WAEvent[Cevt] & (1<<18)) {
ob[WANobj[Cevt][ref]].name = Gnam[WACgeo[Cevt]];
ob[WANobj[Cevt][ref]].geo = WACgeo[Cevt];
}
if(WAEvent[Cevt] & (1<<18)) ob[WANobj[Cevt][ref]].geo = WACgeo[Cevt];
if(WAEvent[Cevt] & (1<<18)) ob[WANobj[Cevt][ref]].image.src = Gspt[ob[Cobj].geo].src;
if(WAEvent[Cevt] & (1<<19)) ob[WANobj[Cevt][ref]].att = WACatt[Cevt];
if(WAEvent[Cevt] & (1<<20)) ob[WANobj[Cevt][ref]].act = WACact[Cevt];
if(WAEvent[Cevt] & (1<<22)) ob[WANobj[Cevt][ref]].evt = WACevt[Cevt];
spox[WANobj[Cevt][ref]] = cpox[Cobj];
spoy[WANobj[Cevt][ref]] = cpoy[Cobj];
SetPath(WANobj[Cevt][ref]);
}
if(WAEvent[Cevt] & (1<<30)) reset(Cobj);
}
}
function whenDeactive()
{
EndPath[Cobj] = 0;
Active[Cobj] = -1; // is disabled unless reset
if(!Cevt)
{
PathCount[Cobj] = -1;
TimeLeft[Cobj] = 0;
setVisibility("hidden");
}
else
{
if(WDEvent[Cevt] & 4) PathCount[Cobj] = MCount[Cact]; // motion
if(WDEvent[Cevt] & (1<<30)) reset(Cobj);
if(Csnd > 0) UpdAudio((WDEvent[Cevt] & 16)); //sound
if(WDEvent[Cevt] & 8) setVisibility("visible");
else setVisibility("hidden");
TimeLeft[Cobj] = tickTime + ATime[Cevt];
if(WDEvent[Cevt] & 4) PathCount[Cobj] = MCount[Cact]; // motion
else PathCount[Cobj] = 0;
if(WDEvent[Cevt] & (1<<5)) Active[WDAObj[Cevt]] = 4;
if(WDEvent[Cevt] & (1<<7)) Active[WDDObj[Cevt]] = 2;
}
}
function reset(cobj) {
Cobj = cobj;
Coid = ob[cobj].obj;
Csty = ob[cobj].sty;
Cevt = ob[cobj].evt;
Catt = ob[cobj].att;
Cact = ob[cobj].act;
Cgrp = ob[cobj].grp;
Cgeo = ob[cobj].geo;
Active[cobj] = 0; // is deactive
if(Cevt)
{
if(WDEvent[Cevt] & 8) setVisibility("visible");
else setVisibility("hidden");
if(WDEvent[Cevt] & (1<<31)) {
PathCount[cobj] = MCount[Cact]; // restart path
cpox[cobj] = spox[cobj];
cpoy[cobj] = spoy[cobj];
cscx[cobj] = ob[cobj].cscx;
cscy[cobj] = ob[cobj].cscy;
crot[cobj] = ob[cobj].crot;
cshd[cobj] = 0.0;
LastPt[cobj] = 0;
// atDis[cobj] = 0;
DisPt[cobj] = 0;
EndPath[cobj] = 0;
}
if(!(WDEvent[Cevt] & 4)) PathCount[cobj] = 0; // no motion
TimeLeft[cobj] = tickTime + ATime[Cevt];
}
else if(Cgeo && Csty)
{
if(ob[cobj].flg & 64)
setVisibility("visible");
else
setVisibility("hidden");
// set action variables
if(Cact) PathCount[cobj] = MCount[Cact]; // motion
else PathCount[cobj] = 0;
TimeLeft[cobj] = 0;
cpox[cobj] = spox[cobj];
cpoy[cobj] = spoy[cobj];
LastPt[cobj] = 0;
// atDis[cobj] = 0;
DisPt[cobj] = 0;
EndPath[cobj] = 0;
}
if(Cgeo && Cact) {
resetMatrix();
appTrans(cobj);
appMtrx();
}
return;
}
/*************************************************************************/
function SetPath(cobj) {
Cobj = cobj;
Coid = ob[Cobj].obj; // Object dom id
Csty = ob[Cobj].sty; // Style
Cevt = ob[Cobj].evt; // Objects event
Catt = ob[Cobj].att; // Objects attribute
Cact = ob[Cobj].act; // Objects action
Cgrp = ob[Cobj].grp; // Objects group
Cgeo = ob[Cobj].geo; // Objects geometry
Csnd = ob[Cobj].snd; // Objects sound
Cpob = MPath[Cact]; // Object actions path object
Cpgo = ob[Cpob].geo; // Path objects geometry
lstVal[Cobj] = ob[Cobj].val - 100;
MDir[Cobj] = -1;
if(Version > 206)
rate[Cobj] = MRate[Cact] * 0.01;
else
rate[Cobj] = MRate[Cact];
if(Cgeo) {
Gszx[Cgeo] = Gszx[Cgeo] * 0.5;
Gszy[Cgeo] = Gszy[Cgeo] * 0.5;
}
// rotation and scaling
cscx[Cobj] = ob[Cobj].cscx;
cscy[Cobj] = ob[Cobj].cscy;
crot[Cobj] = ob[Cobj].crot;
cjtx[Cobj] = ob[Cobj].cjtx;
cjty[Cobj] = ob[Cobj].cjty;
cshd[Cobj] = 0.0;
shade[Cobj] = 1. / (MShade[Cact] * 30); //30 is a magic number
rotate[Cobj]= MRotate[Cact];
scale[Cobj] = MScale[Cact];
// rate[Cobj] = MRate[Cact];
// Coid.getStyle().setProperty("opacity:","1.0");
// for shading animation
if(ATyp[Catt] >= 10 && ATyp[Catt] <= 15) {
Agrd[Catt] = Svgdoc.getElementById(Aid1[Catt]);
var children = Agrd[Catt].getChildNodes();
Astp1[Catt] = children.item(1).getStyle();
Astp2[Catt] = children.item(3).getStyle();
if(ATyp[Catt] == 12)
Astp3[Catt] = children.item(5).getStyle();
}
if(!Cact || !Cgeo || !Csty) {
Plen[Cobj] = 0;
noStep[Cobj] = 0;
disStep[Cobj] = 0;
dpox[Cobj] = 0;
dpoy[Cobj] = 0;
PathCount[Cobj] = 0;
}
else {
PathCount[Cobj] = MCount[Cact];
if(MType[Cact] & ACT_XPATH_MOUSE || MType[Cact] & ACT_YPATH_MOUSE) { //^^ replaced with linPath??
Plen[Cobj] = 1;
noStep[Cobj] = 1;
disStep[Cobj] = 1;
dpox[Cobj] = 0;
dpoy[Cobj] = 0;
}
else if(MType[Cact] & ACT_XPATH_OBJPTH || MType[Cact] & ACT_XPATH_OBJXYZ) {
objPath(Cobj,Cpob,Cpgo);
}
else if(MType[Cact] & ACT_XPATH_KEYPTH) {
motionSetup(Cobj,Cpob,Cpgo);
}
else
{
linPath(Cobj);
}
}
cpox[Cobj] = spox[Cobj];
cpoy[Cobj] = spoy[Cobj];
LastPt[Cobj] = 0;
atDis[Cobj] = 0;
DisPt[Cobj] = 0;
EndPath[Cobj] = 0;
GetStartPos();
// atDis[Cobj] = Plen[Cobj] * MStart[Cact];
objStep[Cobj] = 0;
if(MFlags[Cact] & (1<<20))
{
noStep[Cobj] = MPLen[Cact] * 30;
}
noStep[Cobj] *= (MPLen[Cact] / 100.);
resetMatrix();
appTrans(Cobj);
return;
}
function getPathLenth(Cobj,Cpob,Cgeo)
{
var i, x = 0.0, y = 0.0;
Plen[Cobj] = 0;
// find length of rectangle
if ((Gtyp[Cgeo] & GEO_TYPE) == 1) {
Plen[Cobj] = 2 * (Gpxl[Cgeo][1] - Gpxl[Cgeo][0]) * ob[Cpob].cscx
+ 2 * (Gpyl[Cgeo][1] - Gpyl[Cgeo][0]) * ob[Cpob].cscy;
}
// find length of ellipse
else if ((Gtyp[Cgeo] & GEO_TYPE) == 2) {
Plen[Cobj] = 360;
}
// find length of polygon
else if ((Gtyp[Cgeo] & GEO_TYPE) == 3) {
for ( i = 1; i < Gnpt[Cgeo]; i++)
{
x = (Gpxl[Cgeo][i] - Gpxl[Cgeo][i-1]) * ob[Cpob].cscx;
y = (Gpyl[Cgeo][i] - Gpyl[Cgeo][i-1]) * ob[Cpob].cscy;
Plen[Cobj] += Math.sqrt(x*x + y*y);
}
if(!(Gtyp[Cgeo] & GEO_OPEN))
{
x = (Gpxl[Cgeo][Gnpt[Cgeo]-1] - Gpxl[Cgeo][0]) * ob[Cpob].cscx;
y = (Gpyl[Cgeo][Gnpt[Cgeo]-1] - Gpyl[Cgeo][0]) * ob[Cpob].cscy;
Plen[Cobj] += Math.sqrt(x*x + y*y);
}
}
// Plen[Cobj] *= (MPLen[Cact] / 100.);
}
function linPath(Cobj) {
epox[Cobj] = spox[Cobj];
epoy[Cobj] = spoy[Cobj];
var lh = mH * (MPLen[Cact] / 100.);
var lw = mW * (MPLen[Cact] / 100.);
if(MType[Cact] & ACT_YPATH_UP) {
if(MType[Cact] & ACT_PATH_CENTER) {
spoy[Cobj] += lh;
epoy[Cobj] -= lh;
}
else if(MType[Cact] & ACT_PATH_END) {
spoy[Cobj] += lh;
}
else if(MType[Cact] & ACT_PATH_START) {
epoy[Cobj] -= lh;
}
}
else if(MType[Cact] & ACT_YPATH_DOWN) {
if(MType[Cact] & ACT_PATH_START) {
epoy[Cobj] += lh;
}
else if(MType[Cact] & ACT_PATH_END) {
spoy[Cobj] -= lh;
}
else if(MType[Cact] & ACT_PATH_CENTER) {
spoy[Cobj] -= lh;
epoy[Cobj] += lh;
}
}
else if(MType[Cact] & ACT_YPATH_MOUSE) {
Plen[Cobj] = 1;
noStep[Cobj] = 1;
disStep[Cobj] = 1;
dpoy[Cobj] = 0;
spoy[Cobj] = cpoy[Cobj];
}
if(MType[Cact] & ACT_XPATH_LEFT) {
if(MType[Cact] & ACT_PATH_CENTER) {
spox[Cobj] += lw;
epox[Cobj] -= lw;
}
else if(MType[Cact] & ACT_PATH_END) {
spox[Cobj] += lw;
}
else if(MType[Cact] & ACT_PATH_START) {
epox[Cobj] -= lw;
}
}
else if(MType[Cact] & ACT_XPATH_RIGHT) {
if(MType[Cact] & ACT_PATH_START) {
epox[Cobj] += lw;
}
else if(MType[Cact] & ACT_PATH_END) {
spox[Cobj] -= lw;
}
else if(MType[Cact] & ACT_PATH_CENTER) {
spox[Cobj] -= lw;
epox[Cobj] += lw;
}
}
else if(MType[Cact] & ACT_YPATH_MOUSE) {
Plen[Cobj] = 1;
noStep[Cobj] = 1;
disStep[Cobj] = 1;
dpox[Cobj] = 0;
spox[Cobj] = cpox[Cobj];
}
var x = epox[Cobj] - spox[Cobj];
var y = epoy[Cobj] - spoy[Cobj];
if(x+y)
{
Plen[Cobj] = Math.sqrt(x*x + y*y);
noStep[Cobj] = Math.abs(Plen[Cobj] / rate[Cobj]);
if(noStep[Cobj] < 1) noStep[Cobj] = 1;
disStep[Cobj] = Plen[Cobj] / noStep[Cobj];
dpox[Cobj] = x / noStep[Cobj];
dpoy[Cobj] = y / noStep[Cobj];
}
else
{
Plen[Cobj] = 0;
dpox[Cobj] = 0;
dpoy[Cobj] = 0;
disStep[Cobj] = 0;
noStep[Cobj] = 1;
disStep[Cobj] = 1;
objStep[Cobj] = 1;
}
return
}
function objPath(Cobj,Cpob,Cpgo)
{
if ((Gtyp[Cpgo] & GEO_TYPE) == 1) {
spox[Cobj] = Gpxl[Cpgo][0] * ob[Cpob].cscx + ob[Cpob].cpox;
spoy[Cobj] = Gpyl[Cpgo][0] * ob[Cpob].cscy + ob[Cpob].cpoy;
epox[Cobj] = spox[Cobj];
epoy[Cobj] = spoy[Cobj];
}
else if ((Gtyp[Cpgo] & GEO_TYPE) == 2) {
spox[Cobj] = Gpxl[Cpgo][0] * ob[Cpob].cscx + ob[Cpob].cpox;
// spoy[Cobj] = Gpyl[Cpgo][0] * ob[Cpob].cscy + ob[Cpob].cpoy + Gszy[Cpob] * ob[Cpob].cscy;
spoy[Cobj] = (Gpyl[Cpgo][0] + Gszy[Cpgo]) * ob[Cpob].cscy + ob[Cpob].cpoy;
epox[Cobj] = spox[Cobj];
epoy[Cobj] = spoy[Cobj];
}
else if ((Gtyp[Cpgo] & GEO_TYPE) == 3) {
spox[Cobj] = Gpxl[Cpgo][0] * ob[Cpob].cscx + ob[Cpob].cpox;
spoy[Cobj] = Gpyl[Cpgo][0] * ob[Cpob].cscy + ob[Cpob].cpoy;
if(Gtyp[Cpgo] & GEO_OPEN)
{
epox[Cobj] = Gpxl[Cpgo][Gnpt[Cpgo]-1] * ob[Cpob].cscx + ob[Cpob].cpox;
epoy[Cobj] = Gpyl[Cpgo][Gnpt[Cpgo]-1] * ob[Cpob].cscy + ob[Cpob].cpoy;
}
else
{
epox[Cobj] = spox[Cobj];
epoy[Cobj] = spoy[Cobj];
}
}
getPathLenth(Cobj,Cpob,Cpgo);
if(Cact)
noStep[Cobj] = Math.abs(Plen[Cobj] / rate[Cobj]);
else
noStep[Cobj] = 0;
if(noStep[Cobj] < 1) noStep[Cobj] = 1;
disStep[Cobj] = Plen[Cobj] / noStep[Cobj];
objStep[Cobj] = 0;
objTime[Cobj] = -MDelay[Cact];
return;
}
function GetStartPos()
{
if(Plen[Cobj] == 0 || (MType[Cact] & ACT_XPATH_OBJXYZ)) return;
while(atDis[Cobj] < (Plen[Cobj] * MStart[Cact]))
{
if(MType[Cact] & ACT_XPATH_OBJPTH)
{
if ((Gtyp[Cpgo] & GEO_TYPE) == 1)
GetRectLoc();
else if((Gtyp[Cpgo] & GEO_TYPE) == 2)
{
GetArcLoc();
}
else if((Gtyp[Cpgo] & GEO_TYPE) == 3)
{
GetPathLoc();
}
cpox[Cobj] += cpox[Cpob];
cpoy[Cobj] += cpoy[Cpob];
}
else
{
if(MType[Cact] & ACT_XPATH_MOUSE)
cpox[Cobj] = cmx;
else
cpox[Cobj] += dpox[Cobj];
if(MType[Cact] & ACT_YPATH_MOUSE)
cpoy[Cobj] = cmy;
else
cpoy[Cobj] += dpoy[Cobj];
}
atDis[Cobj] += disStep[Cobj];
}
}
function motionSetup(Cobj,Cpob,Cpgo)
{
if(!Cobj || !Cpgo || !Cact) return;
objStep[Cobj] = 0;
objTime[Cobj] = -MDelay[Cact];
maxTime[Cobj] = Mctl[Cpgo][Gnpt[Cpgo]-1].tim;
if(MRepeat[Cact] >= 0)
TotTime[Cobj] = MRepeat[Cact] * maxTime[Cobj];
else
TotTime[Cobj] = -1;
}
/////////////////////////////////////////////////
function UpdPos() {
if(Cgeo == 0) return;
if(MType[Cact] & ACT_XPATH_KEYPTH)
motionUpdate();
else
animateUpdate();
}
function motionUpdate()
{
var res;
objTime[Cobj] = tickTime - MDelay[Cact];
if(objTime[Cobj] > maxTime[Cobj]) objStep[Cobj] = 0;
if((TotTime[Cobj] < 0 || tickTime < TotTime[Cobj]) && objTime[Cobj] > 0 && maxTime[Cobj] > 0)
objTime[Cobj] = objTime[Cobj] % (maxTime[Cobj]+1);
else if(objTime[Cobj] > maxTime[Cobj])
objTime[Cobj] = maxTime[Cobj];
else if(objTime[Cobj] < 0)
objTime[Cobj] = 0;
res = pathUpdate();
if(res == 0)
{
resetMatrix();
x = cpox[Cobj] - ob[Cobj].corx;
y = cpoy[Cobj] - ob[Cobj].cory;
cpox[Cobj] = x * ob[Cpob].m0 + y * ob[Cpob].m2 + ob[Cpob].m4;
cpoy[Cobj] = x * ob[Cpob].m1 + y * ob[Cpob].m3 + ob[Cpob].m5;
appTrans(Cobj);
transKyPt();
appMtrx();
}
return res;
}
function pathUpdate()
{
var red1, gre1, blu1, alp1, red2, gre2, blu2, alp2;
if(objTime[Cobj] < Mctl[Cpgo][0].tim) return -1;
if(objTime[Cobj] > Mctl[Cpgo][Gnpt[Cpgo]-1].tim) return 1;
while(objTime[Cobj] > Mctl[Cpgo][objStep[Cobj]+1].tim)
{
if((objStep[Cobj] + 1) >= Gnpt[Cpgo]-1) {
objStep[Cobj] = Gnpt[Cpgo]-1;
return 1;
}
else
objStep[Cobj]++;
}
var cStep = objStep[Cobj];
var fact = (objTime[Cobj] - Mctl[Cpgo][cStep].tim) / (Mctl[Cpgo][cStep+1].tim-Mctl[Cpgo][cStep].tim);
if(fact < 0) fact = 0;
else if(fact > 1) fact = 1.0;
var ifact = 1.0 - fact;
if(ob[Cobj].jnt) {
cpox[Cobj] = cjtx[ob[Cobj].jnt];
cpoy[Cobj] = cjty[ob[Cobj].jnt];
}
else {
cpox[Cobj] = Gpxl[Cpgo][cStep] + ((Gpxl[Cpgo][cStep+1] - Gpxl[Cpgo][cStep]) * fact);
cpoy[Cobj] = Gpyl[Cpgo][cStep] + ((Gpyl[Cpgo][cStep+1] - Gpyl[Cpgo][cStep]) * fact);
}
cscx[Cobj] = Mctl[Cpgo][cStep].sclx + (Mctl[Cpgo][cStep+1].sclx - Mctl[Cpgo][cStep].sclx) * fact;
cscy[Cobj] = Mctl[Cpgo][cStep].scly + (Mctl[Cpgo][cStep+1].scly - Mctl[Cpgo][cStep].scly) * fact;
crot[Cobj] = Mctl[Cpgo][cStep].rot + (Mctl[Cpgo][cStep+1].rot - Mctl[Cpgo][cStep].rot) * fact;
if(Catt && (cStep == 0 || Mctl[Cpgo][cStep].rgb1 != Mctl[Cpgo][cStep+1].rgb1 || Mctl[Cpgo][cStep].rgb2 != Mctl[Cpgo][cStep+1].rgb2))
{
red = (Mctl[Cpgo][cStep].rgb1 &255) * ifact + (Mctl[Cpgo][cStep+1].rgb1 &255) * fact;
grn = (Mctl[Cpgo][cStep].rgb1>> 8&255) * ifact + (Mctl[Cpgo][cStep+1].rgb1>> 8&255) * fact;
blu = (Mctl[Cpgo][cStep].rgb1>>16&255) * ifact + (Mctl[Cpgo][cStep+1].rgb1>>16&255) * fact;
alp = (Mctl[Cpgo][cStep].rgb1>>24&255) * ifact + (Mctl[Cpgo][cStep+1].rgb1>>24&255) * fact;
if(ATyp[Catt] >= 10 && ATyp[Catt] <= 15)
{
Astp1[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp1[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
if(ATyp[Catt] >= 12)
{
Astp3[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp3[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
}
red = (Mctl[Cpgo][cStep].rgb2 &255) * ifact + (Mctl[Cpgo][cStep+1].rgb2 &255) * fact;
grn = (Mctl[Cpgo][cStep].rgb2>> 8&255) * ifact + (Mctl[Cpgo][cStep+1].rgb2>> 8&255) * fact;
blu = (Mctl[Cpgo][cStep].rgb2>>16&255) * ifact + (Mctl[Cpgo][cStep+1].rgb2>>16&255) * fact;
alp = (Mctl[Cpgo][cStep].rgb2>>24&255) * ifact + (Mctl[Cpgo][cStep+1].rgb2>>24&255) * fact;
Astp2[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp2[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
}
else {
Coid.setAttribute("style", "fill:" + "rgb("+red+","+grn+","+blu+");opacity:" + (1.-alp/255.));
}
}
red = (Mctl[Cpgo][cStep].cout &256) * ifact + (Mctl[Cpgo][cStep+1].cout &256) * fact;
grn = (Mctl[Cpgo][cStep].cout>> 8&256) * ifact + (Mctl[Cpgo][cStep+1].cout>> 8&256) * fact;
blu = (Mctl[Cpgo][cStep].cout>>16&256) * ifact + (Mctl[Cpgo][cStep+1].cout>>16&256) * fact;
alp = (Mctl[Cpgo][cStep].rgb1>>24&256) * ifact + (Mctl[Cpgo][cStep+1].rgb1>>24&256) * fact;
alp = Mctl[Cpgo][cStep].lwid * ifact + Mctl[Cpgo][cStep+1].lwid * fact;
Gpgo.setAttribute("style", "stroke:rgb("+red+","+grn+","+blu+");stroke-width:"+alp+";");
return 0;
}
/////////////////////////////////////////////////////////////////////////
function animateUpdate() {
Lpox = cpox[Cobj];
Lpoy = cpoy[Cobj];
// end of path condition
if(noStep[Cobj] > 0 && objStep[Cobj] >= noStep[Cobj])
{
objStep[Cobj] = 0;
atDis[Cobj] = Plen[Cobj] * MStart[Cact];
LastPt[Cobj] = 0;
DisPt[Cobj] = 0;
cpox[Cobj] = spox[Cobj];
cpoy[Cobj] = spoy[Cobj];
// reverse path, scaling, rotation, shading
if(MFlags[Cact] & (1<<11))
rate[Cobj] *= -1;
if(MFlags[Cact] & (1<<13))
rotate[Cobj] *= -1;
else
crot[cobj] = ob[cobj].crot;
if(MFlags[Cact] & (1<<19))
scale[Cobj] *= -1;
else
{
cscx[cobj] = ob[cobj].cscx;
cscy[cobj] = ob[cobj].cscy;
}
if(MFlags[Cact] & (1<<21))
shade[Cobj] *= -1;
else
cshd[cobj] = 0.0;
}
fact = atDis[Cobj] / Plen[Cobj];
ifact= 1.-fact;
// shading and transparency
if(MALst[Cact] != 0) {
var f1;
var f2;
if(MFlags[Cact] & (1<<20)) {
cshd[Cobj] += shade[Cobj];
if((cshd[Cobj] > 1.0 || cshd[Cobj] < 0.0) && MFlags[Cact] && (1<<21)) shade[Cobj] *= -1;
cshd[Cobj] = max(0,min(1,cshd[Cobj]));
f1 = cshd[Cobj];
f2 = 1 - f1;
}
else if(shade[Cobj] < 0) {
f1 = fact;
f2 = ifact;
}
else {
f2 = fact;
f1 = ifact;
}
f1 = max(0.0,min(1.0,f1));
f2 = max(0.0,min(1.0,f2));
if(ATyp[Catt] >= 10 && ATyp[Catt] <= 15)
{
var vx = (AVc1x[Catt] * f1 + AVc1x[MALst[Cact]] * f2);
var vy = (AVc1y[Catt] * f1 + AVc1y[MALst[Cact]] * f2);
Agrd[Catt].setAttribute('x',(vx+50)+'%');
Agrd[Catt].setAttribute('y',(vy+50)+'%');
if(ATyp[Catt] == 11) {
vx = -vx + 50;
vy = -vy + 50;
}
else {
vx = (AVc2x[Catt] * f1 + AVc2x[MALst[Cact]] * f2) + 50;
vy = (AVc2y[Catt] * f1 + AVc2y[MALst[Cact]] * f2) + 50;
}
Agrd[Catt].setAttribute('fx',vx+'%');
Agrd[Catt].setAttribute('fy',vy+'%');
red = (ACol[Catt] &256) * f1 + (ACol[MALst[Cact]] &256) * f2;
grn = (ACol[Catt]>> 8&256) * f1 + (ACol[MALst[Cact]]>> 8&256) * f2;
blu = (ACol[Catt]>>16&256) * f1 + (ACol[MALst[Cact]]>>16&256) * f2;
alp = (ACol[Catt]>>24&256) * f1 + (ACol[MALst[Cact]]>>24&256) * f2;
Astp1[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp1[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
if(ATyp[Catt] == 12)
{
Astp3[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp3[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
}
red = (ACol2[Catt] &255) * f1 + (ACol2[MALst[Cact]] &255) * f2;
grn = (ACol2[Catt]>> 8&255) * f1 + (ACol2[MALst[Cact]]>> 8&255) * f2;
blu = (ACol2[Catt]>>16&255) * f1 + (ACol2[MALst[Cact]]>>16&255) * f2;
alp = (ACol2[Catt]>>24&255) * f1 + (ACol2[MALst[Cact]]>>24&255) * f2;
Astp2[Catt].setProperty("stop-color", "rgb("+red+","+grn+","+blu+");");
Astp2[Catt].setProperty("stop-opacity", (1.-alp/255.) + ";");
}
else
{
red = (ACol[Catt] &255) * f1 + (ACol[MALst[Cact]] &255) * f2;
grn = (ACol[Catt]>> 8&255) * f1 + (ACol[MALst[Cact]]>> 8&255) * f2;
blu = (ACol[Catt]>>16&255) * f1 + (ACol[MALst[Cact]]>>16&255) * f2;
alp = (ACol[Catt]>>24&255) * f1 + (ACol[MALst[Cact]]>>24&255) * f2;
Coid.setAttribute("style", "fill:" + "rgb("+red+","+grn+","+blu+");opacity:" + (1.-alp/255.));
}
}
tranUpdate();
if(Plen[Cobj] != 0) atDis[Cobj] += disStep[Cobj];
objStep[Cobj]++;
if(noStep[Cobj] > 0 && objStep[Cobj] >= noStep[Cobj])
{
if(PathCount[Cobj] > 0) PathCount[Cobj]--;
if(PathCount[Cobj] == 0) {
EndPath[Cobj] = 1;
}
}
if(Cact) UpdGeo();
if(Cobj == pgScObj) {
var x = cpox[Cobj]-mW*0.5;
var y = cpoy[Cobj]-mH*0.5;
//^^^window.scrollTo(x,y);
}
return;
}
function tranUpdate()
{
resetMatrix();
// calculate rotation
if(rotate[Cobj] != 0)
{
if(MFlags[Cact] & (1<<12))
crot[Cobj] += rotate[Cobj] * 4;
else
crot[Cobj] = rotate[Cobj] * fact * 360;
}
// calculate scaling
if(scale[Cobj] != 0)
{
if(MFlags[Cact] & (1<<18))
{
cscx[Cobj] += scale[Cobj] / 360.;
cscy[Cobj] += scale[Cobj] / 360.;
}
else
{
var flt = (scale[Cobj] > 0) ? fact : ifact;
cscx[Cobj] = ob[Cobj].cscx * (flt + 1.);
cscy[Cobj] = ob[Cobj].cscy * (flt + 1.);
}
var fsize = 12 * cscx[Cobj];
}
if(ob[Cobj].jnt) {
cpox[Cobj] = cjtx[ob[Cobj].jnt];
cpoy[Cobj] = cjty[ob[Cobj].jnt];
}
// attached to the position of another Object
else if(MType[Cact] & ACT_XPATH_OBJXYZ)
{
cpox[Cobj] = cpox[Cpob] - ob[Cobj].corx;
cpoy[Cobj] = cpoy[Cpob] - ob[Cobj].corx;
}
// trace an Object path
else if(MType[Cact] & ACT_XPATH_OBJPTH)
{
if ((Gtyp[Cpgo] & GEO_TYPE) == 1)
GetRectLoc();
else if((Gtyp[Cpgo] & GEO_TYPE) == 2)
{
GetArcLoc();
}
else if((Gtyp[Cpgo] & GEO_TYPE) == 3)
{
GetPathLoc();
}
x = cpox[Cobj] - ob[Cobj].corx;
y = cpoy[Cobj] - ob[Cobj].cory;
cpox[Cobj] = x * ob[Cpob].m0 + y * ob[Cpob].m2 + ob[Cpob].m4;
cpoy[Cobj] = x * ob[Cpob].m1 + y * ob[Cpob].m3 + ob[Cpob].m5;
//window.status = 'Cpob='+Cpob+' matrix='+ob[Cpob].m0+','+ob[Cpob].m1+','+ob[Cpob].m2+','+ob[Cpob].m3+','+ob[Cpob].m4+','+ob[Cpob].m5;
//window.status = 'Cobj='+Cobj+' cpox[Cobj]='+cpox[Cobj]+' cpoy[Cobj]='+cpoy[Cobj]+' x='+x+' y='+y;
//window.status = 'Cpob='+Cpob+' matrix='+ob[Cpob].m0+','+cpox[Cpob]+','+cpoy[Cpob];
}
// trace the mouse
else
{
if(MType[Cact] & ACT_XPATH_MOUSE)
cpox[Cobj] = cmx - ob[Cobj].corx;
else
cpox[Cobj] += dpox[Cobj]; //^^ is this STOP?
if(MType[Cact] & ACT_YPATH_MOUSE)
cpoy[Cobj] = cmy - ob[Cobj].cory;
else
cpoy[Cobj] += dpoy[Cobj];
}
//window.status = 'Cobj='+Cobj+' cscx[Cobj]='+cscx[Cobj]+' cscy[Cobj]='+cscy[Cobj]+' crot[Cobj]='+crot[Cobj];
appTrans(Cobj);
transKyPt();
appMtrx();
}
function GetArcLoc() {
if(rate[Cobj] > 0)
{
cpox[Cobj] = (Math.sin(0.017453292*(-atDis[Cobj]-90)) * Gszx[Cpgo]);
cpoy[Cobj] = (Math.cos(0.017453292*(-atDis[Cobj]-90)) * Gszy[Cpgo]);
}
else
{
cpox[Cobj] = (Math.sin(0.017453292*(atDis[Cobj]-90)) * Gszx[Cpgo]);
cpoy[Cobj] = (Math.cos(0.017453292*(atDis[Cobj]-90)) * Gszy[Cpgo]);
}
return;
}
function GetPathLoc() {
var cPt, nPt, x, y, dis=0.0, ratio=0.0, ct = 0;
if(rate[Cobj] > 0)
{
while(ct <= Gnpt[Cpgo])
{
ct ++;
if(LastPt[Cobj]+1 < Gnpt[Cpgo])
{
cPt = LastPt[Cobj];
nPt = cPt + 1;
}
else
{
if(Gtyp[Cpgo] & GEO_OPEN)
{
LastPt[Cobj] = 0;
cPt = 0;
nPt = 1;
}
else
{
LastPt[Cobj] = Gnpt[Cpgo]-1;
cPt = LastPt[Cobj];
nPt = 0;
}
}
x = (Gpxl[Cpgo][nPt] - Gpxl[Cpgo][cPt]);
y = (Gpyl[Cpgo][nPt] - Gpyl[Cpgo][cPt]);
dis = Math.sqrt(x*x + y*y);
if(atDis[Cobj] < (dis + DisPt[Cobj])) break;
DisPt[Cobj] += dis;
LastPt[Cobj]++;
if(LastPt[Cobj] >= Gnpt[Cpgo])
{
cPt = 0;
nPt = 1;
LastPt[Cobj] = 0;
}
}
ratio = (atDis[Cobj] - DisPt[Cobj]) / dis;
cpox[Cobj] = Gpxl[Cpgo][cPt] + x * ratio;
cpoy[Cobj] = Gpyl[Cpgo][cPt] + y * ratio;
return;
}
else
{
while(ct <= Gnpt[Cpgo])
{
ct ++;
if(LastPt[Cobj]+1 < Gnpt[Cpgo])
{
cPt = Gnpt[Cpgo] - LastPt[Cobj] - 1;
nPt = cPt - 1;
}
else
{
if(Gtyp[Cpgo] & GEO_OPEN)
{
LastPt[Cobj] = Gnpt[Cpgo] - 1;
cPt = Gnpt[Cpgo] - 1;
nPt = cPt - 1;
}
else
{
LastPt[Cobj] = Gnpt[Cpgo];
cPt = 0;
nPt = LastPt[Cobj] - 1;
}
}
x = (Gpxl[Cpgo][nPt] - Gpxl[Cpgo][cPt]);
y = (Gpyl[Cpgo][nPt] - Gpyl[Cpgo][cPt]);
dis = Math.sqrt(x*x + y*y);
if(atDis[Cobj] <= (dis + DisPt[Cobj])) break;
DisPt[Cobj] += dis;
LastPt[Cobj]++;
if(LastPt[Cobj] >= Gnpt[Cpgo])
{
cPt = 0;
nPt = 1;
LastPt[Cobj] = 0;
}
}
ratio = (atDis[Cobj] - DisPt[Cobj]) / dis;
cpox[Cobj] = Gpxl[Cpgo][cPt] + x * ratio;
cpoy[Cobj] = Gpyl[Cpgo][cPt] + y * ratio;
return;
}
}
function GetRectLoc()
{
var dis = 0.0;
while (0==0)
{
if(rate[Cobj] > 0)
{
if(LastPt[Cobj] == 0)
{
dis = (Gpxl[Cpgo][1] - Gpxl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][0] + (atDis[Cobj]-DisPt[Cobj]);
cpoy[Cobj] = Gpyl[Cpgo][0];
break;
}
LastPt[Cobj] = 1;
DisPt[Cobj] += dis;
}
if(LastPt[Cobj] == 1)
{
dis = (Gpyl[Cpgo][1] - Gpyl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][1];
cpoy[Cobj] = Gpyl[Cpgo][0] + (atDis[Cobj]-DisPt[Cobj]);
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 2;
}
if(LastPt[Cobj] == 2)
{
dis = (Gpxl[Cpgo][1] - Gpxl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][1] - (atDis[Cobj]-DisPt[Cobj]);
cpoy[Cobj] = Gpyl[Cpgo][1];
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 3;
}
if(LastPt[Cobj] == 3)
{
dis = (Gpyl[Cpgo][1] - Gpyl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][0];
cpoy[Cobj] = Gpyl[Cpgo][1] - (atDis[Cobj]-DisPt[Cobj]);
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 0;
}
}
else
{
if(LastPt[Cobj] == 0)
{
dis = (Gpyl[Cpgo][1] - Gpyl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][0];
cpoy[Cobj] = Gpyl[Cpgo][0] + (atDis[Cobj]-DisPt[Cobj]);
break;
}
LastPt[Cobj] = 3;
DisPt[Cobj] += dis;
}
if(LastPt[Cobj] == 3)
{
dis = (Gpxl[Cpgo][1] - Gpxl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][0] + (atDis[Cobj]-DisPt[Cobj]);
cpoy[Cobj] = Gpyl[Cpgo][1];
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 2;
}
if(LastPt[Cobj] == 2)
{
dis = (Gpyl[Cpgo][1] - Gpyl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][1];
cpoy[Cobj] = Gpyl[Cpgo][1] - (atDis[Cobj]-DisPt[Cobj]);
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 1;
}
if(LastPt[Cobj] == 1)
{
dis = (Gpxl[Cpgo][1] - Gpxl[Cpgo][0]);
if((DisPt[Cobj] + dis) > atDis[Cobj])
{
cpox[Cobj] = Gpxl[Cpgo][1] - (atDis[Cobj]-DisPt[Cobj]);
cpoy[Cobj] = Gpyl[Cpgo][0];
break;
}
DisPt[Cobj] += dis;
LastPt[Cobj] = 0;
}
}
}
return;
}
///////////////////////////////////////////////
function resetMatrix() {
cM = 0;
ob[Cobj].m0 = 1;
ob[Cobj].m1 = 0;
ob[Cobj].m2 = 0;
ob[Cobj].m3 = 1;
ob[Cobj].m4 = 0;
ob[Cobj].m5 = 0;
}
function appTrans(obj) {
moveMatrix(cpox[obj]+ob[Cobj].corx, cpoy[obj]+ob[Cobj].cory);
rotateMatrix(crot[obj]);
scaleMatrix(cscx[obj],cscy[obj]);
moveMatrix(-ob[Cobj].corx, -ob[Cobj].cory);
}
function moveMatrix(x, y) {
ob[Cobj].m4 += x * ob[Cobj].m0 + y * ob[Cobj].m2;
ob[Cobj].m5 += x * ob[Cobj].m1 + y * ob[Cobj].m3;
}
function scaleMatrix(x, y) {
ob[Cobj].m0 *= x;
ob[Cobj].m1 *= x;
ob[Cobj].m2 *= y;
ob[Cobj].m3 *= y;
}
function rotateMatrix(ang) {
var cosAng = Math.cos(0.017453292*ang);
var sinAng = Math.sin(0.017453292*ang);
var a = ob[Cobj].m0;
var b = ob[Cobj].m1;
var c = ob[Cobj].m2;
var d = ob[Cobj].m3;
var e = ob[Cobj].m4;
var f = ob[Cobj].m5;
ob[Cobj].m0 = a * cosAng + c * sinAng;
ob[Cobj].m1 = b * cosAng + d * sinAng;
ob[Cobj].m2 = a * -sinAng + c * cosAng;
ob[Cobj].m3 = b * -sinAng + d * cosAng;
}
function tranMatrix(cpob) {
var a = ob[Cobj].m0;
var b = ob[Cobj].m1;
var c = ob[Cobj].m2;
var d = ob[Cobj].m3;
var tx= ob[Cobj].m4;
var ty= ob[Cobj].m5;
ob[Cobj].m0 = a * ob[cpob].m0 + b * ob[cpob].m2;
ob[Cobj].m1 = a * ob[cpob].m1 + b * ob[cpob].m3;
ob[Cobj].m2 = c * ob[cpob].m0 + d * ob[cpob].m2;
ob[Cobj].m3 = c * ob[cpob].m1 + d * ob[cpob].m3;
ob[Cobj].m4 = tx * ob[cpob].m0 + ty * ob[cpob].m2 + ob[cpob].m4;
ob[Cobj].m5 = tx * ob[cpob].m1 + ty * ob[cpob].m3 + ob[cpob].m5;
}
function UpdKpt() {
cpox[Cobj] = cjtx[ob[Cobj].jnt] -ob[Cobj].corx;
cpoy[Cobj] = cjty[ob[Cobj].jnt] -ob[Cobj].cory;
Coid.setAttribute('transform','translate('+cpox[Cobj]+','+cpoy[Cobj]+'),rotate('+crot[Cobj]+'),scale('+cscx[Cobj]+','+cscy[Cobj]+')');
}
function transKyPt() {
cjtx[Cobj] = ob[Cobj].cjtx * ob[Cobj].m0 + ob[Cobj].cjty * ob[Cobj].m2 + ob[Cobj].m4;
cjty[Cobj] = ob[Cobj].cjtx * ob[Cobj].m1 + ob[Cobj].cjty * ob[Cobj].m3 + ob[Cobj].m5;
}
function appMtrx() {
Coid.setAttribute('transform','matrix('+ob[Cobj].m0+','+ob[Cobj].m1+','+ob[Cobj].m2+','+ob[Cobj].m3+','+ob[Cobj].m4+','+ob[Cobj].m5+')');
//window.status = 'Cobj='+Cobj+'ob[Cobj].m0='+ob[Cobj].m0+' ob[Cobj].m1='+ob[Cobj].m1+' ob[Cobj].m2='+ob[Cobj].m2+' ob[Cobj].m3='+ob[Cobj].m3+ob[Cobj].m3+' ob[Cobj].m4='+ob[Cobj].m4+' ob[Cobj].m5='+ob[Cobj].m5;
}