Graal Forums  

Go Back   Graal Forums > Graal V6 forums > Bug Report
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old 02-26-2013, 03:02 PM
Hoyt1134 Hoyt1134 is offline
Registered User
Join Date: Jul 2004
Posts: 18
Hoyt1134 is on a distinguished road
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:


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.
Reply With Quote
  #2  
Old 02-26-2013, 11:24 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
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.
__________________
Reply With Quote
  #3  
Old 02-28-2013, 10:02 AM
Hoyt1134 Hoyt1134 is offline
Registered User
Join Date: Jul 2004
Posts: 18
Hoyt1134 is on a distinguished road
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.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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


All times are GMT +2. The time now is 03:37 PM.


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