Post Reply 
New Casio fx-9860 GIII model
01-21-2022, 03:28 PM (This post was last modified: 01-24-2022 02:11 PM by robve.)
Post: #65
RE: New Casio fx-9860 GIII model
(01-19-2022 08:36 PM)critor Wrote:  If it's for a pause, you can wait for the [AC/ON] key to be pressed :
Code:
def wait_acon_key():
  try:
    while(1):
      pass
  except KeyboardInterrupt:
    pass
But that's all for the time being, there is no getkey()-like function in the fx-CG50 Python.

Thanks for the suggestions.

Here is my line() function to draw lines between two arbitrary points (x1,y1) and (x2,y2) given a color (R,G,B):

Code:
def line(x1,x2,y1,y2,color):
  x1=int(x1)
  x2=int(x2)
  y1=int(y1)
  y2=int(y2)
  dx=x2-x1
  dy=y2-y1
  if abs(dx)>=abs(dy):
    s=1 if x2>x2 else -1
    d=s*dy/dx
    for x in range(x1,x2+s,s)
      set_pixel(x,y1,color)
      y1+=d
  else:
    s=1 if y2>y2 else -1
    d=s*dx/dy
    for y in range(y1,y2+s,s)
      set_pixel(x1,y,color)
      x1+=d

This line() function can be a bit optimized for horizontal and vertical lines (i.e. when d=0), but that does not appear to make a substantial difference.

Casio fx-CG50 program to draw Hitomezashi patterns. Should also work on a Casio 9860GIII when you leave out the color parts:

Code:
from casioplot import *
from random import randint

def wait():
  try:
    while 1:
      pass
  except KeyboardInterrupt:
    pass

def line(x1,x2,y1,y2,color):
  x1=int(x1)
  x2=int(x2)
  y1=int(y1)
  y2=int(y2)
  dx=x2-x1
  dy=y2-y1
  if abs(dx)>=abs(dy):
    s=1 if x2>x2 else -1
    d=s*dy/dx
    for x in range(x1,x2+s,s)
      set_pixel(x,y1,color)
      y1+=d
  else:
    s=1 if y2>y2 else -1
    d=s*dx/dy
    for y in range(y1,y2+s,s)
      set_pixel(x1,y,color)
      x1+=d

def hitomezashi():
  color=(0,0,255)
  while 1:
    s=int(input("s="))
    clear_screen()
    for y in range(0,188,s):
      i=s*randint(0,1)
      for x in range(i,380,2*s):
        line(x,y,x+s,y,color)
    for x in range(0,380,s):
      i=s*randint(0,1)
      for y in range(i,188,2*s):
        line(x,y,x,y+s,color)
    show_screen()
    wait()

hitomezashi()

   

Nice that Casio has Python. But casioplot requires quite some scaffolding to create something useful, making programs quite long.

- Rob

"I count on old friends" -- HP 71B,Prime|Ti VOY200,Nspire CXII CAS|Casio fx-CG50...|Sharp PC-G850,E500,2500,1500,14xx,13xx,12xx...
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New Casio fx-9860 GIII model - Coco - 01-09-2020, 04:34 PM
RE: New Casio fx-9860 GIII model - Hlib - 01-09-2020, 08:02 PM
RE: New Casio fx-9860 GIII model - Coco - 02-02-2020, 04:15 PM
RE: New Casio fx-9860 GIII model - lrdheat - 03-06-2020, 03:22 PM
RE: New Casio fx-9860 GIII model - Dands - 03-08-2020, 04:07 AM
RE: New Casio fx-9860 GIII model - klesl - 03-08-2020, 12:25 PM
RE: New Casio fx-9860 GIII model - lrdheat - 03-10-2020, 05:51 PM
RE: New Casio fx-9860 GIII model - klesl - 05-14-2020, 04:30 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-04-2020, 11:34 PM
RE: New Casio fx-9860 GIII model - pier4r - 10-06-2020, 08:26 PM
RE: New Casio fx-9860 GIII model - vaklaff - 10-11-2020, 06:29 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-15-2020, 03:43 PM
RE: New Casio fx-9860 GIII model - lrdheat - 10-18-2020, 11:26 PM
RE: New Casio fx-9860 GIII model - Druzyek - 10-21-2020, 12:47 AM
RE: New Casio fx-9860 GIII model - DiTBho - 01-01-2021, 01:25 PM
RE: New Casio fx-9860 GIII model - critor - 01-01-2021, 08:37 PM
RE: New Casio fx-9860 GIII model - robve - 01-16-2022, 03:30 PM
RE: New Casio fx-9860 GIII model - critor - 01-19-2022, 08:36 PM
RE: New Casio fx-9860 GIII model - robve - 01-21-2022 03:28 PM



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