SwiftBlend2D

平台 构建状态
macOS Build Status
Linux Build Status
Windows Build Status

用于 Blend2D 的正在开发中的 Swift 绑定。 这个项目使用了 Blend2D 的原始源代码,并且与 Blend2D 没有任何关联或支持。

有关 Swift 中可用 API 的简要报告,请查看状态页面

要求

Xcode 13.0 / Swift 5.4.3

使用示例

取自示例库中的sample1

let img = BLImage(width: 480, height: 480, format: .prgb32)

// Attach a rendering context into `img`.
let ctx = BLContext(image: img)!

// Clear the image.
ctx.compOp = .sourceCopy
ctx.fillAll()

// Fill some path.
let path = BLPath()

path.moveTo(x: 26, y: 31)
path.cubicTo(x1: 642, y1: 132, x2: 587, y2: -136, x3: 25, y3: 464)
path.cubicTo(x1: 882, y1: 404, x2: 144, y2: 267, x3: 27, y3: 31)

ctx.compOp = .sourceOver
ctx.setFillStyleRgba32(0xFFFFFFFF)
ctx.fillPath(path)

// Detach the rendering context from `img`.
ctx.end()

// Let's use some built-in codecs provided by Blend2D.
let codec = BLImageCodec(builtInCodec: .bmp)

try img.writeToFile("bl-getting-started-1.bmp", codec: codec)

这应该会在当前工作目录中创建一个图像,如下所示

Sample 1

该文件中还有更多示例,可以重现 Blend2D 主页中的每个示例。

许可

SwiftBlend2D 的源代码在 MIT 许可证下分发。

来自 Blend2D 的合并源代码在 zlib 许可证下获得许可。