0

I have created a dictionary and when I click on rectangle I am increasing the rectangle.
I got the result but the problem is that it is rising from top to down (since pygame create from top to down) and I want to do the opposite. I attached the image. thanks in advance.

data = {'volvi':0,'ley_seca':0,'jamais':0}

amarillo_surf = pygame.Surface([100, data["jamais"]])
amarillo_surf.fill((255, 255, 0))

blue_surf = pygame.Surface([100, data["ley_seca"]])
blue_surf.fill((0, 123, 194))

red_surf = pygame.Surface([100, data["volvi"]])
red_surf.fill((240, 80, 54))
  • where do you increasing the rectangle. You shouls simply change `x, y` after resizing. If you change `width = width+size1`, `height = height+size2` then you should also do `x = x-size1`, `y = y-size2` – furas Jun 02 '22 at 22:20
  • "but the problem is that it is rising from top to down (since pygame create from top to down) and I want to do the opposite" Okay, so *why is this difficult*? Can you think of a mathematical rule that tells you what the coordinates of the rectangle should be? Also, you say you attached an image but I do not see one, and the code shown does not seem to have anything to do with the problem you describe. – Karl Knechtel Jun 02 '22 at 22:22
  • you can also first keep original `bottom, right` - `b = rect.bottom`, `r = rect.right`, next resize it and finally set back original `bottom, right` - `rect.bottom = b`, `rect.right = r`. And the same way you can resize in all direction and keep original `center` - `c = rect.center`, resize rectangle, and set back `rect.center = c` – furas Jun 02 '22 at 22:25

0 Answers0