Python Tkinter canvas oval原理


Ovals, mathematically, are ellipses, including circles as a special case. The ellipse is fit into a rectangle defined by the coordinates (x0, y0) of the top left corner and the coordinates (x1, y1) of the bottom right corner:

 

The oval will coincide with the top and left-hand lines of this box, but will fit just inside the bottom and right-hand sides.

To create an ellipse on a canvas C, use:

    id = C.create_oval ( x0, y0, x1, y1, option, ... )

which returns the object ID of the new oval object on canvas C.

Options for ovals:

fill

The default appearance of ellipse is transparent, and a value of fill="" will select this behavior. You can also set this option to any color and the interior of the ellipse will be filled with that color; see Section 4.3, “Colors”.

outline

The color of the border around the outside of the ellipse. Default is outline="black".

stipple

A bitmap indicating how the interior of the ellipse will be stippled. Default is stipple="", which means a solid color. A typical value would be stipple="gray25". Has no effect unless the fill has been set to some color. See Section 4.7, “Bitmaps”.

tags

The tags to be associated with the object, as a sequence of strings. See Section 6.1.4, “Canvas tags”.

width

Width of the border around the outside of the ellipse. Default is 1 pixel; see Section 4.1, “Dimensions” for possible values. If you set this to zero, the border will not appear. If you set this to zero and make the fill transparent, you can make the entire oval disappear.

 

 

其實,是剛知道畫橢圓的主要原理,根據兩點確定的矩形,然后畫一個唯一的內切的橢圓。也就是實現了兩點確定一個橢圓。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM