Created
May 16, 2019 13:31
-
-
Save jsbueno/7e2c980fa25a1eadbfb52a2dbddac373 to your computer and use it in GitHub Desktop.
Example of raw plotting 2d funciton with pygame
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pygame | |
larg, alt = 800, 600 | |
intervalo = -10, 10 | |
fator_y = 1.0 | |
tela = pygame.display.set_mode((larg, alt)) | |
f_x= lambda x:3 * x ** 2 + 2 * x + 4 | |
for x_tela in range(larg): | |
x = (x_tela - (larg / 2) ) / larg * (intervalo[1] - intervalo[0]) + intervalo[0] | |
y = f_x(x) | |
y_tela = alt - int(y * fator_y) | |
tela.set_at((x_tela, y_tela), (255, 255, 255)) | |
pygame.display.flip() | |
input("pressione ENTER para encerrar") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment