File indexing completed on 2025-02-02 04:11:05

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 "ellipse.hpp"
0008 
0009 GLAXNIMATE_OBJECT_IMPL(glaxnimate::model::Ellipse)
0010 
0011 
0012 QIcon glaxnimate::model::Ellipse::tree_icon() const
0013 {
0014     return QIcon::fromTheme("draw-ellipse");
0015 }
0016 
0017 QString glaxnimate::model::Ellipse::type_name_human() const
0018 {
0019     return i18n("Ellipse");
0020 }
0021 
0022 glaxnimate::math::bezier::Bezier glaxnimate::model::Ellipse::to_bezier(FrameTime t) const
0023 {
0024     QSizeF sz = size.get_at(t);
0025 
0026     auto bezier = math::EllipseSolver(position.get_at(t), QPointF(sz.width()/2, sz.height()/2), 0).to_bezier(-math::pi/2, math::tau);
0027 
0028     if ( reversed.get() )
0029         bezier.reverse();
0030 
0031     return bezier;
0032 }
0033 
0034 QRectF glaxnimate::model::Ellipse::local_bounding_rect(FrameTime t) const
0035 {
0036     QSizeF sz = size.get_at(t);
0037     return QRectF(position.get_at(t) - QPointF(sz.width()/2, sz.height()/2), sz);
0038 }