Interactive Ink

IOS Sketch Block

Hello, 

I want to integrate Sketch block as in nebo.

Please let me know which which type is using in addBlock and it is supported by Text Document or not?

Currently i am using try self.editorViewController.editor.addBlock(p, type: "Raw Content") but it give me error 

Error while creating package : The operation couldn’t be completed. Error, -[IINKEditor addBlock:type:error:]::365 cannot add a block of type Raw Content

Thanks in advance


Dear Khushbu,


currently, you cannot create a block of "Raw Content" type. When creating a block, it can be of type "Diagram", "Drawing", "Math" and "Text".


In your case, it is likely you should create a Part of type "Raw Content".


Best regards,


Olivier

Dear Olivier,

Want to achieve a block like Sketch as in nebo, how to achieve it. 

Thanks, 

Khushbu

Dear Khushbu,


basically, what you call the Sketch mode is basically a "drawing" block. Basically, when calling the "createPart" function, just set it as "drawing".


Best regards,


Olivier

Dear Olivier,

I don't want conversion on that section. It should be strokes only.

Thanks,

Khushbu

Dear Khushbhu,


indeed, we have an internal stroker that smoothes the stroke rendering.


To prevent from this, you should implement your own stroker. This can be done as follows:

-First, create a stroker that is doing a simple "lineTo"

package com.myscript.iink.example;

import com.myscript.iink.graphics.IPath;
import com.myscript.iink.graphics.IStroker;
import com.myscript.iink.graphics.InkPoint;

public class CustomStroker implements IStroker
{
    @Override
    public boolean isFill() {
        return false;
    }

    @Override
    public void stroke(InkPoint[] input, float width, float pixelSize, IPath output)
    {
        final int count = input.length;

        output.moveTo(input[0].x, input[0].y);

        for(int i=1;i<count;i++)
        {
            output.lineTo(input[i].x,input[i].y);
        }
    }
}


-Then, implement the IStrokerFactory:

package com.myscript.iink.example;

import com.myscript.iink.graphics.IStroker;
import com.myscript.iink.graphics.IStrokerFactory;

public class CustomStrokerFactory implements IStrokerFactory {
    @Override
    public IStroker createStroker() {
        return new CustomStroker();
    }
}


-Last, register it to the renderer in the onCreate function:

    CustomStrokerFactory custStroker = new CustomStrokerFactory();
    renderer.registerStroker("Custom", custStroker);


Best regards,


Olivier

Dear Olivier,

Can 2 packages work in a single project.

If yes, then how? Please let me know.

Thanks,

Khushbu

Dear Khushu Bhawsar,


What do you mean by having 2 packages work in a single project? I am not sure to understand...


Ar you referring to having sub blocks? In that case, you can refer to the following part of the documentation.


If that doesn't help, please provide with more explanation...


Best regards,


Olivier

Dear Olivier,

I mean i want both Conversion and Strokes Content blocks so that i want to ask should i create separate packages for both?

Thanks 

Dear Dear Khushbu,


yes the idea is that you have  2 parts, one for drawing, one for Conversion. You keep the strokes of the drawing part, and you can add these to the editor when setting the "Conversion" part.


Best regards,


Olivier

Login or Signup to post a comment