Beginning with pygame

Hi…to all …today i learnt how to begin with pygame in python

now lets consider getting intensity range of RED,GREEN ,BLUE  inputs from user  and display the resultant colour in window.

 

#! usr/bin/python
#color.py
import pygame
from pygame.locals import *
from sys import exit
 
r=min(255, input("Enter the red colour intensity  :"))
g=min(255, input("enter the green colour intensity : "))
b=min(255, input("enter the blue colour intensity  :"))
screen=pygame.display.set_mode((640,480),0,24)
pygame.display.set_caption("colour testing ")
 
while True:
 for i in pygame.event.get():
  if i.type==QUIT:
   exit()
 screen.fill((r, g, b))
 pygame.display.update()

Run the file by python color.py

Window will appear with the resultant color …

Thats it…enjoy coding with pygame….:) Thanks …..:)

Author: Balaji

Hi..My name is Balaji and i am working as a Senior Software Developer in India. I am interested in Shell scripts, python, erlang , linux kernel .

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: