Comments (5)
Thank you. I believe I already understand how to draw a rectangle on a black background, as you describe. However, my program is TRYING TO UNDERSTAND how update(rect) works, and it appears to me (a non-expert) not to be working correctly.
My understanding is that, by updating only the rect area, the displaySurf.fill(white) will only be "executed" (or be effective or applicable) within the rect area being updated. Since that rect area is also being updated by the 2-color rectangle (which comes after (later than) the fill), it presumably should allow the fill to execute only in the rect area, so the entire background (outside the rect area) should remain black.
This is toy code with a purpose. I am new to pygame. (I am trying to use it to make a rather sophisticated 2D drawing program.) So I may not understand how update(rect) is supposed to work. So, yes, there may be a bug in my thinking rather than a bug in the code, but I would certainly like to know which it is.
from pygame.
The issue is likely due to the fact that the pygame.display.update(rect) call updates the entire display surface and not just the specified rectangle. for updating the rectangle area you have to say pygame.display.update() code.
and sorry for my wrong answer i thought you just to create a white background application . if this will help you then comment if not then sorry again plz.
and you can read pygame documentation for getting the detailed explanation over their functions
from pygame.
NOTE: Actual code has correct indentation and runs.
from pygame.
you may need to wrap your code like this:
your code
from pygame.
Hi , @sabrawer
This is not looking like a bug here you done a slight mistake that is only updated the rectangle by 'pygame.display.update(rect)' instead of this you can go for 'pygame.display.update()' for make the background full white and for black background just remove 'displaySurf.fill((255,255,255))' from the code.
I hope this will help you.
from pygame.
Related Issues (20)
- How to prevent pygame loop from crashing when calling an asynchronous machine learning module. HOT 3
- Understanding blit_test.py -> comment of #blend(s, 0, d) = d HOT 1
- Broken link for MacCompile instructions in wiki on Getting Started page
- Broken link for FreeBSD Package in wiki on Getting Started page
- Behavior change in fullscreen behavior on gaining focus
- PyGame completely broken on Raspberry Pi Bullseye Lite with official Raspberry Pi touch LCD
- pygame doesn't read my controller inputs if I'm inside a game or another program HOT 2
- Add support for Python 3.9 & later!! HOT 5
- camlist is flipped
- Unusual error (error: failed to create renderer) when using pygame.SCALED HOT 7
- Blue value in (R, G, B) color selection has no affect HOT 14
- Not very welcoming discord HOT 2
- pygame.freetype.Font.get_metrics returns the third value in tuple 'min_y' a wrong value
- Just ignore this
- Pygame not installing HOT 1
- Window stops responding randomly when display.flip() is called after a sprite.Group is drawn HOT 1
- Missing pygame.FINGERMOTION events
- Pygame module pygame.threads is missing
- .../3.9/lib/python/site-packages/pygame/pygame_icon.tiff: 'No such file or directory'
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pygame.