{"record":{"id":"a8429ec2bbdec4fe","repo":"Yalantis/uCrop","slug":"cimg-appname-math-parser-cimg-s-function-a8429e","errorCode":null,"errorMessage":"\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'ellipse()': Invalid arguments '%s'. \"","messagePattern":"\"\\[\" cimg_appname \"_math_parser\\] CImg<(.+?)>: Function 'ellipse\\(\\)': Invalid arguments '(.+?)'\\. \"","errorType":"exception","errorClass":"CImgArgumentException","httpStatus":null,"severity":"error","filePath":"ucrop/src/main/jni/CImg.h","lineNumber":26709,"sourceCode":"                    if (i<i_end) {\n                      cimg_forX(color,k) if (i<i_end) color[k] = (T)_mp_arg(i++);\n                      else { color.resize(k,1,1,1,-1); break; }\n                      color.resize(img._spectrum,1,1,1,0,2);\n                    }\n                  }\n                }\n              }\n            }\n          }\n        }\n        if (!is_invalid_arguments) {\n          if (is_outlined) img.draw_ellipse(x0,y0,r1,r2,angle,color._data,opacity,pattern);\n          else img.draw_ellipse(x0,y0,r1,r2,angle,color._data,opacity);\n        } else {\n          CImg<doubleT> args(i_end - 4);\n          cimg_forX(args,k) args[k] = _mp_arg(4 + k);\n          if (ind==~0U)\n            throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'ellipse()': \"\n                                        \"Invalid arguments '%s'. \",\n                                        mp.imgin.pixel_type(),args.value_string()._data);\n          else\n            throw CImgArgumentException(\"[\" cimg_appname \"_math_parser] CImg<%s>: Function 'ellipse()': \"\n                                        \"Invalid arguments '#%u%s%s'. \",\n                                        mp.imgin.pixel_type(),ind,args._width?\",\":\"\",args.value_string()._data);\n        }\n        return cimg::type<double>::nan();\n      }\n\n      static double mp_epoch(_cimg_math_parser& mp) {\n        unsigned int\n          year = (unsigned int)mp.opcode[2]==~0U?~0U:(unsigned int)std::max(_mp_arg(2),1900.),\n          month = (unsigned int)mp.opcode[3]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(3),1.,12.),\n          day = (unsigned int)mp.opcode[4]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(4),1.,31.),\n          hour = (unsigned int)mp.opcode[5]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(5),0.,23.),\n          minute = (unsigned int)mp.opcode[6]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(6),0.,59.),\n          second = (unsigned int)mp.opcode[7]==~0U?~0U:(unsigned int)cimg::cut(_mp_arg(7),0.,60.);","sourceCodeStart":26691,"sourceCodeEnd":26727,"githubUrl":"https://github.com/Yalantis/uCrop/blob/f788b534b48c144edf786c8cddbf0e029e637804/ucrop/src/main/jni/CImg.h#L26691-L26727","documentation":"The math parser's ellipse() function expects either a fixed set of scalar arguments or a valid image index selector. This variant is thrown when no image selector (#ind) was given (ind==~0U) but the argument list does not match any supported ellipse() overload, so the collected extra arguments cannot be dispatched.","triggerScenarios":"Calling ellipse() in a math expression with an argument count or types that match no supported signature (e.g. wrong number of radii/angle/color arguments) without a #index prefix.","commonSituations":"Typos in argument count (missing radius or angle); passing color as multiple scalars beyond the supported arity; porting scripts between CImg versions where ellipse() gained/lost overloads.","solutions":["Check the ellipse() signature in your CImg version and supply the exact expected arguments (x,y,radius1,radius2,angle,color,...).","Add the #image_index selector if you meant to draw on a specific image.","Count the provided arguments — the message echoes them via value_string to spot extras/missing ones.","Update the expression if it was written for a different CImg version with different arity."],"exampleFix":"// before: missing second radius\n ellipse(x,y,r,angle)\n// after\n ellipse(x,y,r1,r2,angle)","handlingStrategy":"validation","validationCode":"// Validate ellipse() argument count against the expected signature before evaluation\nconst ELLIPSE_MIN_ARGS = 5; // x,y,r1,r2,angle\nfunction checkEllipseArgs(args) { if (args.length < ELLIPSE_MIN_ARGS) throw new Error('ellipse() needs at least ' + ELLIPSE_MIN_ARGS + ' args, got ' + args.length); }","typeGuard":"function hasValidEllipseArity(args) { return [5,6,7,8].includes(args.length); }","tryCatchPattern":"try { evalMath(expr); } catch (e) { if (String(e).includes(\"Function 'ellipse()'\") && String(e).includes('Invalid arguments')) { console.error('bad ellipse args:', e.message); fixExpr(); } else throw e; }","preventionTips":["Count ellipse() arguments against the CImg version's documented overloads","Echo arguments in scripts before eval during development","Add a #index selector when drawing to a specific image","Re-verify math expressions after CImg/G'MIC upgrades"],"tags":["cimg","math-parser","ellipse","argument-count"],"backgroundTag":"missing-required-argument","analyzedSha":"f788b534b48c144edf786c8cddbf0e029e637804","analyzedAt":"2026-09-08T08:36:04.887Z","contentChangedAt":"2026-09-08T08:36:04.887Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}