mIRC Home    About    Download    Register    News    Help

Print Thread
#159549 18/09/06 06:20 PM
Joined: Aug 2006
Posts: 13
V
vbCrLf Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Aug 2006
Posts: 13
Hello.
I tried to use $inellipse:
$inellipse(480,301,318.650782,295.558688,30,30)
And its returns $true. But I checked it with:
/drawrect -ef @test 4 1 318.650782 295.558688 30 30
/drawdot @test 3 3 480 301
And the dot is not in the ellipse. Its looks like a bug.

#159550 19/09/06 09:18 AM
Joined: May 2006
Posts: 122
J
Vogon poet
Offline
Vogon poet
J
Joined: May 2006
Posts: 122
Quote:

$inellipse(480,301,318.650782,295.558688,30,30)

How can u draw half a pixel?


If only women came with popup menus and online help.
#159551 19/09/06 09:42 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The help file says $inellipse(x,y,x,y,w,h) while you're using $inellipse(x,y,w,h,x,y). Try $inellipse(30,30,480,301,318.650782,295.558688)


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#159552 19/09/06 09:43 AM
Joined: Aug 2006
Posts: 13
V
vbCrLf Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Aug 2006
Posts: 13
There is no diffrence. I tried:
Code:
 $inellipse(480,301,318,295,30,30) 

And its still return $true.

EDIT: I talked to jizzy... I will try it now.

Last edited by vbCrLf; 19/09/06 09:46 AM.
#159553 19/09/06 09:49 AM
Joined: Aug 2006
Posts: 13
V
vbCrLf Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Aug 2006
Posts: 13
Quote:
The help file says $inellipse(x,y,x,y,w,h) while you're using $inellipse(x,y,w,h,x,y). Try $inellipse(30,30,480,301,318.650782,295.558688)

Maybe you didn't understand me.
$inellipse(480,301,318.650782,295.558688,30,30)
480,301 = x,y of the dot.
318.650782,295.558688 = x,y of the ellipse.
30,30 = h,w of the ellipse.

#159554 19/09/06 10:12 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
That should teach me not to try stuff before I've had coffee frown

You're right, it looks like a bug.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#159555 19/09/06 10:20 AM
Joined: Aug 2006
Posts: 13
V
vbCrLf Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Aug 2006
Posts: 13
So don't drink coffee smirk
I need to continue my game, so do you have a code instead $inellipse? I can't wait until a new version of mIRC will come...

#159556 19/09/06 11:37 AM
Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I'd written an $inellipse alias before it was added in mirc, here it is:
Code:
alias inellipse2 {
  if $calc((1-(2*($1 -$3 -$5 /2) / $5)^2)^0.5*$6 /2) $& 
    && $abs($calc($2 -$4 -$6 /2)) isnum 0- $+ $v1 { return $true }
  return $false
}
I removed the error checking to make it faster, since you know how to use it.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
#159557 19/09/06 02:18 PM
Joined: Aug 2006
Posts: 13
V
vbCrLf Offline OP
Pikka bird
OP Offline
Pikka bird
V
Joined: Aug 2006
Posts: 13
Thanks qwerty smile
Its working perfectly... I will never understand how those things working :tongue:

#159558 21/09/06 01:21 PM
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks this has been fixed for the next version.

Khaled #183411 19/08/07 08:52 PM
Joined: Dec 2003
Posts: 48
N
Ameglian cow
Offline
Ameglian cow
N
Joined: Dec 2003
Posts: 48
Hello, Maybe someone out there could double check my work,
but in 6.21 it appears the ellipse was giving false readings
vertically, and I checked in 6.3 and it seems theres false
readings horizontally. so if someone could double check my
findings that would be good.

I did however get the ellipse2 alias to work for me.

Heres my work: [image removed]

Comment: I am unable to test your script since you have pasted it as an image. Can you please post the text of the script? Thanks :-)

Last edited by Khaled; 22/08/07 11:47 AM.
Joined: Dec 2003
Posts: 48
N
Ameglian cow
Offline
Ameglian cow
N
Joined: Dec 2003
Posts: 48
I thought about that later, but used the image to demonstrate
the codes usage. so apologies if this code isnt up to spec,
I wasnt expecting to be speaking to "the man". smile

I may have over-killed the code a little bit,
but I know you have alot of stuff to do, might as well be easy?

Code:

menu status,channel {
  .-
  Test_Ellipse: test386 
}

alias test386 {
  .enable #EllipseTest
  set %use.ellipse 1
  clear @test386
  window -ek0pa @test386 1 1 550 300
}

#EllipseTest off

menu @test386 {

  mouse: {
    drawdot @test386
    ; __________________________________________________________ Retrieve Current Mouse Coordinates.
    var %mx = $mouse.x
    var %my = $mouse.y

    ; __________________________________________________________ Target Ellipse Coordinates
    var %x 100
    var %y 100
    var %w 30
    var %h 60

    ;___________________________________________________________ Evaluation: $inellipse(mx,my,tX,tY,tW,tH)
    ;                                                                            Where               m = mouse, t = target 
    var %ellipse.1 = $inellipse(%mx,%my,%x,%y,%w,%h)
    var %ellipse.2 = $inellipse2(%mx,%my,%x,%y,%w,%h)

    echo $replace(%ellipse.1,$true,3,$false,4) -s :Ellipse. $+ %use.ellipse $& 
      : %ellipse. [ $+ [ %use.ellipse ] ] :0X/Y: $mouse.x $mouse.y :9Target: %x %y %w %h

    ; __________________________________________________________Draw Target Ellipse
    drawrect -en @test386 11 2 %x %y %w %h

    ; __________________________________________________________Draw Mouse Plot
    drawdot -n @test386 $replace(%ellipse. [ $+ [ %use.ellipse ] ],$true,3,$false,4) 10 %mx %my

    ; __________________________________________________________Debug Output(logical check)
    titlebar @test386 _ M.X = $mouse.x _ M.Y = $mouse.y  $replace(%ellipse,$true,>.IN.<,$false,<*OUTSIDE*>)  CIRCLE TARGET( %x %y %w %h )
    ;    echo -s 11 MouseX(0 $chr(9) %mx 11)  $chr(9) MouseY(0 $chr(9) %my $chr(9) 11) $chr(9) $chr(9) $replace(%ellipse,$true,9IN,$false,4OUTSIDE)   CIRCLE 3TARGET-COORDINATES(0 %x %y %w %h 3)
    ;    echo -s 11 MouseX(0 %mx 11) MouseY(0 %my 11) $replace(%ellipse,$true,9IN,$false,4OUTSIDE)   CIRCLE 3TARGET-COORDINATES(0 %x %y %w %h 3)
  }

  ..Use mIRC Inellipse:{ set %use.ellipse 1 | clear @test386 }
  ..Use Qwerty Inellipse2:{ set %use.ellipse 2 | clear @test386 }
}

; __________________________________________________________Inellipse(2) By Qwerty
alias inellipse2 {  
  if $calc((1-(2*($1 -$3 -$5 /2) / $5)^2)^0.5*$6 /2) $&
    && $abs($calc($2 -$4 -$6 /2)) isnum 0- $+ $v1 { return $true }  
  return $false 
}

; __________________________________________________________Variable Cleanup
on *:close:@test386: {
  unset %use.ellipse
  .disable #EllipseTest
}

#EllipseTest end
 


Red = $False
Green = $True

(The group #ellipsetest is just preventive to avoid
conflict with other scripts. Was tried without groups with same
effect.)

Right-Click a status or channel window, -> "Test_Ellipse"
(or type /test386)

Right-click the @test386 window to switch between
mIRC $inellipse and Qwertys solution of $inellipse2 (provided).

Last edited by NrWarren; 25/08/07 04:50 AM.
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks for the code! I tried it out however I couldn't spot any issues when either using $inellipse or $inellipse2, they seem to behave identically. I traced a careful outline of the ellipse, moving my mouse in and out of the border using both ellipse methods. In both cases, the dot turned green on the inside and red on the outside as expected.

Can you describe in more detail the difference in behaviours that you see?

Khaled #184366 28/08/07 03:41 AM
Joined: Dec 2003
Posts: 48
N
Ameglian cow
Offline
Ameglian cow
N
Joined: Dec 2003
Posts: 48
Seeing as you didnt have a problem with it, I thought maybe it
was Vista, so I switched to XP. With same result, so I thought
maybe it could be my graphics card flaking out on me.

Props to my friends(Matt/Hatred), who checked on mIRC6.21 and
found similar results as I did where it returns $True all along
the vertical axis. Then we all tried the addon in 6.3 and it
returned $True all along the X axis.

To also check if it wasnt any stray variable or strange
condition, I had them try

For mIRC 6.3
Code:
$inellipse(250,10,10,10,50,50)


where 250,10 are the X/Y coords
10,10 = X/Y 50,50 =W/H
so it obviously shouldnt be returning $True here, but it is
for us.

Any other volunteers who would like to try the code
would be appreciated. Thanks.


To conclude the differences, when I move outside of the
ellipse $inellipse still reports $True, but only on the X axis.
when moved outside the Y axis it works as expected.

(When I move mouse all over the screen to check for $true/$false
conditions, there is a Green bar horizontally, where the drawn
cyan ellipse resides, everywhere else below/above cyan ellipse
is red)

In 6.2 it does the same, except with the Y axis, showing a
vertical green bar.


also, on a side note, the edges of the circle do appear to be
Red/$False but only in the rectangular shape that the ellipse
resides, then once outside the rectangle it goes back to reporting falsely on the X coords.

Let me know if you need me to check anything again.

Last edited by NrWarren; 28/08/07 04:11 AM.
Joined: Dec 2002
Posts: 5,420
Hoopy frood
Offline
Hoopy frood
Joined: Dec 2002
Posts: 5,420
Thanks for the help, I managed to reproduce the issue. I was previously testing your script under a debug version of mIRC, which worked fine. When tested under the release version, the problem was visible.

It turns out that when the Microsoft compiler creates the release version of mIRC, it optimizes floating point operations in a way that leads to inconsistent results for large floating point values.

I have been able to resolve this issue by enabling the compiler option to improve floating point consistency, which applies to all number handling in mIRC. So this should hopefully be fixed in the next version.

Khaled #184441 29/08/07 01:22 AM
Joined: Dec 2003
Posts: 48
N
Ameglian cow
Offline
Ameglian cow
N
Joined: Dec 2003
Posts: 48
Keep up the good work, I'm a big fan of mIRC.

and now for my shameless plug whistle
ever thought about updating the script editor
with background themes or an identifier evaluator?

you can tell where I spend my time... grin


Link Copied to Clipboard