Old 28th June 2004, 06:07   #1
horse-fly
Account Closed
 
horse-fly's Avatar
 
Join Date: Apr 2001
Posts: 2,360
Pixel Placement

Is there a way to define a superscope by a certain pixel position, rather than ratio?
horse-fly is offline   Reply With Quote
Old 28th June 2004, 10:09   #2
Deamon
Major Dude
 
Deamon's Avatar
 
Join Date: Nov 2002
Location: Arnhem, the Netherlands
Posts: 927
in frame:

p=0;

In per point:
p=p+1;
x=xp1*equal(p,1)+xp2*equal(p,2)+xp3*equal(p,3);
y=yp1*equal(p,1)+yp2*equal(p,2)+yp3*equal(p,3);

where xp1, xp2, xp3, yp1, yp2 and yp3 are coordinates. Make sure n equals the number of p you use, all n higher than p snap to coords (0,0).

Works in 3D as well.

.:HyperNation @ winamp:. .:DeviantArt:.
Thermal is now available for download at DeviantArt.
Deamon is offline   Reply With Quote
Old 28th June 2004, 10:29   #3
Jaak
Major Dude
 
Jaak's Avatar
 
Join Date: Jan 2003
Location: Estonia.
Posts: 851
dont use multiply, just chunks of ifs, multiplication is slow, but the ifs will be quite faster... especialy if your little scope consists of 100 points

Phi = (1+sqrt(5))/2
Jaak is offline   Reply With Quote
Old 28th June 2004, 11:51   #4
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
I don't think this is what he meant..
You can use px=1/w for instance for 1 pixel in width and py=1/h for 1 pixel in height. or 2/h, 3/h for two or three pixels etc.

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 29th June 2004, 00:57   #5
horse-fly
Account Closed
 
horse-fly's Avatar
 
Join Date: Apr 2001
Posts: 2,360
I'll try what WOTL said, as it seems to be the one that would work.
horse-fly is offline   Reply With Quote
Old 29th June 2004, 07:24   #6
Shylent
Junior Member
 
Join Date: May 2004
Location: A Galaxy Far Far Away
Posts: 19
Hmm, seriously, Jaak, in case you are right, I will need to remake quite a lot of my scopes
Shylent is offline   Reply With Quote
Old 29th June 2004, 07:52   #7
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
you should use megabufs for those scopes then
wotl: i think it was 1/(w-1) and 1/(h-1)

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 1st July 2004, 22:22   #8
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
Why the extra -1?

If screenwidth (w) is, say, 300 pixels,
then 1 pixel is 1/w (1 / 300 = 0.003333333-> ).

Or am I wrong?

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 2nd July 2004, 21:10   #9
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
1 pixel is 2/w (-1 .. 1 = 2 units), but you might need to add 1/w to coordinates to make sure you are on the center of a pixel.
Same for y.

UnConeD is offline   Reply With Quote
Old 3rd July 2004, 02:24   #10
dirkdeftly
Forum King
 
dirkdeftly's Avatar
 
Join Date: Jun 2001
Location: Cydonia, Mars
Posts: 2,651
Send a message via AIM to dirkdeftly
also, if you run into problems (as i did just recently) with points being a pixel off, avs does some wonky rounding and i *think* it turns out that avs rounds down to the nearest pixel when the value is above zero, and up if the value is below zero. so if you have a point that is at 100.5 pixels, it will round to 100, but if it's -100.5, it'll round to -100 instead of -101
the way i fixed it is just adding 1/w (1/2 pixel) to x and y.
stupidgoddamnroundingerrors

"guilt is the cause of more disauders
than history's most obscene marorders" --E. E. Cummings
dirkdeftly is offline   Reply With Quote
Old 3rd July 2004, 13:42   #11
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
So if your screensize is 300x300 then w=h=150 and not 300?!? WTF?

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 3rd July 2004, 16:27   #12
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
Um no WOTL.

Width in pixels = 300pixels
Width in 'avs units' = 2 (from -1 to 1).

1 pixel = 2 / 300 = 2 / w

UnConeD is offline   Reply With Quote
Old 5th July 2004, 11:19   #13
TomyLobo
Major Dude
 
TomyLobo's Avatar
 
Join Date: Feb 2004
Location: Germany
Posts: 580
ok 2/(w-1)
pixels on screen go from 0..(w-1) whereas AVS has a coordinate range of -1..1
so to go from pixels to avs coords, you
- divide by (w-1)
- multiply by 2
- subtract 1
in other words
xavs=xpix/(w-1)*2-1;
if you have 2 pixels and want the distance, in avs coordinates:
xavs1=xpix1/(w-1)*2-1;
xavs2=xpix2/(w-1)*2-1;
xavs2-xavs1=xpix2/(w-1)*2-1-(xpix1/(w-1)*2-1);
=xpix2/(w-1)*2-xpix1/(w-1)*2;
=(xpix2-xpix1)/(w-1)*2;

if xpix2-xpix1 is 1 pixel then you get xavs2-xavs1=2/(w-1)

same thing for y coords just with h instead of w

If you can't say something nice, say something surrealistic.
TomyLobo is offline   Reply With Quote
Old 5th July 2004, 16:15   #14
Warrior of the Light
Forum King
 
Warrior of the Light's Avatar
 
Join Date: Aug 2002
Location: The Netherlands
Posts: 4,082
Okay, I get it now. Thanks

Jesus loves you [yes, you] so much, he even died for you so that you will not need to die, but live forever
Warrior of the Light is offline   Reply With Quote
Old 6th July 2004, 04:22   #15
NemoOrange
Senior Member
 
NemoOrange's Avatar
 
Join Date: Jan 2003
Location: Philadelphia, USA
Posts: 135
Send a message via AIM to NemoOrange
Kinda on the same subject:

I was making a scope that I wanted to move in perfect 45 degree angles.

The code went something like:

xm=xm+sin(mr)*speed;

ym=ym+cos(mr)*speed;

mr=$PI/2*var+$PI/4;

x=xm; y=ym;

For the most part, it did move in 45 degrees, but every 10 pixels or so, it would move up a pixel, then back down 10 pixels later. This sounds like what Atero was talking about. Does anyone know how to fix this?
NemoOrange is offline   Reply With Quote
Old 6th July 2004, 06:33   #16
UnConeD
Whacked Moderator
 
UnConeD's Avatar
 
Join Date: Jun 2001
Posts: 2,104
Nemo: Perhaps there are some rounding errors on the angle, in any case it's faster to just use +/- 0.707 rather than sin/cos.

UnConeD is offline   Reply With Quote
Old 4th August 2004, 10:59   #17
vanderphunck
Junior Member
 
vanderphunck's Avatar
 
Join Date: Jul 2004
Location: Finland
Posts: 47
check my reply to this thread: http://forums.winamp.com/showthread....45#post1429445
vanderphunck is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Visualizations > AVS

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump