avm1: Implement Matrix.deltaTransformPoint
This commit is contained in:
parent
8baa36e801
commit
8c86434e38
|
@ -358,6 +358,23 @@ fn transform_point<'gc>(
|
|||
Ok(object.into())
|
||||
}
|
||||
|
||||
fn delta_transform_point<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
args: &[Value<'gc>],
|
||||
) -> Result<Value<'gc>, Error<'gc>> {
|
||||
let matrix = object_to_matrix(this, activation)?;
|
||||
let point = value_to_point(
|
||||
args.get(0).unwrap_or(&Value::Undefined).to_owned(),
|
||||
activation,
|
||||
)?;
|
||||
|
||||
let x = point.0 * matrix.a as f64 + point.1 * matrix.c as f64;
|
||||
let y = point.0 * matrix.b as f64 + point.1 * matrix.d as f64;
|
||||
let object = point_to_object((x, y), activation)?;
|
||||
Ok(object.into())
|
||||
}
|
||||
|
||||
fn to_string<'gc>(
|
||||
activation: &mut Activation<'_, 'gc, '_>,
|
||||
this: Object<'gc>,
|
||||
|
@ -481,5 +498,13 @@ pub fn create_proto<'gc>(
|
|||
Some(fn_proto),
|
||||
);
|
||||
|
||||
object.force_set_function(
|
||||
"deltaTransformPoint",
|
||||
delta_transform_point,
|
||||
gc_context,
|
||||
EnumSet::empty(),
|
||||
Some(fn_proto),
|
||||
);
|
||||
|
||||
object.into()
|
||||
}
|
||||
|
|
|
@ -160,3 +160,14 @@ false
|
|||
(x=18, y=23)
|
||||
|
||||
|
||||
/// deltaTransformPoint
|
||||
// matrix = new Matrix(2, 3, 5, 7, 11, 13);
|
||||
(a=2, b=3, c=5, d=7, tx=11, ty=13)
|
||||
|
||||
// matrix.deltaTransformPoint();
|
||||
(x=NaN, y=NaN)
|
||||
|
||||
// matrix.deltaTransformPoint(new Point(1, 1));
|
||||
(x=7, y=10)
|
||||
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue