- Tip & Tech
- Code Snippet
- Tizen Projects
- Tip & Tech
- Code Snippet
- Tizen Projects
SkiaSharp in Tizen .NET Applications
Cross-platform apps are popular for many years as it is usually cost-effective, easy to deploy, and supports code reusability. However, some projects challenge you with UI designs. This challenge is solved by toolkit like Xamarin.Forms. However, earlier this toolkit was not well versed with cross-platform graphics APIs. To create some interesting graphics across the platform, first, you need to code using the native APIs of your platform. Then, to render the logic across platforms, you need to create abstraction layers and create a call sequence. This whole process is interesting, however, this is a hideous task when you are not satisfied with your creativity or when you need to bring in complex graphics or more ideas with gradients, textures, and so on across platforms.
Later, Xamarin.Forms collaborated with something different to help you solve this issue and that is SkiaSharp. SkiaSharp is based on Google’s Skia library, a cross-platform 2D graphics API for .NET platforms. The amalgamation of Xamarin.Forms and SkiaSharp is fascinating.
Something refreshing about SkiaSharp is that you can create custom controls very easily by drawing it on a UI canvas. It can be used for mobile apps, desktop apps, and so on to render images. SkiaSharp library provides Xamarin bindings to Skia API and is available for all platforms. The interesting part is that every event you code with this API quickly appears on your canvas. Don’t you feel artistic? How about using SkiaSharp in Tizen .NET apps.
Before going into Tizen .NET apps, let’s see what is in the store for us in SkiaSharp.
The best part of SkiaSharp is that you will have a canvas of your own when you start designing — not joking!
SkiaSharp has its on canvas, SKCanvas property that helps you to showcase your creativity.
Following are the main properties of SkiaSharp:
These properties will come handy when you start drawing. Whenever you call the SkiaSharp API, the result appears on your canvas and you can visualize your creativity. To visualize the same, you need an extension library, Views. There are two types of views:
If you are a beginner with SkiaSharp, it is recommended to start with the canvas view.
When you start drawing, a PaintSurface event is triggered. Here, you can also use the OnPaintSurface method or a handler of the PaintSurface event. To proceed with, you have SKPaint class that helps you with color, style, blur, and so on. To create complex shapes like line segments, quadratic curves, cubic curves, and so on, you have the SKPath class. For more artistic features, you have SKShader that specifies the source color for what is being drawn.
You also have a coordinate system with SKPoint, SKRect, SKRegion, and so on.
Now, you know what all are there. To start drawing, follow these guidelines:
Let’s see how to use SkiaSharp in Tizen .NET apps.
How to use SkiaSharp in Tizen .NET apps
Before beginning to draw anything with SkiaSharp, you need the following directives of SkiaSharp:
To change the target framework of your app, open your project file (.csproj) and change `netcoreapp2.0` to `Tizen5.5`:
You can use your respective Tizen version.
To work with SkiaSharp in Tizen .NET apps, you need to install SkiaSharp.Views.Forms:
2. Select the Browser tab and choose nugget.org as the package source.
3. In the search bar, enter SkiaSharp and select SkiaSharp.Views from the result and click Install.
3. Create a basic Tizen .NET UI application.
In the Tizen .NET UI application, you can use SkiaSharp for shapes, text, images, and so on.
Draw a text with SkiaSharp
SkiaSharp can be used according to your requirements.
Let’s see how to use SkiaSharp commands to draw a simple text, SkiaSharp in Tizen .NET.
Here you are! Ready with the basics. Now, you can try more complex graphics using the samples available.
It is said that you don’t have to re-invent the wheel, so don’t re-invent but be different and creative in what you are doing. I found a way to be different while creating user controls using SkiaSharp.
It is good to play around with the technical tools of the trade and its design fundamentals when you are learning something new. So, try SkiaSharp and its amazing features using Tizen .NET and enjoy the powerful APIs.
Let's bring life to designs!
BY Annie Abraham
24 Sep 2021
Tizen Studio, Tizen .NET Application
BY Rishu Mehra
30 Jun 2020
Tizen .NET, Tizen Studio, Tizen
BY Reni Mathew
29 Apr 2020
Tizen .NET Application, Tizen .NET