Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Bug Report (https://forums.graalonline.com/forums/forumdisplay.php?f=193)
-   -   Error with polygons drawing lines (https://forums.graalonline.com/forums/showthread.php?t=134267941)

Hoyt1134 02-26-2013 03:02 PM

Error with polygons drawing lines
 
I have run into an unusual bug with drawing polygons on the latest version (6.037) of the Windows client. When drawing a polygon with only 2 points, its x and y positions are offset by 0.5 tiles. If you attempt to draw a polygon with the coordinates {20, 20, 25, 25} it will instead draw it at {20.5, 20.5, 25.5, 25.5} and also move the rightmost pixel up by 1 pixel. This doesn't seem to affect polygons with more than 2 points or images though. Here is the code I used to test with:

PHP Code:

//#CLIENTSIDE
function onMouseDown(){
 
temp.imageX=mousex;
 
temp.imageY=mousey;

//Block image
 
with(findimg(200)){
  
image="block.png";
  
x=temp.imageX;
  
y=temp.imageY;
  
layer=0;
 }

//Green triangle 2-D polygon
 
with(findimg(201)){
  
polygon={
   
temp.imageX,temp.imageY,
   
temp.imageX+2,temp.imageY,
   
temp.imageX+2,temp.imageY+2
  
};
  
layer=1;
  
red=0;
  
green=1;
  
blue=0;
 }

//Red line 1-D polygon
 
with(findimg(202)){
  
polygon={
   
temp.imageX,temp.imageY,
   
temp.imageX+2,temp.imageY
  
};
  
layer=2;
  
red=1;
  
green=0;
  
blue=0;
 }


And here is an image of the results:
http://i.imgur.com/zaiOhzS.png

The red line should line up with the top edge of the green triangle and the block image, but instead it is shifted down and to the right, and the rightmost pixel is raised up.

cbk1994 02-26-2013 11:24 PM

It doesn't really make a lot of sense to draw polygons with two points. At least in the past, the behavior when doing that was inconsistent between platforms anyway. If you just need a line, then it's better to make a skinny rectangle. Plus you get control over the line weight.

Hoyt1134 02-28-2013 10:02 AM

I've never run into any strange behavior with polygons being used to draw lines before on Graal, and in fact in the original documentation for showpoly it specifically says you can enter 2 points to draw a line. In order to use 4 points to draw a rectangle to simulate drawing a line you have to do additional calculations for getting the line's angle in order to properly rotate the corners to keep the polygon a rectangle. You also don't get the crisp 1-pixel thick lines like a 2 point showpoly provides. It is much easier to simply have a function that draws the line with only 2 points, like Graal's polygons are supposed to.

A line mathematically isn't a polygon, but there is no reason to restrict functionality based on that. Even if there has been a bug with polygon lines for a long time, it doesn't mean the bug shouldn't be fixed.


All times are GMT +2. The time now is 09:43 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.