258-MyroGraphicsImProcProgramming

258-MyroGraphicsImProcProgramming - Drawing and Image...

Info iconThis preview shows pages 1–14. Sign up to view the full content.

View Full Document Right Arrow Icon
Drawing and Image Processing in Python with Myro Graphics Dr. Paige H. Meeker
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
What can Python do without the Robots? We can use Python to control the robots We can also use Python to create some interesting drawings! http://wiki.roboteducation.org/Myro_Reference_Manual
Background image of page 2
Changing Colors Python uses the RGB Color model. That stands for red, green, and blue The range for each color is 0-255.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Changing Colors To create a new color value, assign an identifier to a new color: redColor = color_rgb(255,0,0) There are 256 different shades for each of the three colors. Combinations of these shades will allow you millions of color choices. For a list of several of the RGB colors, visit: http://www.tayloredmktg.com/rgb/ Alternatively, you can use Google with "rgb color codes" as a search parameter
Background image of page 4
Drawing To draw things, we need a window. We create it with: myWin = GraphWin(title, width, height) (remember, myWin is a variable name – it can be anything you want it to be.) After creating the window, you can do several things to it: myWin.setBackground(color) myWin.close() myWin.isClosed() myWin.getMouse()
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Myro Graphics Objects You can draw lots of things using Myro: Point Oval Circle Rectangle Image Text Line Polygon
Background image of page 6
Point(x,y) myPoint = Point(x,y) Actions you can use on points include: getX() getY() These actions (also called “methods”) will give you back the x and y locations of the point you reference. To use any actions, you use the identifier of the point: myPoint.getX() #For example
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Oval(point1,point2) myOval = Oval(point1,point2) Actions you can use on ovals include: getCenter() getP1() getP2() These actions (also called “methods”) will give you back the x and y locations of the point you reference. To use any actions, you use the identifier of the point: myOval.getCenter() #For example
Background image of page 8
Rectangle(point1,point2) myRectangle = Rectangle(point1,point2) Actions you can use on rectangles include: getCenter() getP1() getP2() These actions (also called “methods”) will give you back the x and y locations of the point you reference. To use any actions, you use the identifier of the point: myRectangle.getCenter() #For example
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Line(point1,point2) myLine = Line(point1,point2) Actions you can use on lines include: getCenter() setArrow("first" / "last" / "both" / "none") getP1() getP2()
Background image of page 10
Circle(centerPoint,radius) myCircle = Circle(centerPoint,radius) Actions you can use on circles include: getCenter() getRadius()
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Polygon(point1, point2, . ..) myPoly = Polygon(p1,p2,p3,…) #list of points Actions you can use on polygons include: getPoints() #Returns a list of points.
Background image of page 12
Text(anchorPoint, string) myText = Text(anchorPoint,string) Actions you can use on text include: setText(string) getText() getAnchor() setFace(family) setSize(point) setStyle('normal'/'bold'/'italic') setTextColor(color)
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 14
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 67

258-MyroGraphicsImProcProgramming - Drawing and Image...

This preview shows document pages 1 - 14. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online