- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
SpriteKit 在 GPU 上高效运行。
CoreGraphics 在 CPU 上运行。
我想不出任何 CoreGraphics 可以做而 SpriteKit 做不到的绘图。
鉴于此,您能说出为什么有人可能仍然希望在新应用中更喜欢 CoreGraphics 而不是 SpriteKit 的原因吗?
最佳答案
这不是“非此即彼”的问题,因为他们的能力存在差距。
Core Graphics 可以制作非常复杂的图像,通过具有不同效果和内容的极其复杂的图层构建。但最重要的是,它非常擅长以其他 iOS 框架无法比拟的质量绘制形状和线条。正如苹果所说:
Core Graphics... provides low-level, lightweight 2D rendering with unmatched output fidelity. You use this framework to handle path-based drawing, transformations, color management, offscreen rendering, patterns, gradients and shadings, image data management, image creation, and image masking, as well as PDF document creation, display, and parsing.
https://developer.apple.com/reference/coregraphics
在 SpriteKit 的上下文中,您不会找到 PDF 导出创建、图像创建(纹理创建,是的,但不是图像创建),也不会找到复杂的渐变、颜色管理、复杂的图案、转换和离屏渲染。
同样,你不会在SpriteKit中找到Core Graphics中的那种抗锯齿。
如果你想将你的图像制作作品集成到 UIKit 应用程序中,你最好混合使用 Core Graphics、Core Image 和 Core Animation,而不是尝试使用 SpriteKit 进行此类图像创作和动画制作一个应用程序。
将 SpriteKit 用于可适当受益于将 Sprites 作为主要图形内容的游戏。
例如,您可以为专注于更多动态内容的游戏选择 Core Animation 和 Core Graphics,或者需要比仅从 SpriteKit 获得的更高质量的编程创建内容。或者,您可以使用 Core Graphics 以比从 SKShapeNode 获得的质量更高的质量为 Sprite 制作内容。
所以...类(class)用马。
类(class)基本上是:
A) Sprite 和简单的二维渲染和绘图
B) 各种图形、动态绘图以及对质量和输出类型的更高要求
或
C) 两者兼而有之
关于ios - 使用 CoreGraphics 而不是 SpriteKit 的原因?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41634525/
Xcode 10 更改了搜索头文件的方法。具体来说,它给出了警告: Traditional headermap style is no longer supported; please migrate
我的基于 Objective-C 的项目中有一些 swift 代码文件。 我可以编译它,它们相互配合得很好。 swift 代码可以 导入 CoreGraphics.CGBase 然而,当我在调试swi
我的形状周围有这条线: 问题是,它的厚度显然从 1px 变成了 2px。这是我正在使用的代码: CGContextRef context = UIGraphicsGetCurrentContext()
我有以下代码,似乎唯一使用整行的最后一种颜色......我希望颜色在整个过程中不断变化。有什么想法吗? CGContextSetLineWidth(ctx, 1.0);
我试图在 CG 中获得透明背景,但它总是显示为黑色。 我有以下代码: - (id)initWithFrame:(CGRect)frame { if ((self = [super initWi
我使用以下代码对加载的图像执行一些操作,但我发现在视网膜显示屏上时显示变得模糊 - (UIImage*)createImageSection:(UIImage*)image section:(CGRe
我正在尝试绘制具有2px透明边框的图像: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBFillColor(
我已经使用CoreGraphics绘制了两个四边形(4面)形状的路径。总共有6个点,path1使用前4个点,path2使用后4个点,因此都共享2个点。 代码如下 - (void)drawRect:(C
我正在编写一个左侧有图例的 ViewController(标签和彩色框的垂直列表:Category1:黄色,Category2:gree,Category 3:蓝色,等等......) 用户可以点击列
我的形状周围有这条线: 问题是,它的厚度显然从 1px 变成了 2px。这是我正在使用的代码: CGContextRef context = UIGraphicsGetCurrentContext()
我有一个名为 myView 的 UIView @interface MyView : UIView { UIImage *myPic; NSMutableArray *myDra
我需要帮助来绘制这样的东西: 有人告诉我,灰色背景条和紫色条应该绘制在不同的图层上。然后,表示一本书章节(此 slider 所涉及的内容)的点将位于这两层之上的一层上。 我已经完成了在事件栏上创建渐变
有人可以帮我用 CoreGraphics 绘制一个特定的渐变吗?只要给出线索就足够了。示例代码值得我致以最深的敬意。我需要这个形状: 我尝试了以下代码: -(UIImage *)imageWithGr
我的 CGContext 有一个路径和一个线宽,这在我的 UIView 中绘制了一个漂亮的黑色路径轮廓。 .伟大的。现在我试着给这个笔划上色,虽然 CGContextSetStrokeColorWit
我有一个UIBezierPath,它是一个弧线。我只想在图形上下文中绘制笔划(即圆弧的笔划,不包括连接圆弧终点和起点的线) 完成此操作后,我可以向上下文添加线性渐变,从而有效地在圆弧笔划上绘制渐变。
我正在尝试使用核心图形创建两个矩形路径。当我尝试使用颜色填充路径时,重叠的路径不会填充颜色。 使用的代码是 - (void)drawRect:(CGRect)rect { CGPoint to
编辑:我认为最好的是将代码转换为 CoreAnimation。该代码将如何转换为该方法?我认为问题在于设备 FPS 存在差异。 我一直在为 iOS 搜索自定义进度圈并遇到这个库:https://git
我肯定遗漏了 Core Graphics 上下文的某些部分,无法自行清除。这是我在 Xcode Playground 中的代码 import UIKit class MyView08 : UIView
我不确定是否可以提高图像质量,但以下代码在 PDF 中显示的图像质量非常差。我知道它用于从 View 生成图像的标准代码,但我可以做些什么来指定图像质量或改进它吗? - (void)renderVie
此代码来自 Apple 的 WWDC 2011 session 318 - 深入了解 iOS 性能并使用 CoreGraphics 从服务器托管图像创建缩略图。 CGImageSourceRef sr
我是一名优秀的程序员,十分优秀!