Variant 1

Let's assume that you've learned a canvas object using Mobile Spy and want to draw on it. In this case use this function:

/**
 * Draws a signature on a canvas
 * @param canvas Object to draw on.
 */
function DrawHelper_DoSignature(/**objectId*/ canvas)
{
	if (!g_mobileWrapper.Connected)
	{
		AppiumDriver.ReconnectSession(true);
	}

	var oinf = _SeSGetObjectInfo(canvas);
	var element = AppiumDriver.FindElementByXPath(oinf.xpath);
	
	Actions.MoveToElement(element, 200, 200).ClickAndHold().MoveByOffset(300,300).Release().Perform();
	Actions.MoveToElement(element, 500, 200).ClickAndHold().MoveByOffset(-300,300).Release().Perform();
	
	return true;
}

It draws a cross sign. Customize Actions lines to draw anything else.

Variant 2

If you know the XPath or use pure Appium API to create tests then the function can be simplified.

/**
 * Draws a signature on a canvas
 * @param canvas Object to draw on.
 */
function DrawHelper_DoSignature(/**string*/ xpath)
{
	if (!g_mobileWrapper.Connected)
	{
		AppiumDriver.ReconnectSession(true);
	}

	var element = AppiumDriver.FindElementByXPath(xpath);
	
	Actions.MoveToElement(element, 200, 200).ClickAndHold().MoveByOffset(300,300).Release().Perform();
	Actions.MoveToElement(element, 500, 200).ClickAndHold().MoveByOffset(-300,300).Release().Perform();
	
	return true;
}

In both variants we use Actions object.

https://rapisedoc.inflectra.com/Libraries/Actions/