CYD-UI
A C++ library for building native graphic user interfaces
Loading...
Searching...
No Matches
ellipse.cppm
Go to the documentation of this file.
1
// Copyright (c) 2024, Víctor Castillo Agüero.
2
// SPDX-License-Identifier: GPL-3.0-or-later
3
4
module
;
5
#include <cairomm-1.16/cairomm/cairomm.h>
6
#include <tracy/Tracy.hpp>
7
8
export
module
cydui.graphics.vector.elements.ellipse
;
9
10
import
std;
11
12
export
import
cydui.dimensions
;
13
export
import
cydui.graphics.vector.element
;
14
15
export
namespace
vg
{
16
struct
ellipse
:
17
element_t
,
18
attrs_core
<ellipse>,
19
attrs_fill
<ellipse>,
20
attrs_stroke
<ellipse>,
21
attr_cx
<ellipse>,
22
attr_cy
<ellipse>,
23
attr_rx
<ellipse>,
24
attr_ry
<ellipse> {
25
ellipse
() {
26
//TracyAllocN(this, sizeof(decltype(*this)), "fragment_elements");
27
}
28
~ellipse
()
override
{
29
//TracyFreeN(this, "fragment_elements");
30
}
31
void
apply_to
(
pixelmap_editor_t
&editor)
const override
{
32
apply_stroke
(editor);
33
apply_fill
(editor);
34
35
editor->save();
36
double
odd_offset = 0.0;
37
if
((
_stroke_width
% 2) != 0) {
38
odd_offset = 0.5;
39
}
40
editor->translate(
origin_x
+
_cx
+ odd_offset,
origin_y
+
_cy
+ odd_offset);
41
editor->scale(
_rx
,
_ry
);
42
editor->arc(0.0, 0.0, 1.0, 0.0, 2 * std::numbers::pi);
43
44
set_source_to_fill
(editor);
45
editor->fill_preserve();
46
47
set_source_to_stroke
(editor);
48
editor->stroke();
49
50
editor->restore();
51
}
52
53
footprint
get_footprint
()
const override
{
54
return
{
_cx
-
_rx
,
_cy
-
_ry
, 2 *
_rx
, 2 *
_ry
};
55
}
56
};
57
}
pixelmap_editor_t
Definition
pixelmap_editor.cppm:14
cydui.dimensions
cydui.graphics.vector.element
cydui.graphics.vector.elements.ellipse
vg
Definition
attributes.cppm:14
vg::attr_cx
cx - center x-axis coordinate
Definition
attributes.cppm:339
vg::attr_cx< ellipse >::_cx
int _cx
Definition
attributes.cppm:339
vg::attr_cy
cy - center y-axis coordinate
Definition
attributes.cppm:341
vg::attr_cy< ellipse >::_cy
int _cy
Definition
attributes.cppm:341
vg::attr_rx
rx - radius in x-axis
Definition
attributes.cppm:327
vg::attr_rx< ellipse >::_rx
int _rx
Definition
attributes.cppm:327
vg::attr_ry
ry - radius in y-axis
Definition
attributes.cppm:329
vg::attr_ry< ellipse >::_ry
int _ry
Definition
attributes.cppm:329
vg::attr_stroke_width< ellipse >::_stroke_width
int _stroke_width
Definition
attributes.cppm:409
vg::attrs_core
Definition
attributes.cppm:529
vg::attrs_fill
Definition
attributes.cppm:494
vg::attrs_fill< ellipse >::apply_fill
void apply_fill(pixelmap_editor_t &editor) const
Definition
attributes.cppm:496
vg::attrs_fill< ellipse >::set_source_to_fill
void set_source_to_fill(pixelmap_editor_t &editor) const
Definition
attributes.cppm:500
vg::attrs_stroke
Definition
attributes.cppm:473
vg::attrs_stroke< ellipse >::set_source_to_stroke
void set_source_to_stroke(pixelmap_editor_t &editor) const
Definition
attributes.cppm:483
vg::attrs_stroke< ellipse >::apply_stroke
void apply_stroke(pixelmap_editor_t &editor) const
Definition
attributes.cppm:475
vg::element_t::footprint
Definition
element.cppm:31
vg::element_t
Definition
element.cppm:19
vg::element_t::origin_y
int origin_y
Definition
element.cppm:21
vg::element_t::origin_x
int origin_x
Definition
element.cppm:20
vg::ellipse::get_footprint
footprint get_footprint() const override
Definition
ellipse.cppm:53
vg::ellipse::apply_to
void apply_to(pixelmap_editor_t &editor) const override
Definition
ellipse.cppm:31
vg::ellipse::~ellipse
~ellipse() override
Definition
ellipse.cppm:28
vg::ellipse::ellipse
ellipse()
Definition
ellipse.cppm:25
include
cyd_ui
graphics
vector
elements
ellipse.cppm
Generated by
1.13.2