"斜角"在Quartz 2D中的形状 [英] "Beveled" Shapes in Quartz 2D
问题描述
我熟悉Quartz 2D绘图的一些基础知识,比如绘制基本的形状和渐变等,但我不确定如何用斜面绘制形状,如下所示:
p>
斜圆圈http:// www .shaggyfrog.com / junk / beveled-circle.jpg
基本上,我们在一个角落发光,也许在对角有一些阴影。我想 - 我没有制作这张图片,尽管我希望能够近似它。
任何想法?这是在iPhone上,我想使用内置的框架,并尽可能避免任何外部库。
解决方案 实际上,只有几种有用的方法可以解决这个问题。
-
使用您的基本形状绘制技术并将它们与一条或多条渐变曲线相结合。 (隐式对象构造)与曲线/填充。自定义构建一个UIView并在drawRect中构建每个像素的对象。
-
预渲染斜面/阴影形状并将它们加载到图像中,并将它们投射到UIImageView中。
I'm familiar with some of the basics of Quartz 2D drawing, like drawing basic shapes and gradients and so on, but I'm not sure how to draw a shape with a "beveled" look, like this:
beveled circle http://www.shaggyfrog.com/junk/beveled-circle.jpg
Essentially we've got a shine on one corner, and maybe some shading in the opposite corner. I think -- I didn't make this image, although I'd like to be able to approximate it.
Any ideas? This is on the iPhone, and I'd like to use built-in frameworks and avoid any external libraries if at all possible.
There are really only a few useful approaches you can take to this problem.
Use your basic shape drawing techniques and combine them with a one or more gradient curves. (Implicit object construction) with curves/fills.
Custom build a UIView and build the object up per-pixel in a drawRect.
Pre-render your beveled/shadowed shapes and load them into an image and blit them into a UIImageView.
这篇关于"斜角"在Quartz 2D中的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!