Friday, November 13, 2026

Python: Drawing Perspective

Python: Drawing Perspective




The goal: draw lines towards the center (0,0), creating the perspective of looking directly towards a point in the distance.



The script asks for two inputs:

h: the height of the wall

n: the number of lines drawn (half of the wall)



Best results are achieved when n divides in h evenly.



Python: Using Turtle (Numworks)





(h = 100, n = 5)

Code:

from math import *

from turtle import *


# inputs

h=eval(input("height? "))

n=int(input("# of steps? "))


speed(7)


# loop

for i in range(-n,n+1):

  penup()

  y=i*h/n

  goto(-160,y)

  pendown()

  goto(160,-y)


hideturtle()



Python: Using TI-Draw (TI-84 Evo)



(h = 100, n = 5)


Code:

# Math Calculations

from math import *

from ti_draw import *


# 2026-07-20 EWS

# perspective drawing


# inputs

h=eval(input("height? "))

n=int(input("# of steps? "))




# set up screen

clear()

set_window(-160,160,-105,105)


# loop

for i in range(-n,n+1):

  y=i*h/n

  draw_line(-160,y,160,-y)


# show drawing

show_draw()


Enjoy and have a great day,


Eddie


All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.


Symmetric Quartic Equation - Python

Symmetric Quartic Equation - Python Note: The code is programmed with a TI-84 Evo. No modules are used, so the scripts should be adopt...