mIRC Homepage

/drawrot, slightly unexpected behaviour

Posted By: quartz

/drawrot, slightly unexpected behaviour - 17/08/20 04:44 PM

so I'm using this image


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

Posted By: Wims

Re: /drawrot, slightly unexpected behaviour - 17/08/20 07:40 PM

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.
Posted By: quartz

Re: /drawrot, slightly unexpected behaviour - 18/08/20 02:11 PM

(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
Posted By: Talon

Re: /drawrot, slightly unexpected behaviour - 19/08/20 08:09 PM

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 ":
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) $+ %

/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

/pie 2 10 160 .1

/pie 2 10 160 .5

/pie 2 10 160 .83
© 2021 mIRC Discussion Forums