1

As I have described yesterday (Create an alternative form of questionnaire), I'm trying to create a form of questionnaire in which respondents express their approval by dragging the question into a ring that surrounds it. Since I first wanted to get the layout right, I'm now stuck on drawing a ring that contains color gradients, similar to the picture that I have attached. Does anybody have a suggestion on how I could do that, keeping in mind that I'd like to be able to manipulate the color grading, in order to try out different settings. Also, I wondered if theres an easy way to draw a ring around my text-block. Thanks for any tips and suggestions.

import pygame
import ptext
pygame.init()
screen = pygame.display.set_mode((500, 500))
BG_COLOR = pygame.Color('white')
BG_COLOR2 = pygame.Color('black')
x = 200
y = 220
font = pygame.font.SysFont("myanmarmn", 18)
text = """  I shy away
from crowds 
 and people."""

done = False
while not done:
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            done = True
        elif event.type == pygame.MOUSEMOTION:
            if event.buttons[0]:
                x += event.rel[0]
                y += event.rel[1]

    screen.fill(BG_COLOR)
    ptext.draw(text, (x, y), color = BG_COLOR2)
    pygame.draw.circle(screen, (0,0,0), (250, 250), 230, 20)
    pygame.display.flip()

pygame.quit()
quit()

image of the ring
image of the ring

Rabbid76
  • 202,892
  • 27
  • 131
  • 174
psyph
  • 291
  • 1
  • 10
  • 3
    pygame doesn't have function to draw gradiens. You would have to calculate every pixel and put on surface. And later you can blit this surface on screen around text. Maybe something similar you could create with OpenGL or with external module. – furas Jul 16 '19 at 18:00
  • 1
    Do you really need to draw it with pygame? Can't you load it as an image? – Valentino Jul 17 '19 at 10:24
  • @Valentino I can but I wanted to vary the color grading for which some code would have been more convenient. But now, until further notice I have integrated the picture from above. – psyph Jul 17 '19 at 16:22

0 Answers0