Answers for "how to get the screen pixels python"

11

get screen size python

>>> import pyautogui

>>> width, height= pyautogui.size()

>>> print(width)
1366

>>> print(height)
768
Posted by: Guest on July-16-2020
0

turn pixel on display screen python

# Used this for pygame project just for the entry
# turn a specific pixel into another colour on your self made game display
						
change_specific_pixel =  game_Display.set_at((x, y), (255, 255, 255))
											# coords	RGB
  
# e.g. a random star background for a game
import random
starlist = []
for x in range(1, display_width + 1): # iterates all integers between 1 and max width
  for y in range(1, display_height + 1): # ditto with max height
    x = random.randint(1 display_width) # sets random integer to x 
	y = random.randint(1, display_height) # ditto to y
    star = game_Display.set_at((x, y), (255,255,255)) # turns pixel on the position (by cord above) into white
    starlist.append(star) # adds the star to the list above
    if len(starlist) >= 30:
      break # loop ends when 30 stars are saved in the list
#Note: every time the game gets started you'll get a new star formation
#Sensensven
Posted by: Guest on August-06-2020

Code answers related to "how to get the screen pixels python"

Python Answers by Framework

Browse Popular Code Answers by Language