Click here to Skip to main content
15,889,200 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
Hello, I ve been googling for hours. Please help me! Im having trouble with real time rectangle drawing, Let's say 1st second I want to draw y1 to positive heigth, in 2nd second y1 to negative heigth. But DrawRectangle doesn't except negative values and doesn't draw. I show in drtail in picture please help!

What I have tried:

I have tried giving negative values to DrawRectangle but not working
Posted
Updated 30-Aug-19 21:13pm
Comments
[no name] 7-Dec-16 12:24pm    
Probably mostly because rectangles can't have a negative height. Whatever you are doing doesn't make any sense.
[no name] 7-Dec-16 19:04pm    
Real time? Drawing a rectangle is always real time. Unless you provide your code and explain better nobody will be able to help.

It would seem kind of obvious to just check to make sure the height is greater than 0 before drawing the rectangle.
 
Share this answer
 
Comments
kursatdemir58 7-Dec-16 16:20pm    
My goal is, drawing towards opposite site.
Dave Kreskowiak 7-Dec-16 16:29pm    
And exactly what do you mean by "drawing towards opposite site (side?)"?

If you want drawing to actually work with negative numbers, you're going to have to write your own drawing code to translate those negative numbers into something meaningful on a Cartesian coordinate system.
I made this function to sort the rectangle so that it will draw.

private Rectangle SortedRect(Point P, Size S)
{
if (S.Width < 0)
{
S.Width = -S.Width;
P.X = P.X - S.Width;
}
if (S.Height < 0)
{
S.Height = -S.Height;
P.Y = P.Y - S.Height;
}
return new Rectangle(P, S);
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900