File indexing completed on 2024-12-15 04:01:12
0001 /* 0002 * SPDX-FileCopyrightText: 2019-2023 Mattia Basaglia <dev@dragon.best> 0003 * 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 */ 0006 0007 #include "point.hpp" 0008 0009 using namespace glaxnimate; 0010 0011 0012 void math::bezier::Point::adjust_handles_from_type() 0013 { 0014 if ( type != math::bezier::PointType::Corner ) 0015 { 0016 math::PolarVector<QPointF> p_in(tan_in - pos); 0017 math::PolarVector<QPointF> p_out(tan_out - pos); 0018 0019 qreal in_angle = (p_in.angle + p_out.angle + pi) / 2; 0020 if ( p_in.angle < p_out.angle ) 0021 in_angle += pi; 0022 p_in.angle = in_angle; 0023 p_out.angle = in_angle + pi; 0024 0025 if ( type == math::bezier::PointType::Symmetrical ) 0026 p_in.length = p_out.length = (p_in.length + p_out.length) / 2; 0027 0028 tan_in = p_in.to_cartesian() + pos; 0029 tan_out = p_out.to_cartesian() + pos; 0030 } 0031 } 0032 0033 void math::bezier::Point::transform(const QTransform& t) 0034 { 0035 pos = t.map(pos); 0036 tan_in = t.map(tan_in); 0037 tan_out = t.map(tan_out); 0038 }