[SOLVED] Drawing a simple rectangle in c#

PointF basePosition = new PointF(0f, 0f);
SizeF healthRectSize = new SizeF(1800f, 1002f);
Color healthRectColor = Color.FromArgb(0, 255, 0, 0);
healthRect = new Rectangle(basePosition, healthRectSize, healthRectColor);
healthRect.Enabled = true;
healthRect.Draw();

Yields nothing, no matter what i do with it.

Someone with more knowledge in this would be very helpful ;-;

I think you’re setting the alpha to 0, making it invisible. Heres a rectanglethat works:

new Rectangle(new PointF(.5f, .5f), new SizeF(.5f,.5f), Color.FromArgb(250,250,50,50),false).Draw();

If that works it’s because the F values i used aren’t between 0 and 1 i am guessing?

Hmm… not working either. I am putting this in the onspawn function so i should atleast see it for a second, or is each frame by frame?

This is one frame, put it in a loop

I tried placing it in the Tick event delegate but, that didn’t work either.

Placed it in a while loop, but that locked up the client.

private async Task OnTick() {
    new Rectangle(new PointF(.5f, .5f), new SizeF(.5f,.5f), Color.FromArgb(250,250,50,50),false).Draw();
}

If you put a while(true ) loop in there it will never exit. use the above to draw once each frame

Yea, that’s what I tried. For some reason it didn’t draw. Heading to bed though, will poke around with this again tomorrow.

Drawing using REctangle.draw isn’t working for me at all now… Just use the native:
DrawRect(.5f,.5f,.02f,.02f,50,250,50,200);

Hmm, doesn’t seem to exist?

What class is that function under?

CitizenFX.Core.Native.API.DrawRect

Oookay i think I’m just an idiot. I found the API under the class. Testing now.

THERE IT IS. Jesus, this was a headache.

Thanks for your help lito!