Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Wild Curser: making it one color 1

Status
Not open for further replies.

Kirderf

Technical User
Oct 4, 2000
183
US
I have a bit of code that changes the color of lines eminating from the curser. You can see the way it looks at this site.

I have tried to change the code to make it all one color.(#FF0066)
And I need help because I am stuck.
The code goes into a frame action.
Code:
stop();

p = new Array();
count = 0;
p[count] = {x:_xmouse, y:_ymouse, w:0, col:0};
count++;
rand = Math.random;
sin = Math.sin;

r = 255; //rand() * 128 + 127;
g = 127; //rand() * 128 + 127;
b = 0; //rand() * 128 + 127;
w = 0;
ri = 0.02; //rand() * 0.05;
gi = 0.015; //rand() * 0.05;
bi = 0.025; //rand() * 0.05;

this.onEnterFrame = function() {
	vx = _xmouse - oldx + rand() * 2 - 1;
	vy = _ymouse - oldy + rand() * 2 - 1;
	oldx = _xmouse;
	oldy = _ymouse;

	p[count] = { x:_xmouse, y:_ymouse, vx:vx * 0.5, vy:vy * 0.5, w:(sin(w += 0.2)*5 + 5),
					  col:(sin(r += ri) * 128 + 127) << 16  |  (sin(g += gi) * 128 + 127) << 8  |  (sin(b += bi) * 128 + 127) };
	count++;
	clear();
	moveTo(_xmouse, _ymouse);
	for (var i in p) {
		lineStyle(p[i].w, p[i].col);
		p[i].x += p[i].vx;
		p[i].y += p[i].vy;
		if (p[i].y > 380) {
			p[i].y = 380;
			p[i].vy *= -0.5;
			p[i].vx *= .95;
		}
		if (i) curveTo(p[i].x, p[i].y, (Number(p[i].x) + Number(p[i-1].x))/2, (Number(p[i].y) + Number(p[i-1].y))/2);

		if (p.length > 50) {
			p.splice(0, 1);
			count--;
		}
	}
};

I'd gladly pay you on Thursday
for a hamburger today!
 
Change the value of [tt]col[/tt] in [tt]p[count][/tt] to #ff0066:
[tt]//
p[count] = {x:_xmouse, y:_ymouse, vx:vx*0.5, vy:vy*0.5, w:(sin(w += 0.2)*5+5), col:0xff0066};
//[/tt]
You may remove the following variable initializations too: [tt]r, g, b, ri, gi, bi[/tt]

Kenneth Kawamoto
 
Awesome! That was it. I must tell you that I tried everything I could think of except for that.

I'd gladly pay you on Thursday
for a hamburger today!
 
Kirderf,

I like the crazy cursor, is there a way to stop and restart the effect?

Thanks,

Laurence
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top