1858{
1859 wxSize size = GetSize();
1861 auto radius =
m_show_full ? size.x / 2 - FromDIP(1) : size.x / 2;
1863
1866 const double center_x = size.x / 2.0;
1867 const double center_y = size.y / 2.0;
1868 const double draw_radius = radius;
1869 dc.SetPen(*wxTRANSPARENT_PEN);
1870 for (int x = 0; x < size.x; ++x) {
1871 const double dx = x + 0.5 - center_x;
1872 if (std::abs(dx) > draw_radius) continue;
1873
1874 const double half_height = std::sqrt(std::max(0.0, draw_radius * draw_radius - dx * dx));
1875 const int top = std::max(0, static_cast<int>(std::ceil(center_y - half_height)));
1876 const int bottom = std::min(size.y - 1, static_cast<int>(std::floor(center_y + half_height)));
1877 const double pos = size.x > 1 ?
static_cast<double>(x) / (size.x - 1) : 0.0;
1879 const size_t idx = std::min(
static_cast<size_t>(
scaled),
m_cols.size() - 2);
1880 const double ratio =
scaled - idx;
1881
1882 if (top <= bottom) {
1884 dc.DrawRectangle(x, top, 1, bottom - top + 1);
1885 }
1886 }
1887 }
1888 else {
1889 float ev_angle = 360.0 /
m_cols.size();
1890 const float overlap = 2.0f;
1891 wxPoint
center(size.x / 2, size.y / 2);
1892 dc.SetPen(*wxTRANSPARENT_PEN);
1893 dc.SetBrush(wxBrush(
m_cols.front()));
1895 for (
int i = 0; i <
m_cols.size(); i++) {
1897 float startAngle = 270.0f + i * ev_angle;
1898 float endAngle = startAngle + ev_angle;
1899 dc.DrawEllipticArc(
center.x - radius,
center.y - radius, 2 * radius, 2 * radius, startAngle - overlap, endAngle + overlap);
1900 }
1901 }
1902 }
1903 else if (alpha == 0) {
1905 int center_x = (size.x - bmp_size.x) / 2;
1906 int center_y = (size.y - bmp_size.y) / 2;
1908 }
1909 else if (alpha != 254 && alpha != 255) {
1911 std::string rgb = (
m_colour.GetAsString(wxC2S_HTML_SYNTAX)).ToStdString();
1912 if (rgb.size() == 9) {
1913
1914 rgb = rgb.substr(0, rgb.size() - 2);
1915 }
1916 float alpha_f = 0.7 *
m_colour.Alpha() / 255.0;
1917 std::vector<std::string> replace;
1918 replace.push_back(rgb);
1919 std::string fill_replace = "fill-opacity=\"" + std::to_string(alpha_f);
1920 replace.push_back(fill_replace);
1921 m_bitmap_transparent = ScalableBitmap(
this,
"transparent_color_picker", 25,
false,
false,
true, replace).bmp();
1923 }
1925 int center_x = (size.x - bmp_size.x) / 2;
1926 int center_y = (size.y - bmp_size.y) / 2;
1928 }
1929 else {
1932 dc.DrawCircle(size.x / 2, size.y / 2, radius);
1933 }
1934
1937 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1938 dc.DrawCircle(size.x / 2, size.y / 2, size.x / 2);
1939 }
1940
1942 dc.SetPen(wxPen(wxColour("#6B6B6B")));
1943 dc.SetBrush(*wxTRANSPARENT_BRUSH);
1944 dc.DrawCircle(size.x / 2, size.y / 2, radius);
1945 }
1946
1948 dc.SetTextForeground(*wxBLACK);
1949 auto tsize = dc.GetTextExtent("?");
1950 auto pot = wxPoint((size.x - tsize.x) / 2, (size.y - tsize.y) / 2);
1951 dc.DrawText("?", pot);
1952 }
1953}
bool m_show_full
Definition AMSMaterialsSetting.hpp:61
bool transparent_changed
Definition AMSMaterialsSetting.hpp:65
bool m_is_empty
Definition AMSMaterialsSetting.hpp:62
wxColour m_colour
Definition AMSMaterialsSetting.hpp:58
std::vector< wxColour > m_cols
Definition AMSMaterialsSetting.hpp:59
bool m_selected
Definition AMSMaterialsSetting.hpp:60
int ctype
Definition AMSMaterialsSetting.hpp:63
static wxColour mix_colour(const wxColour &left, const wxColour &right, double ratio)
Definition AMSMaterialsSetting.cpp:95
Vec3d pos(const Pt &p)
Definition ReprojectPointsOnMesh.hpp:16
BoundingBox scaled(const BoundingBoxf &bb)
Definition BoundingBox.hpp:284
void center(ExPolygonsWithIds &e)
Definition Emboss.cpp:1382