Download JES Tool JES: Jython Environment for Students Python development tool developed by Georgia...
-
Upload
brice-wilkinson -
Category
Documents
-
view
215 -
download
0
Transcript of Download JES Tool JES: Jython Environment for Students Python development tool developed by Georgia...
Download JES Tool JES: Jython Environment for Students
Python development tool developed by Georgia Tech
Download and install JES at C:/100 From
https://github.com/gatech-csl/jes/releases,
Select jes-5.010-windows-java-included.zip
And select “Save As” to download to C:/100
Download JES Tool Right-click on the zip file, select 7-
zip, and select ‘Extract Here.’
Create a new folder pics under C:\100 Download www.cs.uml.edu/~kim/100/pics.zip Save into C:\100\pics Right click and select 7-zip &‘Extract here.”
Under C:\100, you should have C:\100\JES.exe C:\100\pics (folder)
Download media files
JES IDE (Integrated Development Environment) Incorporates editing
environment Program pane Command pane Watcher button to
view debugging
Python/JES
Picture Functions in JES
pickAFile() opens a file browser to select a file
makePicture(filename) creates and returns a picture object, from the JPEG file at the filename
show(pic) displays a picture in a window
repaint(picture) to re-display after changing it
FileImage()
pic.draw()
How to access a Picture in JES ?
Select a picture file For example,
myFile = pickAFile() WARNING: picture file (eiffel.jpg) is NOT
a picture
A picture file HAS TO BE converted to a picture object
myPic = makePicture(myFile)
Or, myPic = makePicture(pickAFile())
• getPixel(pic,x,y) to get a single pixel ----- pic.getPixelt(x,y)
• getRed, getGreen, and getBlue are functions that • return a color value (between 0 and 255) at
a specified pixel• setRed, setGreen, and setBlue are functions
that• set its color value at a specified pixel
• We can also get, set, and make colors• getColor returns a Color object with three color
values at a pixel • setColor sets the pixel to the specified color• makeColor returns a Color object with specified
three color values• pickAColor lets you use a color chooser and
returns the chosen color
Other Pixel Functions
Example>>> thisPixel = getPixel(myPic,1,1)>>> print thisPixelPixel, color=color r=168 g=131
b=105
# get/set individual color values>>> print getRed(thisPixel)168>>> setRed(thisPixel,255)>>> print getRed(thisPixel)255>>> color=getColor(thisPixel)>>> print colorcolor r=255 g=131 b=105>>> setColor(thisPixel,color)
Example
>>> newColor=makeColor(0,100,0)>>> print newColorcolor r=0 g=100 b=0>>> setColor(thisPixel,newColor)>>> print getColor(thisPixel)color r=0 g=100 b=0>>> print colorcolor r=168 g=131 b=105>>> print makeDarker(color)color r=117 g=91 b=73>>> print colorcolor r=117 g=91 b=73>>> newcolor=pickAColor()>>> print newcolorcolor r=255 g=51 b=51
Change Colors Directly
>>> file=pickAFile()>>> pict=makePicture(file)>>> show(pict)>>> setColor(getPixel(pict,10,100),black)>>> setColor(getPixel(pict,11,100),black)>>> setColor(getPixel(pict,12,100),black)>>> setColor(getPixel(pict,13,100),black)>>> repaint(pict)
• Draw a horizontal line of 100 pixel from (20,50) in a picture
• Write a Python function hLine(pic, len) to draw a horizontal line of length ‘len’ from (20,50) of a picture ‘pic.’
• Write a Python function diag(pic, len, tx,ty) to draw a diagonal line of length ‘len’ starting at location (tx,ty)
LAB