from Library import GRCGraphics as GRC # define size of graphics window windowWidth = 300 windowHeight = 300 # Define the graphics window object gWindow = GRC.GraphicsWindow("Title of window: Box", windowWidth, windowHeight) def main(): drawBox() def drawBox(): # set boarder Color of box object boarderColor = "Black" # set boarder Color of box object fillColor = "Yellow" # define a polygon object as a box polygon = GRC.Polygon(GRC.Point(10, 10), GRC.Point(125, 10), GRC.Point(125, 125), GRC.Point(10, 125)) polygon.setBoarderColor(boarderColor) polygon.setFillColor(fillColor) # Pass graphic window object to the box object; call draw method. polygon.draw(gWindow)
import random from Library import GRCGraphics as GRC from Library.Examples import nrnoble as Util windowWidth = 502 windowHeight = 268 interval = .1 Color = random.choice(Util.Colors) gWindow1 = GRC.GraphicsWindow("Image Window-1", windowWidth, windowHeight) gWindow2 = GRC.GraphicsWindow("Image Window-2", windowWidth, windowHeight) #background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\bwdock.png") # background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\icecave.png") background2 = GRC.Image(GRC.Point(251, 134), ".\\Content\\blackbackground.png") def main(): filepath = '.\\Content\\randomColors.pkle' #background1.draw(gWindow1) background2.draw(gWindow2) # gWindow1.redraw() # gWindow2.redraw() pixels = [] for y in range(0, windowHeight - 3): for x in range(0, windowWidth): # red, green, blue = background1.getPixel(x,y) red = random.randint(0, 255)
import pickle import random from Examples import nrnoble as Util from Library import GRCGraphics as GRC windowWidth = 502 windowHeight = 268 interval = .1 Color = random.choice(Util.Colors) gWindow1 = GRC.GraphicsWindow("Image Window-1", windowWidth, windowHeight) gWindow2 = GRC.GraphicsWindow("Image Window-2", windowWidth, windowHeight) #background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\bwdock.png") background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\icecave.png") background2 = GRC.Image(GRC.Point(251, 134), ".\\Content\\blackbackground.png") def main(): background1.draw(gWindow1) background2.draw(gWindow2) # gWindow1.redraw() # gWindow2.redraw() pixels = [] for y in range(0, windowHeight - 3): for x in range(0, windowWidth): red, green, blue = background1.getPixel(x, y) rgb = color_rgb(red, green, blue)
import random import time from Library import GRCGraphics as GRC from Library.Examples import nrnoble as Util windowWidth = 300 windowHeight = 300 interval = .1 Color = random.choice(Util.Colors) gWindow = GRC.GraphicsWindow("Text Demo", windowWidth, windowHeight) def main(): then = time.time() #Util.sleep(1) now = time.time() diff = now - then minutes, seconds = int(diff // 60), int(diff % 60) print('Next time you add blood is ' + str(minutes) + ':' + str(seconds)) print('Next time you add blood is ' + str(minutes).zfill(2) + ':' + str(seconds).zfill(2)) myTime1 = time.strptime("30 Nov 00", "%d %b %y") # myTime2 = time.strftime(%M,time.time()) myTime3 = time.strftime("%a %d %b %Y %H:%M:%S +0000", time.gmtime()) myTime3 = time.strftime("%S".zfill(3), time.gmtime()) sec = int(myTime3) print(sec)
def clockHand(endPoint, handWidth, handColor, clockCenter): hourHand = GRC.Line(endPoint, clockCenter) hourHand.setWidth(handWidth) hourHand.setFillColor(handColor) hourHand.setArrow("first") return hourHand
from Library import GRCGraphics as GRC import math win = GRC.GraphicsWindow("test", 500, 500) def main(): #win = GRC.GraphicsWindow("test", 500, 500) p1 = GRC.Point(10, 20) p2 = GRC.Point(10, 200) # myLine = GRC.Line(p1, p2) # myLine.draw(win) # calcPoints(p1,p2) points = get_line([10,10], [20,200]) #print (points) for point in points: print (point) win.plot(point[0], round(point[1]), "Black") line = GRC.Line(p1,p2) win.addItem(line) win.redraw() win.waitForKeyPress() #ListOfPoints(p1,p2) def calcPoints(P1,P2): x1 = P1.x y1 = P1.y
import random from Library import GRCGraphics as GRC from Library.Examples import nrnoble as Util windowWidth = 300 windowHeight = 300 interval = .1 Color = random.choice(Util.Colors) gWindow = GRC.GraphicsWindow("Clock", windowWidth, windowHeight) def main(): line1 = GRC.Line(GRC.Point(10, 10), GRC.Point(20, 10)) gWindow.addItem(line1) gWindow.redraw() Util.sleep(5) line1.move(20, 20) gWindow.redraw() Util.pause(gWindow) def fifteenSeconds(centerPoint, radius): xx = centerPoint.getX() yy = centerPoint.getY() for tick in range(1, 16, 1):
import random import time from Library import GRCGraphics as GRC from Library.Examples import nrnoble as Util windowWidth = 300 windowHeight = 300 interval = 1 Color = random.choice(Util.Colors) gWindow = GRC.GraphicsWindow("Clock", windowWidth, windowHeight) clockCenter = GRC.Point(150, 150) #lineStartPoint = [] #points = [] def main(): circlePoints = pointsOnCircle(150, 150, 100) HourHandcirclePoints = pointsOnCircle(150, 150, 90) minuteHandcirclePoints = pointsOnCircle(150, 150, 95) secondHandEndPoint = circlePoints[0] secondHand = GRC.Line(secondHandEndPoint, clockCenter) gWindow.addItem(secondHand) gWindow.setBackground("Black") for tick in range(0, 360, 6): gWindow.plotPixel(circlePoints[tick].getX(), circlePoints[tick].getY(), "Yellow")
def drawLine(startPoint, endPoint): myLine = GRC.Line(startPoint, endPoint) win.addItem(myLine) GRC.time.sleep(interval) win.redraw() print(startPoint, endPoint)
import random, os, sys, inspect, pickle sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))))) import nrnoble as Util from Library import GRCGraphics as GRC windowWidth = 502 windowHeight = 268 interval = .1 Color = random.choice(Util.Colors) gWindow1 = GRC.GraphicsWindow("Image Window-1", windowWidth, windowHeight) #gWindow2 = GRC.GraphicsWindow("Image Window-2", windowWidth, windowHeight) # background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\bwdock.png") # background2 = GRC.Image(GRC.Point(251, 134), ".\\Content\\blackbackground.png") background2 = GRC.Image(GRC.Point(251, 134), "..\\Content\\randomPixelsbackground3.png") #background2 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\randomPixelsbackground3.png") def main(): # background1.draw(gWindow1) background2.draw(gWindow1) # gWindow1.redraw() # gWindow2.redraw() pixels = []
def main(): p1 = 250 p2 = 250 size = 10 c1 = GRC.Circle(GRC.Point(p1, p2), size) c2 = GRC.Circle(GRC.Point(p1, p2), size) c3 = GRC.Circle(GRC.Point(p1, p2), size) c4 = GRC.Circle(GRC.Point(p1, p2), size) c1.setFillColor("BLACK") c2.setFillColor("RED") c3.setFillColor("GREEN") c4.setFillColor("White") win.addItem(c1) win.addItem(c2) win.addItem(c3) win.addItem(c4) win.redraw() #pause(win) # win.redraw() # win.getMouse() c4.setFillColor("blue") for i in range(1, 22): c1.move(-i, -i) c2.move(-i, i) c3.move(i, -i) c4.move(i, i) win.redraw() #win.getMouse() GRC.time.sleep(.05) myP1 = c1.getCenter() myP2 = c2.getCenter() myP3 = c3.getCenter() myP4 = c4.getCenter() drawLine(myP1, myP2) drawLine(myP2, myP4) drawLine(myP4, myP3) drawLine(myP3, myP1) drawLine(myP3, myP2) drawLine(myP4, myP1) # myLine1 = GRC.Line (myP1,myP2) # win.addItem(myLine1) # GRC.time.sleep(interval) # win.redraw() # print("myLine1") #myLine2 = GRC.Line(myP2, myP4) #win.addItem(myLine2) #GRC.time.sleep(interval) #win.redraw() #print("myLine2") # myLine3 = GRC.Line(myP4, myP3) # win.addItem(myLine3) # GRC.time.sleep(interval) # win.redraw() # print("myLine3") # myLine4 = GRC.Line(myP3, myP1) # win.addItem(myLine4) # GRC.time.sleep(interval) # win.redraw() # print("myLine4") # myLine5 = GRC.Line(myP3, myP2) # win.addItem(myLine5) # GRC.time.sleep(interval) # win.redraw() # print("myLine5") # myLine6 = GRC.Line(myP4, myP1) # win.addItem(myLine6) # GRC.time.sleep(interval) # win.redraw() # print("myLine6") #c.draw(win) #c1.draw(win) #c2.draw(win) win.waitForClick() c2.move(150, 50) pause(win) c2.move(1, 1) pause(win) c2.move(150, 70) pause(win) c2.move(150, 80) pause(win) c2.radius = 30 pause(win) win.close() # Close window when done
import random, os, sys, inspect sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))))) from Library import GRCGraphics as GRC interval = .5 win = GRC.GraphicsWindow("My Circle", 500, 500) def main(): p1 = 250 p2 = 250 size = 10 c1 = GRC.Circle(GRC.Point(p1, p2), size) c2 = GRC.Circle(GRC.Point(p1, p2), size) c3 = GRC.Circle(GRC.Point(p1, p2), size) c4 = GRC.Circle(GRC.Point(p1, p2), size) c1.setFillColor("BLACK") c2.setFillColor("RED") c3.setFillColor("GREEN") c4.setFillColor("White") win.addItem(c1) win.addItem(c2) win.addItem(c3) win.addItem(c4)
from ctypes import windll from tkinter import * import random, os, sys, inspect, pickle sys.path.append (os.path.dirname(os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe()))))) from Library import GRCGraphics as GRC background2 = GRC.Image(GRC.Point(251, 134), "..\\Content\\randomPixelsbackground3.png") root = Tk() def click(event): dc = windll.user32.GetDC(0) rgb = windll.gdi32.GetPixel(dc,event.x_root,event.y_root) r = rgb & 0xff g = (rgb >> 8) & 0xff b = (rgb >> 16) & 0xff print (r,g,b) for i in ['red', 'green', 'blue', 'black', 'white']: Label(root, width=30, background=i).pack() root.bind('<Button-1>', click) root.mainloop()
import random, os, sys, inspect sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))))) from Library import GRCGraphics as GRC Colors = [ 'Red', 'Green', 'Blue', 'White', 'Black', 'Yellow', 'Orange', 'Pink', 'Purple', 'Gold', 'Silver', 'Gray', 'Maroon' ] background1 = GRC.Image(GRC.Point(251, 134), "E:\\Data\\Github\\GRC1\\Content\\icecave.png") reverseX = 1 reverseY = 1 x = 1 y = 1 heightmargin = 5 widethMargin = 5 reverse = 1 def main(): wallBounce() def wallBounce(): windowWidth = 500 windowHeight = 268
import random, os, sys, inspect sys.path.append( os.path.dirname( os.path.dirname( os.path.abspath(inspect.getfile(inspect.currentframe()))))) import nrnoble as Util from Library import GRCGraphics as GRC windowWidth = 300 windowHeight = 300 interval = .1 Color = random.choice(Util.Colors2) gWindow = GRC.GraphicsWindow("Connect The Dots", windowWidth, windowHeight) gWindow.setBackground("black") pixels = [] def main(): for i in range(0, 50): x = random.randint(5, windowWidth - 5) y = random.randint(5, windowHeight - 5) rgb = color_rgb(255, 255, 0) pix = pixel(x, y, rgb) pixels.append(pix) gWindow.plotPixel(x, y, "Red") Util.sleep(1) pix1 = pixels.pop() pix2 = pixels.pop() line = GRC.Line(GRC.Point(pix1.x, pix1.y), GRC.Point(pix2.x, pix2.y)) rndColor = random.choice(Util.Colors2)