Math

calculation results layout


How are the calculation results determined, such as the layout, font size, and position relative to the BBox of the original formula? Does the SDK have any APIs that can be used to obtain this information? Can I use it in offscreenEditor?

image


Hello Sid,

For the moment, there are no APIs that let you know anything else than the solved result.

We designed the Offscreen APIs so it was completely up to the integrator to manage its ink, and Offscreen would simply add context (recognition) to it.

That being said, the use-case for solving looks quite valid to us and we will investigate if we can add in the JIIX export of the solver the strokes related to the computed result, so that you would be able to draw it yourself, at the best size and position possible (like in our classic editor).

For the moment, you would need to display the result by getting the position of the `=` sign and display the result as typeset text.

To get the state of our current solver export, you can use the following snippet (for example in the `IOffscreenEditorListener::contentChanged` callback):

blockIds.forEach { blockId ->
    val mathSolver = offscreenEditor?.mathSolverController ?: return@forEach
    if (itemIdHelper?.getBlockType(blockId) == "Math") {
        if (mathSolver.getAvailableActions(blockId).contains("numerical-computation")) {
            val solverJIIX = mathSolver.getActionOutput(blockId, "numerical-computation", MimeType.JIIX)
            Log.d(TAG, "Solver JIIX: $solverJIIX")
        }
    }
}

Let us know if you need further assistance,

Yann from MyScript

Thank you for your answer. I would like to know more about how to determine the display position of the calculation results in onscreen mode?

Hello,

I've checked with the team and there are no "simple" algorithm that I could share. It is a string of decision based on the left hand side (if there are any fraction bar for instance), and the right hand side result. Also, sometimes you'll see that everything is "moved" a little bit in order to insert something like a parenthesis on the left hand side (this won't be possible in offscreen). We'll keep you updated if and when we can come up with directions where to put the result in offscreen but at the moment you'll need to compute this position yourself.

Best regards,

Yann

 

Login or Signup to post a comment