Skip to content
Advertisement

Draw rectangle on key click

I want to draw a rectangle with a button click , but the problem is with every loop it updates the display , display is filled with a color So the rectangle is only seen for a brief period of time. How to solve this.

JavaScript

Advertisement

Answer

You have to draw the rectangle in the application loop. For example add a new rectangle to a list when g is pressed. Draw each rectangles in the list in the application loop

JavaScript

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement