Color Values in Python?
04-21-2021, 02:23 PM
Post: #6
 toml_12953 Senior Member Posts: 2,040 Joined: Dec 2013
RE: Color Values in Python?
(04-21-2021 09:03 AM)critor Wrote:
Code:
hpprime.eval("rgb(0,255,0)")
No crash here.

I get "OverflowError: overflow converting long int to machine word" in this line (line 22 in the code). If I replace the eval with a number, I get no error.

pixon(0,x1,230-y1,eval("rgb(0,255,0)"))

Code:
#PYTHON EXPORT pyhat from hpprime import * from math import * t0 = eval("ticks()") # Save the current clock count for timing program # Clear screen fillrect(0,0,0,320,240,0,0) # Start program proper p=160; q=120 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+1):   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(0,x1,230-y1,eval("rgb(0,255,0)"))       if y1!=0:         line(0,x1,230-y1+1,x1,230,0) # Erase points below current point t = eval("ticks()")-t0 # Wait for key and print elapsed time eval("wait()") t = t/1000 print(t," seconds") #end

Tom L
Cui bono?
 « Next Oldest | Next Newest »

 Messages In This Thread Color Values in Python? - toml_12953 - 04-21-2021, 12:23 AM RE: Color Values in Python? - critor - 04-21-2021, 07:01 AM RE: Color Values in Python? - cyrille de brĂ©bisson - 04-21-2021, 07:23 AM RE: Color Values in Python? - toml_12953 - 04-21-2021, 07:49 AM RE: Color Values in Python? - critor - 04-21-2021, 09:03 AM RE: Color Values in Python? - toml_12953 - 04-21-2021 02:23 PM RE: Color Values in Python? - cyrille de brĂ©bisson - 04-22-2021, 08:41 AM RE: Color Values in Python? - toml_12953 - 04-22-2021, 01:26 PM

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