Is there any way to export as a SVG on Konva - konvajs

In my project I am using konvajs. Is there any way to export as a SVG image ?

Konva doesn't have an API to export a stage into SVG. The only way around is to make your own SVG-to-konva and konva-to-SVG converter.

You can generate an svg by using the canvas2svg package and tying it into the underlying canvas reference.
You can set your Layer's context equal to a c2s instance, rendering it, and resetting your Layer's ref to what it was previously, as shown here.

Related

Can you fill a shape with a canvas

I would like to be able to fill a shape with a canvas; potentially to have one konva canvas generate an animation and update another konva canvas shape with it, masked inside a path. Is this possible?
Its not totally clear what you actually want to do, but what you describe is probably achievable with Konva layers. You see Konva is a wrapper for HTML5 canvas and one of its features is layers - so you have one Konva instance that must have a minimum of one layer but can have more. Konva cunningly uses a separate HTML5 canvas for each layer. See the example here in the Konva docs. If you hit F12 you can see the two canvas elements used, and there is a code sample too.
This gives a lot of power and some great performance management potential. And it is all baked in to Konva already so you will not have to manage multiple canvas instances in your own code.

How to draw Multi-styled text using Konva?

I am now using KonvaJS.
I know Text draws text. But it accepts only one style.
Here's my code to render text.
And I want to make Konva color to red and others green.
You can do live coding here
Currently, that is not possible with Konva. To resolve your issue you can:
Use several instances of Konva.Text with different styles
Use custom Konva.Shape and draw all text manually with native canvas access

Add konva js into existing canvas

Is it possible to add konva js into existing canvas?
the canvas class is "custom" and it does not have an id is it possible to initiate Konva stage directly into a canvas instead of a container?
At the current moment (v1.1.8) Konva doesn't support this a use case. You can't use Konva with the existing canvas element.
You can use it only with <div> container.

Have to develop the component shown in below image

Need to develop the component shown in the image above using Objective-C language. No idea where to start and which framework to use. Any heads up/reference links to develop this component is highly appreciated.
Use a combination of UIBezierPaths with custom fill colors. You can either use a shape layer or core graphics. Bezier path allows you to construct a custom path, so the first one will be a triangle, and the second a quadrilateral.
You could also use paint code if you want to construct the path visually.
Look at this
https://www.raywenderlich.com/76433/how-to-make-a-custom-control-swift
It's a very general way to create whatever control you want.

How to work with non-visible TImage32

I try to make use of a TImage32 to combine several layers with positions and transparency etc. So I create in runtime a TImage32, set parent to nil, load from file a bitmap and load from file a layer on top of that bitmap. Now I want to save the result, but I seem to be unable to find where the actual result is. If I do the same with creating the TImage32 in designtime, make it visible, the result of the combined bitmaps is in the Buffer field of TImage32, and I can save the result using Image32.Buffer.SaveToFile('test.bmp'). If the component is not visible, the Buffer is an empty bitmap and the combined bitmap seem to be not created.
Can someone shed light on this? How do I combine bitmaps with GR32, save them, but with invisible components?
Thanks a lot!
Willem
You don't need to use visual controls like TImage.
The library you're using graphics32 has all the methods you need.
Use TBitmap32: The Bitmap can be displayed and scaled using its DrawMode, MasterAlpha and StretchFilter properties.
You simply use the MyBitmap.LoadFromFile method to get it.
I suggest you then store your bitmaps in a TObjectList.
Combine them using TBitmap32.Draw{To}, note that you can use the DrawMode to modify the behavior of Draw.
And use the SaveToFile method as usual when done manipulating the bitmap.

Resources