# compatibility with Casio fx-CG / USB Power Graphic 3 from casioplot import get_pixel, set_pixel, draw_string, show_screen, clear_screen try: from ppn_all import * ppn_w, ppn_h, ppn_need_show = 384, 192, True # for TI-83P/84+ CE scripts ppn_conf_ce = [(0, 0, 0), 1, (1, 1), 30] def getPixel(x, y): return getPixel(x, y - ppn_conf_ce[3]) def setPixel(x, y, c): setPixel(x, y - ppn_conf_ce[3], c) def setPen(s, t): s, t = int(s), int(t) ppn_conf_ce[1], ppn_conf_ce[2] = (s < 0 or s > 3) and 2 or s, t == 0 and (1, 1) or t == 1 and (2, 4) or t == 3 and (1, 4) or (4, 6) def setColor(c): ppn_conf_ce[0] = c def drawLine(x1, y1, x2, y2): x1, y1, x2, y2 = int(x1), int(y1), int(x2), int(y2) if (x2 - x1) ** 2 >= (y2 - y1) ** 2: if min(x1, x2) != x1: x1, y1, x2, y2 = x2, y2, x1, y1 for k in range(x2 - x1 + 1): x = x1 + k if x % (ppn_conf_ce[2][1] * (ppn_conf_ce[1] + 1)) < ppn_conf_ce[2][0] * (ppn_conf_ce[1] + 1): y = int(y1 + (y2 - y1)*k/(x2 - x1)) for i in range(-ppn_conf_ce[1], ppn_conf_ce[1] + 1, 1): set_pixel(x, y + i - ppn_conf_ce[3], ppn_conf_ce[0]) else: if min(y1, y2) != y1: x1, y1, x2, y2 = x2, y2, x1, y1 for k in range(y2 - y1 + 1): y = y1 + k if y % (ppn_conf_ce[2][1] * (ppn_conf_ce[1] + 1)) < ppn_conf_ce[2][0] * (ppn_conf_ce[1] + 1): x = int(x1 + (x2 - x1)*k/(y2 - y1)) for i in range(-ppn_conf_ce[1], ppn_conf_ce[1] + 1, 1): set_pixel(x + i, y - ppn_conf_ce[3], ppn_conf_ce[0]) def drawPolyLine(l): for k in range(len(l) - 1): drawLine(l[k][0], l[k][1], l[k + 1][0], l[k + 1][1]) def drawRect(x, y, w, h): drawLine(x, y, x + w - 1, y) drawLine(x, y + h - 1, x + w - 1, y + h - 1) drawLine(x, y + 1, x, y + h - 2) drawLine(x + w - 1, y + 1, x + w - 1, y + h - 2) def fillRect(x, y, w, h): for i in range(h): for j in range(w): set_pixel(x + j, y + i - ppn_conf_ce[3], ppn_conf_ce[0]) def drawString(s, x, y): draw_string(x, y - ppn_conf_ce[3], s, ppn_conf_ce[0], 'small') cls = clear_screen # for TI-Nspire Ndless scripts def getPx(x, y): return col_lst2int(get_pixel(x, y)) def setPx(x, y, c): set_pixel(x, y, col_int2lst(c)) def fill(c): c = col_int2lst(c) for i in range(ppn_h): for j in range(ppn_w): set_pixel(x + j, y + i, c) display = show_screen # for NumWorks scripts def fill_rect(x, y, w, h, c): for i in range(h): for j in range(w): set_pixel(x + j, y + i, c) def _has_color(): set_pixel(0, 0, (0, 127, 255)) _col = get_pixel(0, 0) return _col[0] != _col[1] or _col[1] != _col[2] ppn_has_color = _has_color() if not ppn_has_color and ppn_w == 384: ppn_w, ppn_h = 128, 64 except: myInternalException('Casio Graph 90/35+E II / fx-CG50 / fx-9750/9860GIII')