Getting Started
First import the library with:
After importing you can create a phanim screen as follows:
This will use the device screen resolution. We can also change some of the screen parameters.Now we can create something to render on the screen. In this example we will create a simple grid, but the possibilities are endless.
grid = phanim.Grid(1,1,10,10) #This creates a grid with each line seperated by 1, and 10 lines to each side of the origin.
Now we can add some wait time and animate the grid being added to the screen by:
myScreen.wait(60) #This will add an empty animation for 60 frames or 1 seconds.
myScreen.play(Create(grid))
Then add this function to the updater list and run the script:
Make sure you only add the .run() command once at the very end of your script. We can also add some dotted lines to track the mouse position like this:lines = DottedLine(),DottedLine()
def setLines(screen):
lines[0].setEnds([screen.LocalCursorPosition[0],0],screen.LocalCursorPosition)
lines[1].setEnds([0,screen.LocalCursorPosition[1]],screen.LocalCursorPosition)
myScreen.play(Create(lines[0]),Create(lines[1]))
myScreen.addUpdater(setLines)
After combining the update functions the final script will look like this:
from phanim import *
myScreen = Screen(fullscreen=True)
grid = Grid(1,1,10,10)
arrow =Arrow(color=color.blue)
lines = DottedLine(),DottedLine()
def update(screen):
arrow.setDirection([0,0],screen.LocalCursorPosition)
lines[0].setEnds([screen.LocalCursorPosition[0],0],screen.LocalCursorPosition)
lines[1].setEnds([0,screen.LocalCursorPosition[1]],screen.LocalCursorPosition)
myScreen.addUpdater(update)
myScreen.wait(60)
myScreen.play(Create(grid))
myScreen.play(Create(arrow))
myScreen.play(Create(lines[0]),Create(lines[1]))
myScreen.run()