Giter Club home page Giter Club logo

Comments (5)

sabrawer avatar sabrawer commented on May 28, 2024 1

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.

CodeYard01 avatar CodeYard01 commented on May 28, 2024 1

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.

sabrawer avatar sabrawer commented on May 28, 2024

NOTE: Actual code has correct indentation and runs.

from pygame.

dantezhu avatar dantezhu commented on May 28, 2024

you may need to wrap your code like this:

your code

from pygame.

CodeYard01 avatar CodeYard01 commented on May 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.