Code Monkey home page Code Monkey logo

Comments (1)

olimaticer avatar olimaticer commented on June 30, 2024

Normally NaN and Infinity values should be ignored by default, but on some devices (Android 6) these values trigger crashes in conjunction with arcs.

Solutions:

` private boolean execute_gr_arc() {
GR.BDraw b = createGrObj_start(GR.Type.Arc); // create Graphic Object and get variable
if (b == null) return false;
Var.Val saveVal = mVal;

	if (!isNext(',')) return false;
	int[] ltrb = getArgs4I();
	if (ltrb == null) return false;

	if (!isNext(',')) return false;
	//Double[] angles = getArgsDD();
	//if (angles == null) return false;
	// vv 2018-12-25gt
	if (!evalNumericExpression()) return false;					// get angle
	if (EvalNumericExpressionValue.isNaN())return RunTimeError("Start angle is Not a Number (NaN)");
	if (EvalNumericExpressionValue.isInfinite())return RunTimeError("Start angle is infinite");
	float startAngle = EvalNumericExpressionValue.floatValue();
	if (!isNext(','))				{ return false; }
	if (!evalNumericExpression()) return false;					// get angle
	if (EvalNumericExpressionValue.isNaN())return RunTimeError("Sweep angle is Not a Number (NaN)");
	if (EvalNumericExpressionValue.isInfinite())return RunTimeError("Sweep angle is infinite");
	float sweepAngle = EvalNumericExpressionValue.floatValue();
	// ^^ 2018-12-25gt

	if (!isNext(',') || !evalNumericExpression()) return false;
	int fillMode = EvalNumericExpressionValue.intValue();

	//b.arc(ltrb, (float)angles[0], (float)angles[1], fillMode);
	b.arc(ltrb, startAngle, sweepAngle, fillMode);// 2018-12-25gt

	return createGrObj_finish(b, saveVal);						// store the object and return its index
}

`

` private boolean execute_gr_modify() {
int obj = getObjectNumber("Object Number out of range");
if (obj < 0) return false;
GR.BDraw b = DisplayList.get(obj); // get the object to change
GR.Type type = b.type();

	while (isNext(',')) {
		if (!getStringArg()) return false;						// get the parameter string
		if (!isNext(',')) return false;
		String parm = StringConstant;

		String sVal = "";
		int iVal = 0;
		float fVal = 0.0f;
		if (parm.equals("text")|| parm.toLowerCase().equals("_text")) { // Also to lower case 2017-07-15gt
			if (!getStringArg()) return false;					// get the parameter string
			sVal = StringConstant;
		} else {
			if (!evalNumericExpression()) return false;			// get parameter value
			// vv 2018-12-25gt
			if (EvalNumericExpressionValue.isNaN())return RunTimeError("An numeric argument is Not a Number (NaN)");
			if (EvalNumericExpressionValue.isInfinite())return RunTimeError("An numeric argument is infinite");
			b.angle(EvalNumericExpressionValue.floatValue());
			// ^^ 2018-12-25gt
			fVal = EvalNumericExpressionValue.floatValue();
			iVal = EvalNumericExpressionValue.intValue();
		}

.......
........
`

Gregor

from basic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.