Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement CGContext #102

Open
ephemer opened this issue Oct 30, 2017 · 4 comments
Open

Implement CGContext #102

ephemer opened this issue Oct 30, 2017 · 4 comments

Comments

@ephemer
Copy link
Member

ephemer commented Oct 30, 2017

CGContext is a drawing canvas. We can use it to render fonts, convert 32bit PNGs to 8bit Alpha maps etc.

Implementation

The easiest method available to us is to make CGContext a thin wrapper over SDLSurface - both have similar initialisers, properties, and methods. And a SDLSurface can be easily converted to a CGImage (as can a CGContext). If we need more advanced drawing capabilities (rounded circles etc) we can use (lib) Cairo to draw on the SDLSurface internally.

This work has been done in Cacao: https://github.com/PureSwift/Cacao. @colemancda has indicated to us that it'd be fine to use the implementation he implemented using Cairo, we "just" need to build Cairo for Android and adapt his internal UIKit code to match our structures.

@colemancda
Copy link

The actual code is here: https://github.com/PureSwift/Silica CoreGraphics is actually one of the really solid parts of the Cacao project. You need the get Cairo compiling via the SwiftPM or an Android binary.

@3d4m-volodymyr
Copy link

Alternatively, you can use skia for 2D. It is pretty close to CGContext from my experience.

@colemancda
Copy link

Great, how to you use C++ Skia from Swift? Is there a wrapper library somewhere? I would love to use Skia and Swift on Linux and Android.

@3d4m-volodymyr
Copy link

3d4m-volodymyr commented Aug 12, 2021

Yea, for some features it will require writing a thin layer to make C APIs. :)
Some APIs are available as C.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants