python - Crop Function Jython JES -
Hi trying to create a crop function for the Hi-Geeton environment, what the students have done to me so far.
I am also trying to explain how to shape the canvas will raise the size all new pixels.
Any help
deaf crop (pic, startX, endx, startY, endY): canvas = makeEmptyPicture (source 500 for source, startx, endX) 800): Source in Source (startY, endY): color = getColor (getPixel (pic, sourceX, sourceY)) setColor (GetPixel (canvas, startx, start, color) startY = startY + 1 startX = startX + 1 show ( Canvas)
Try it out:
Note: The resulting canvas size can be obtained from (AndX - StartX) X (ANDY - StartAvai) 0) and \ (Endx & Lt; GetWidth (pic)) and (endY & lt; GetHeight (pic)): # Create a canvas with canvas of the right size = Iapital Picture (AndX - StartX, Endy - Startwave) # Source Xx (StartX, Endx ) Browse the interesting part: source in the source (Start, end): color = getColor (getPixel (pic, sourceX, sourceY)) write # pixels, start with # 0 (= startX (y) - starting field (y)) and getxix (y) set collar (Canvas, Source X - RTX, Sourceari) - startY, Color) Return Canvas Other: # PrintNote Print while passing the wrong boundary ("Error: Bad Crop limit! - Expected [0 .. "+ str (getWidth (pic) -1) +"] x [0. (+ 1) + "]" returns no def main (): file = picfile () photo = makepicture (file) cropped = crop (picture, 50, 150, 50, 180) if (cropped): show (croppick) main () >
give:
...........
......... .......... .................................
........... ..
Output with incorrect parameters: < / P>
& gt; & Gt; & Gt; CropPic = Crop (figure, 50, 500, 50, 180) & gt; & Gt; & Gt; ======= Loading Progam ======= Error: bad crop limit! - Expected [0..258] x [0..193]
Comments
Post a Comment