colors - I need some help drawing coloured squares in a certain order with pygame for python 3.2 -


This is my first post here! I hope this question was not answered before, unfortunately I did not know who I should have searched for ...

This is a university practice where I have a series of intersections To draw a user-defined column one row and color (blue) is gradually lighter, to make things even more complicated, the intersections are also deeper than the rows (in line 0 included) and others The largest class in strange people, Mr. row of each row together, should be gradually lightens the light of the previous row.

I am using Python 1.9 with Python 3.2.

Even I tried so far:

  import pygame rows = int (input ('rows?')) Cols = int (input ( 'Column?') Colourstepblue = 255 / (column * rows) # Defines how light intersections # walk on each pygame.init (screen) = pygame.display.set_mode ((640,480)) screen.fill ((255,255,255) )) In the range (0, rows) for count = 0: for a range (0, cols): if i% 2 == 0: pygame.draw. Rect (screen, (0, 0, (colourstepblue * ((a) * (i + 1)), (one * 30, i * 30, 29, 29)) From: pygame.draw.rect (screen, (0, 0, 255 - (i) * colourstepblue * a), (one * 30, i * 30, 29, 29) count + cols pygame.display.flip ()  
< (Sorry if it says html, then I do not know how to call it a dragon)

It produces the right amount of squares in the correct format.

Does, however I can not get the right to fill colors. I would be grateful for any advice that you can give it to work properly (still it is a practice, so I will not be given the right code, just a tip for setting me in the right direction).

Thanks for any answers and sorry for the long question!

One way is to color them correctly, instead calculate them as you go Can easily do it.

If you are in dragon 2, you have to be careful when split. Make sure that one of the numbers is a dragon, so that the dragon can be rotated in the whole. In addition, you can leave the first parameter in the category This will be less than 0.

  colourstepblue = 255.0 / (cols * rows) color = [x * x for color (color * color in rows) * colourstepblue]  

then , You can slice the list of colors. In odd rows, you can slice the list into reverse. In addition, you should consider more descriptive variable names.

  for line in range (rows): if line% 2 == 0: row_colours = colors [row * rows: (row + 1) * rows] and row_colours = color [(line + 1) * rows: row * rows: -1] For the range (cols) in the cola: # row_colours [col] has the color you want  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

javascript - amcharts makechart not working -

java - Algorithm negotiation fail SSH in Jenkins -