mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:17:45 +00:00
LibPDF: Render cubic bezier curves
The implementation of bezier curves already exists on Gfx, so implementing the PDF rendering of this command is trivial.
This commit is contained in:
parent
fe5c823989
commit
e58165ed7a
1 changed files with 34 additions and 3 deletions
|
@ -225,9 +225,40 @@ RENDERER_HANDLER(path_line)
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
RENDERER_TODO(path_cubic_bezier_curve)
|
RENDERER_HANDLER(path_cubic_bezier_curve)
|
||||||
RENDERER_TODO(path_cubic_bezier_curve_no_first_control)
|
{
|
||||||
RENDERER_TODO(path_cubic_bezier_curve_no_second_control)
|
VERIFY(args.size() == 6);
|
||||||
|
m_current_path.cubic_bezier_curve_to(
|
||||||
|
map(args[0].to_float(), args[1].to_float()),
|
||||||
|
map(args[2].to_float(), args[3].to_float()),
|
||||||
|
map(args[4].to_float(), args[5].to_float()));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
RENDERER_HANDLER(path_cubic_bezier_curve_no_first_control)
|
||||||
|
{
|
||||||
|
VERIFY(args.size() == 4);
|
||||||
|
VERIFY(!m_current_path.segments().is_empty());
|
||||||
|
auto current_point = m_current_path.segments().rbegin()->point();
|
||||||
|
m_current_path.cubic_bezier_curve_to(
|
||||||
|
current_point,
|
||||||
|
map(args[0].to_float(), args[1].to_float()),
|
||||||
|
map(args[2].to_float(), args[3].to_float()));
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
|
RENDERER_HANDLER(path_cubic_bezier_curve_no_second_control)
|
||||||
|
{
|
||||||
|
VERIFY(args.size() == 4);
|
||||||
|
VERIFY(!m_current_path.segments().is_empty());
|
||||||
|
auto first_control_point = map(args[0].to_float(), args[1].to_float());
|
||||||
|
auto second_control_point = map(args[2].to_float(), args[3].to_float());
|
||||||
|
m_current_path.cubic_bezier_curve_to(
|
||||||
|
first_control_point,
|
||||||
|
second_control_point,
|
||||||
|
second_control_point);
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
RENDERER_HANDLER(path_close)
|
RENDERER_HANDLER(path_close)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue