static JSValue js_sys_rect_union_ex(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, Bool is_inter)
{
	GF_Rect rc1, rc2;
	Double fval;
	JSValue v;
	int res;
	if (argc<2) return GF_JS_EXCEPTION(ctx);

#define GET_PROP(_obj, _n, _f)\
	_f = 0;\
	v = JS_GetPropertyStr(ctx, _obj, _n);\
	res = JS_ToFloat64(ctx, &fval, v);\
	if (!res) _f = FLT2FIX(fval);\
	JS_FreeValue(ctx, v);\

	GET_PROP(argv[0], "x", rc1.x)
	GET_PROP(argv[0], "y", rc1.y)
	GET_PROP(argv[0], "w", rc1.width)
	GET_PROP(argv[0], "h", rc1.height)
	GET_PROP(argv[1], "x", rc2.x)
	GET_PROP(argv[1], "y", rc2.y)
	GET_PROP(argv[1], "w", rc2.width)
	GET_PROP(argv[1], "h", rc2.height)

#undef GET_PROP

	if (is_inter) {
		gf_rect_intersect(&rc1, &rc2);
	} else {
		gf_rect_union(&rc1, &rc2);
	}
	v = JS_NewObject(ctx);
	JS_SetPropertyStr(ctx, v, "x", JS_NewFloat64(ctx, FIX2FLT(rc1.x) ));
	JS_SetPropertyStr(ctx, v, "y", JS_NewFloat64(ctx, FIX2FLT(rc1.y) ));
	JS_SetPropertyStr(ctx, v, "w", JS_NewFloat64(ctx, FIX2FLT(rc1.width) ));
	JS_SetPropertyStr(ctx, v, "h", JS_NewFloat64(ctx, FIX2FLT(rc1.height) ));
	return v;
static JSValue js_sys_rect_union_ex(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, Bool is_inter)
{
	GF_Rect rc1, rc2;
	Double fval;
	JSValue v;
	int res;
	if (argc<2) return GF_JS_EXCEPTION(ctx);

#define GET_PROP(_obj, _n, _f)\
	_f = 0;\
	v = JS_GetPropertyStr(ctx, _obj, _n);\
	res = JS_ToFloat64(ctx, &fval, v);\
	if (!res) _f = FLT2FIX(fval);\
	JS_FreeValue(ctx, v);\

	GET_PROP(argv[0], "x", rc1.x)
	GET_PROP(argv[0], "y", rc1.y)
	GET_PROP(argv[0], "w", rc1.width)
	GET_PROP(argv[0], "h", rc1.height)
	GET_PROP(argv[1], "x", rc2.x)
	GET_PROP(argv[1], "y", rc2.y)
	GET_PROP(argv[1], "w", rc2.width)
	GET_PROP(argv[1], "h", rc2.height)

#undef GET_PROP

	if (is_inter) {
		gf_rect_intersect(&rc1, &rc2);
	} else {
		gf_rect_union(&rc1, &rc2);
	}
	v = JS_NewObject(ctx);
	JS_SetPropertyStr(ctx, v, "x", JS_NewFloat64(ctx, FIX2FLT(rc1.x) ));
	JS_SetPropertyStr(ctx, v, "y", JS_NewFloat64(ctx, FIX2FLT(rc1.y) ));
	JS_SetPropertyStr(ctx, v, "w", JS_NewFloat64(ctx, FIX2FLT(rc1.width) ));
	JS_SetPropertyStr(ctx, v, "h", JS_NewFloat64(ctx, FIX2FLT(rc1.height) ));
	return v;