Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement flash.filters.BevelFilter avm1 built-in #1215

Merged
merged 3 commits into from
Sep 29, 2020

Conversation

CUB3D
Copy link
Contributor

@CUB3D CUB3D commented Sep 23, 2020

Implements flash.filters.BevelFilter (#292)
This also fixes the issue with clone() for filter objects mentioned in my previous pr (#1041)

@CUB3D CUB3D changed the title Implement flash.filters.BevelFilter Implement flash.filters.BevelFilter avm1 built-in Sep 23, 2020
Comment on lines 32 to 41
let highlight_color = args
.get(2)
.unwrap_or(&0xFFFFFF.into())
.coerce_to_i32(activation)?;

let highlight_color_clamped = if highlight_color.is_negative() {
0x1000000 - (highlight_color.abs() % 0x1000000)
} else {
highlight_color % (0x1000000)
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this can just be coerce_to_u32 and then color & 0xffffff


let angle = args
.get(1)
.unwrap_or(&44.9999999772279.into())
Copy link
Member

@Herschel Herschel Sep 23, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if the almost-45 default means the angle is actually stored as radians (in an f32?), and the getters/setters convert to/from degrees, or similar? Not sure, something to keep in mind and maybe test more thoroughly someday.

Comment on lines 54 to 58
let shadow_color_clamped = if shadow_color.is_negative() {
0x1000000 - (shadow_color.abs() % 0x1000000)
} else {
shadow_color % (0x1000000)
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Comment on lines 103 to 114
bevel_filter.set_distance(activation.context.gc_context, distance);
bevel_filter.set_angle(activation.context.gc_context, clamped_angle);
bevel_filter.set_highlight_color(activation.context.gc_context, highlight_color_clamped);
bevel_filter.set_highlight_alpha(activation.context.gc_context, highlight_alpha);
bevel_filter.set_shadow_color(activation.context.gc_context, shadow_color_clamped);
bevel_filter.set_shadow_alpha(activation.context.gc_context, shadow_alpha);
bevel_filter.set_blur_x(activation.context.gc_context, blur_x);
bevel_filter.set_blur_y(activation.context.gc_context, blur_y);
bevel_filter.set_strength(activation.context.gc_context, strength);
bevel_filter.set_quality(activation.context.gc_context, quality);
bevel_filter.set_type(activation.context.gc_context, type_);
bevel_filter.set_knockout(activation.context.gc_context, knockout);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If these setters are going to clamp the values, do we have to do it above too? Seems like we're doing it twice

@Herschel
Copy link
Member

Thank you!

@Herschel Herschel merged commit f0a02f0 into ruffle-rs:master Sep 29, 2020
@CUB3D CUB3D deleted the bevel_filter branch December 24, 2020 21:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants