mIRC Home    About    Download    Register    News    Help

Print Thread
/drawrot, slightly unexpected behaviour #267591 17/08/20 04:44 PM
Joined: Dec 2019
Posts: 30
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 30
so I'm using this image

https://i.ibb.co/zZpgWNt/blue-marker-l.png

example^^ is 150px x 150px

the square outline (u cant see it from the page format but it's a white square with black outline) is just so I can see what the shape is doing.

it's part of a percentage progress meter, main script is this, on a millisecond timer, %total is about 5,000, %loop 1 to 5,000

window setup

window -dp @perc 150 600 400 400
drawpic @perc 30 30 "c:\path\blue_marker_l.png"

percentage script

drawpic -n @perc 30 30 "c:\path\blue_marker_l.png"
drawrot -c @perc $calc((100 /(%total / %loop)) * 3.6) 30 30 150 150


so that doesnt rotate it by a fraction of a degree per percentage, it puts the original image up each time and rotates it by the total. which is fine (no accumulated errors and stuff). basically it can work. couple of problems

1) I'd like to turn it into a sort of pac-man shape progress rather than line (needle) progress. I can (in theory) do that by rather than rotating the entire square, rotating just the blue line section of the image (with the bottom-middle (ideally) of the line as the reference point), and "spreading" the marker (not redrawing the square/circle as white each time)

using /drawrot without the -c, I can see *how* it rotates the image within the window? but....it's wrong smile like -c uses the centre as the static point, I need to be able to set the static reference as "bottom middle", rather than the way it rotates at the moment. it sort of re-jigs the image into the space it's rotating (which isnt quite right! - for what Im doing)

possibly another set of params for /drawrot which specifies the co-ordinates of the static point (where an example of "-c" is actually a static point, it's the middle)

thats the main-ish thing

2) if I put some text just above that square (or any side or it) , as it rotates, eg at 45 degrees, the square becomes a diamond - which covers over any text just above/around it. I've tried making the ".png" a circle with transparent background but /drawrot rotates the windows contents and not the ".png" itself?.....so transparent background doesnt do anything,

again rotating just the line itself rather than 150x150 pix would solve this, but can't set the static point if its just the line

3) one last final thing which is slightly seperate, is it possible to rotate an icon inside a dialog window? for exactly the same purpose, at the moment the dialog needs a seperate picture window for this graphic


Last edited by quartz; 17/08/20 04:49 PM.
Re: /drawrot, slightly unexpected behaviour [Re: quartz] #267594 17/08/20 07:40 PM
Joined: Jul 2006
Posts: 3,715
W
Wims Offline
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 3,715
If you want to use drawrot for that, you have to keep the previous drawing and basically increment by small angles, not very good, you should probably just draw some lines from the angle you get, depending on the image, you could use /drawfil to fill the space between the last drawn place and the new angle.


Looking for a good help channel about mIRC? Check #mircscripting @ irc.swiftirc.net
Re: /drawrot, slightly unexpected behaviour [Re: Wims] #267597 18/08/20 02:11 PM
Joined: Dec 2019
Posts: 30
Q
quartz Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Dec 2019
Posts: 30
(thanks Wims)

done. can't drawrot a line, but $sin().deg and $cos().deg work nicely to find a destination point, using the angle

this is basically the line

$cos( $calc(((100 /(%total / %loop)) * 3.6) -90) ).deg
$sin( $calc(((100 /(%total / %loop)) * 3.6) -90) ).deg

the 3.6 convert a percentage into degrees
the -90 starts the percentage off vertically, rather than at 3 o'clock
also I used "100 x" that to make the line a decent length, because '$sin' and '$cos' (.deg) give a result of less than 1

Last edited by quartz; 18/08/20 02:16 PM.
Re: /drawrot, slightly unexpected behaviour [Re: quartz] #267602 19/08/20 08:09 PM
Joined: Dec 2002
Posts: 203
T
Talon Offline
Fjord artisan
Offline
Fjord artisan
T
Joined: Dec 2002
Posts: 203
not sure if this helps or not, sounds like you're trying to do like a pie chart. Here's a quick mock-up example:

this is an ALIAS, I wrote this in my aliases tab, if you put it in remotes, prefix it with "alias ":
Code
pie {
  ;<color1 [0-99]> <color2 [0-99]> <radius in pixels> <percentage [0-1]>
  var %w = $$3 * 2 , %w = %w + 2 , %hw = %w / 2 , %hr = $3 / 2
  var %pc = $calc(360 * $4 - 90) , %hpc = $calc(180 * $4 - 90)
  var %cos = $cos(%pc).deg * $3 , %sin = $sin(%pc).deg * $3
  var %hcos = $cos(%hpc).deg * %hr , %hsin = $sin(%hpc).deg * %hr

  window -dpf +l @Pie -1 -1 %w %w
  drawrect -nf @Pie 1 1 0 0 %w %w
  drawdot @Pie $1 $3 %hw %hw
  if ($4) {
    drawline -n @Pie $2 1 %hw %hw %hw 1
    drawline -n @Pie $2 1 %hw %hw $calc(%hw + %cos) $calc(%hw + %sin)
    drawfill -s @Pie $2 $1 $calc(%hw + %hcos) $calc(%hw + %hsin)
    drawtext @Pie 0 $calc(%hw + %hcos) $calc(%hw + %hsin) $round($calc($4 * 100),2) $+ %
  }
}


Usage:
/pie <color> <color> <radius> <percent>
Color 1 is the primary circle color, Color 2 is the pie wedge color, radius is the size of the circle, and percent is a number between 0-1, 0 being none, 1 being full, .5 being 50%, etc...

Examples of a Dark Blue circle, with a Light Blue Wedge, with a radius of 160:

/pie 2 10 160 .06327
6.33%

/pie 2 10 160 .1
10%

/pie 2 10 160 .5
50%

/pie 2 10 160 .83
83%