"斜角"在Quartz 2D中的形状 [英] "Beveled" Shapes in Quartz 2D

查看:168
本文介绍了"斜角"在Quartz 2D中的形状的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我熟悉Quartz 2D绘图的一些基础知识,比如绘制基本的形状和渐变等,但我不确定如何用斜面绘制形状,如下所示:

p>

斜圆圈http:// www .shaggyfrog.com / junk / beveled-circle.jpg

基本上,我们在一个角落发光,也许在对角有一些阴影。我想 - 我没有制作这张图片,尽管我希望能够近似它。



任何想法?这是在iPhone上,我想使用内置的框架,并尽可能避免任何外部库。

解决方案

实际上,只有几种有用的方法可以解决这个问题。


  1. 使用您的基本形状绘制技术并将它们与一条或多条渐变曲线相结合。 (隐式对象构造)与曲线/填充。自定义构建一个UIView并在drawRect中构建每个像素的对象。


  2. 预渲染斜面/阴影形状并将它们加载到图像中,并将它们投射到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.

  1. Use your basic shape drawing techniques and combine them with a one or more gradient curves. (Implicit object construction) with curves/fills.

  2. Custom build a UIView and build the object up per-pixel in a drawRect.

  3. Pre-render your beveled/shadowed shapes and load them into an image and blit them into a UIImageView.

这篇关于"斜角"在Quartz 2D中的形状的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆