The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Why Doesn't This Python Program Work?
07-25-2024, 04:56 AM (This post was last modified: 07-25-2024 04:57 AM by toml_12953.)
Post: #1
Why Doesn't This Python Program Work?
The following program works when I put it in a PPL wrapper but not from the Python app. In the Python app, it doesn't draw anything, it just prints the elapsed time. I can't figure out why. Can you?

Code:
from hpprime import *
from math import *
from graphic import *
t0=eval("ticks")
set_cartesian(0,0,320,200)
# Clear screen 
fillrect_c(0,0,0,320,200,black,black)
# Start program proper   
p=160; q=100
xp=144; xr=1.5*3.1415927
yp=56; yr=1; zp=64
xf=xr/xp; yf=yp/yr; zf=xr/zp
for zi in range(-q,q):
   if zi>=-zp and zi<=zp:
      zt=zi*xp/zp; zz=zi
      xl=int(.5+sqrt(xp*xp-zt*zt))
      # Draw one cross-section of figure     
      for xi in range(-xl,xl+1):     
         xt=sqrt(xi*xi+zt*zt)*xf; xx=xi
         yy=(sin(xt)+.4*sin(3*xt))*yf
         x1=xx+zz+p      
         y1=yy-zz+q
         pixon_c(0,x1,y1,green)
         if y1!=0:
            line_c(0,x1,y1-1,x1,0,black)
t0 = eval("ticks")-t0
# Wait for key and print elapsed time
eval("wait")
t0 = t0/1000
print()
print(t0," seconds")

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Why Doesn't This Python Program Work? - toml_12953 - 07-25-2024 04:56 AM



User(s) browsing this thread: 3 Guest(s)