-
Notifications
You must be signed in to change notification settings - Fork 0
/
Write_in_solid_BG.py
71 lines (54 loc) · 1.62 KB
/
Write_in_solid_BG.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# import pygame module in this program
import pygame
# activate the pygame library
# initiate pygame and give permission
# to use pygame's functionality.
pygame.init()
# define the RGB value for white,
# green, blue colour .
white = (255, 255, 255)
green = (0, 255, 0)
blue = (0, 0, 128)
# assigning values to X and Y variable
X = 400
Y = 400
# create the display surface object
# of specific dimension..e(X, Y).
display_surface = pygame.display.set_mode((X, Y ))
# set the pygame window name
pygame.display.set_caption('Show Text')
# create a font object.
# 1st parameter is the font file
# which is present in pygame.
# 2nd parameter is size of the font
font = pygame.font.Font('freesansbold.ttf', 32)
# create a text suface object,
# on which text is drawn on it.
text = font.render('GeeksForGeeks', True, green, blue)
# create a rectangular object for the
# text surface object
textRect = text.get_rect()
# set the center of the rectangular object.
textRect.center = (X // 2, Y // 2)
# infinite loop
while True :
# completely fill the surface object
# with white color
display_surface.fill(white)
# copying the text surface object
# to the display surface object
# at the center coordinate.
display_surface.blit(text, textRect)
# iterate over the list of Event objects
# that was returned by pygame.event.get() method.
for event in pygame.event.get() :
# if event object type is QUIT
# then quitting the pygame
# and program both.
if event.type == pygame.QUIT :
# deactivates the pygame library
pygame.quit()
# quit the program.
quit()
# Draws the surface object to the screen.
pygame.display.update()