资源简介 第八课:画奥运五环旗学习要点:1.进一步熟悉GraphicsWindow对象的操作和属性。2.进一步熟悉GraphicsWindow窗口的坐标系。教学重难点:教学重点是让学生进一步熟悉GraphicsWindow对象的操作和属性,掌握学习方法,难点是坐标的运算。www.21-cn-jy.com一、画几何图形:? ? ? 画奥运五环旗需要在不同的位置画不同颜色的圆,因此首先要掌握如何画彩色的圆,然后学习如何计算所画圆的位置。2·1·c·n·j·y1.GraphicsWindow对象中画几何图形的各种操作:例如:GraphicsWindow.DrawEllipse(0,0,60,60) 画圆GraphicsWindow.FillEllipse(0,0,60,60) 画实心圆GraphicsWindow.DrawRectangle(0,0,60,60) 画正方形GraphicsWindow.FillRectangle(0,0,60,60) 画实心正方形GraphicsWindow.DrawRectangle(60,60,100,60) 画矩形框GraphicsWindow.FillRectangle(160,120,100,60) 画实心矩形【来源:21·世纪·教育·网】GraphicsWindow.DrawTriangle(0,0,60,20,30,80) 画三角形GraphicsWindow.FillTriangle(0,0,60,20,30,80) 画实心三角形21·世纪*教育网2、GraphicsWindow对象中,用改变图形的颜色或笔的颜色、粗细backgroundcolor ? ? 背景颜色brushcolor ? ? ? ? ? ? ? ?刷子的颜色pencolor ? ? ? ? ? ? ? ? ? 画笔的颜色penwidth ? ? ? ? ? ? ? ? ? 画笔的宽度几何图形的边框颜色,用PenColor属性来设置,例如:GraphicsWindow.PenColor ="Red" 将画笔设置为红色www-2-1-cnjy-com如果画实心几何图形,用BrushColor属性来设置颜色,例如:GraphicsWindow.BrushColor="Green" 将刷子设置为绿色2-1-c-n-j-y二、画奥运五环旗? ? ? ? 从下图可以看出,最左边的蓝色圆的坐标是(x,y),那么黑色圆的坐标是(x+d+g,y),那么黄色圆的坐标是(x+d/2+g/2,y+d/2),红色圆的坐标是(x+2d+2g,y),绿色圆的坐标是(x+1.5*d+1.5*g,y+d/2)21*cnjy*com图8-1 奥运五环旗的尺寸关系图:d=120g=20x=50y=50GraphicsWindow .PenWidth =12GraphicsWindow .BackgroundColor ="white"GraphicsWindow .PenColor ="blue"GraphicsWindow .DrawEllipse (x,y ,d ,d )GraphicsWindow .PenColor ="black"GraphicsWindow .DrawEllipse (x+d+g,y,d,d)GraphicsWindow .PenColor ="red"GraphicsWindow .DrawEllipse (x+2*d+2*g,y,d,d)GraphicsWindow .PenColor ="yellow"GraphicsWindow .DrawEllipse (x+d/2+g/2,y+d/2,d,d)GraphicsWindow .PenColor ="green"GraphicsWindow .DrawEllipse (x+1.5*d+1.5*g,y+d/2,d,d)21世纪教育网版权所有三、练习:? ? ? ?编写程序,画带橙色旗杆的奥运五环旗分析:为了让程序能画出不同大小的五环旗,程序中的圆的直径、圆之间的间隙、位置等应该用变量来表示。程序如下:d=60g=10x=160y=50GraphicsWindow.PenWidth =5GraphicsWindow.BackgroundColor ="black"GraphicsWindow.BrushColor="white"GraphicsWindow.FillRectangle(x-g,y-2*g,3*d+4*g,4*g+d+d/2)21教育网GraphicsWindow.BrushColor="orange"GraphicsWindow.FillRectangle(x-g-g/2,y-2*g,g/2,(4*g+d+d/2)*2)21·cn·jy·comGraphicsWindow.PenColor ="blue"GraphicsWindow.DrawEllipse (x,y,d,d )GraphicsWindow.PenColor ="black"GraphicsWindow.DrawEllipse (x+d+g,y,d,d)GraphicsWindow.PenColor ="red"GraphicsWindow.DrawEllipse (x+2*d+2*g,y,d,d)GraphicsWindow.PenColor ="yellow"GraphicsWindow.DrawEllipse (x+d/2+g/2,y+d/2,d,d)GraphicsWindow.PenColor ="green"GraphicsWindow.DrawEllipse (x+1.5*d+1.5*g,y+d/2,d,d)21cnjy.com 展开更多...... 收起↑ 资源预览