Skip to content

AColor#

Represents a 4-component floating point color (RGBA).

Header:#include <AUI/Common/AColor.h>
CMake:aui_link(my_target PUBLIC aui::core)

Examples#

examples/app/game_of_life/src/main.cpp

Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.

            }
            for (int i = 1; i < mCells->size().y; ++i) {
                points << std::make_pair(glm::vec2(0.f, i * SCALE), glm::vec2(getSize().x, i * SCALE));
            }
            ctx.render.lines(ASolidBrush { AColor::GRAY }, points);
        };
        drawGrid();
    }

    void onPointerPressed(const APointerPressedEvent& event) override {

examples/app/minesweeper/src/CellView.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

        if (count) {
            AFontStyle fs;
            fs.size = getHeight() * 6 / 7;
            fs.align = ATextAlign::CENTER;
            auto color = AColor::BLACK;

            switch (count) {
                case 1:
                    color = 0x0000ffffu;
                    break;

examples/ui/backdrop/src/main.cpp

Backdrop - Backdrop effects demo.

                      Backdrop {
                          Backdrop::LiquidFluid {},
                      },
//                      Border { 1_dp, AColor::GRAY.transparentize(0.7f) },
                      BoxShadow { 0, 32_dp, 32_dp, AColor::BLACK.transparentize(0.8f) },
                  },
                  Label { "boll" } AUI_WITH_STYLE {
                      FixedSize { 60_dp },
                      BorderRadius { 60_dp / 2.f },
                      Padding { 0 },

examples/ui/contacts/src/view/ContactDetailsView.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

        }) AUI_WITH_STYLE { Opacity(0.5f), FontSize { 32_dp } },
    } AUI_WITH_STYLE {
        FixedSize { 64_dp },
        BorderRadius { 32_dp },
        BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
    };
}

template <typename T>
_<AView> viewer(AProperty<T>& property) {

examples/ui/contacts/src/view/common.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

using namespace ass;
using namespace declarative;

_<AView> common_views::divider() {
    return _new<AView>() AUI_WITH_STYLE { FixedSize { {}, 1_px }, BackgroundSolid { AColor::GRAY } };
}

examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker - Flight Booker.

public:
    FlightBookerWindow() : AWindow("AUI - 7GUIs - Book Flight", 150_dp, 50_dp) {
        setExtraStylesheet(AStylesheet { {
          ass::c(".red"),
          ass::BackgroundSolid { AColor::RED },
        } });
        setContents(Centered {
          Vertical {
            _new<ADropdownList>(AListModel<AString>::make({ "one-way flight", "return flight" })) AUI_LET {
                    connect(it->selectionId().readProjected([](int selectionId) { return selectionId == 1; }),

examples/7guis/cells/src/main.cpp

7GUIs Cells - Spreadsheet processor (Excel).

                        for (unsigned row = 0; row < mState->spreadsheet.size().y; ++row) {
                            views[row + 1][0] = labelTitle("{}"_format(Cell::rowName(row)));
                            for (unsigned column = 0; column < mState->spreadsheet.size().x; ++column) {
                                views[row + 1][column + 1] = _new<CellView>(mState, mState->spreadsheet[{ column, row }]) AUI_WITH_STYLE {
                                    BackgroundSolid { AColor::WHITE },
                                };
                            }
                        }
                        return views;
                    }())

examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

public:
    CircleDrawArea(_<State> state) : mState(std::move(state)) {
        setCustomStyle({
          Expanding(),
          BackgroundSolid(AColor::WHITE),
          Border(1_px, AColor::GRAY),
          AOverflow::HIDDEN_FROM_THIS,
        });
        connect(mState->circles.changed, me::redraw);
        connect(mHoveredCircle.changed, me::redraw);

Public Methods#

AColor#


constexpr AColor::AColor(unsigned int color)

Construct with hex integer

Arguments
color
integer representing color in 0xRRGGBBAA

AColor(0xff0000ff) will represent opaque bright red

Examples#

examples/app/game_of_life/src/main.cpp

Game of Life - Game of Life implementation that uses advanced large dynamic data rendering techniques such as ITexture, AImage to be GPU friendly. The computation is performed in AThreadPool.

            }
            for (int i = 1; i < mCells->size().y; ++i) {
                points << std::make_pair(glm::vec2(0.f, i * SCALE), glm::vec2(getSize().x, i * SCALE));
            }
            ctx.render.lines(ASolidBrush { AColor::GRAY }, points);
        };
        drawGrid();
    }

    void onPointerPressed(const APointerPressedEvent& event) override {
examples/app/minesweeper/src/CellView.cpp

Minesweeper Game - Minesweeper game implementation driven by ass.

        if (count) {
            AFontStyle fs;
            fs.size = getHeight() * 6 / 7;
            fs.align = ATextAlign::CENTER;
            auto color = AColor::BLACK;

            switch (count) {
                case 1:
                    color = 0x0000ffffu;
                    break;
examples/ui/backdrop/src/main.cpp

Backdrop - Backdrop effects demo.

                      Backdrop {
                          Backdrop::LiquidFluid {},
                      },
//                      Border { 1_dp, AColor::GRAY.transparentize(0.7f) },
                      BoxShadow { 0, 32_dp, 32_dp, AColor::BLACK.transparentize(0.8f) },
                  },
                  Label { "boll" } AUI_WITH_STYLE {
                      FixedSize { 60_dp },
                      BorderRadius { 60_dp / 2.f },
                      Padding { 0 },
examples/ui/contacts/src/view/ContactDetailsView.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

        }) AUI_WITH_STYLE { Opacity(0.5f), FontSize { 32_dp } },
    } AUI_WITH_STYLE {
        FixedSize { 64_dp },
        BorderRadius { 32_dp },
        BackgroundGradient { AColor::GRAY.lighter(0.5f), AColor::GRAY, 163_deg },
    };
}

template <typename T>
_<AView> viewer(AProperty<T>& property) {
examples/ui/contacts/src/view/common.cpp

AUI Contacts - Usage of AUI_DECLARATIVE_FOR to make a contacts-like application.

using namespace ass;
using namespace declarative;

_<AView> common_views::divider() {
    return _new<AView>() AUI_WITH_STYLE { FixedSize { {}, 1_px }, BackgroundSolid { AColor::GRAY } };
}
examples/7guis/flight_booker/src/main.cpp

7GUIs Flight Booker - Flight Booker.

public:
    FlightBookerWindow() : AWindow("AUI - 7GUIs - Book Flight", 150_dp, 50_dp) {
        setExtraStylesheet(AStylesheet { {
          ass::c(".red"),
          ass::BackgroundSolid { AColor::RED },
        } });
        setContents(Centered {
          Vertical {
            _new<ADropdownList>(AListModel<AString>::make({ "one-way flight", "return flight" })) AUI_LET {
                    connect(it->selectionId().readProjected([](int selectionId) { return selectionId == 1; }),
examples/7guis/cells/src/main.cpp

7GUIs Cells - Spreadsheet processor (Excel).

                        for (unsigned row = 0; row < mState->spreadsheet.size().y; ++row) {
                            views[row + 1][0] = labelTitle("{}"_format(Cell::rowName(row)));
                            for (unsigned column = 0; column < mState->spreadsheet.size().x; ++column) {
                                views[row + 1][column + 1] = _new<CellView>(mState, mState->spreadsheet[{ column, row }]) AUI_WITH_STYLE {
                                    BackgroundSolid { AColor::WHITE },
                                };
                            }
                        }
                        return views;
                    }())
examples/7guis/circle_drawer/src/main.cpp

7GUIs Circle Drawer - Undo, redo, dialog control.

public:
    CircleDrawArea(_<State> state) : mState(std::move(state)) {
        setCustomStyle({
          Expanding(),
          BackgroundSolid(AColor::WHITE),
          Border(1_px, AColor::GRAY),
          AOverflow::HIDDEN_FROM_THIS,
        });
        connect(mState->circles.changed, me::redraw);
        connect(mHoveredCircle.changed, me::redraw);

fromAARRGGBB#


static constexpr AColor AColor::fromAARRGGBB(unsigned int color)

Construct with hex integer

Arguments
color
integer representing color in 0xAARRGGBB

AColor(0xff0000ff) will represent opaque bright blue

fromRRGGBB#


static constexpr AColor AColor::fromRRGGBB(unsigned int color)

Construct with hex integer

Arguments
color
integer representing color in 0xRRGGBB

AColor(0x00ff00) will represent opaque bright green

mul#


inline constexpr AColor AColor::mul(float d)

Multiply all color components except alpha channel (rgb * d, a)

Arguments
d
multiplier
Returns
multiplied color

opacify#


AColor AColor::opacify(float alpha)

Increases the alpha channel by the given value.

transparentize#


AColor AColor::transparentize(float alpha)

Decreases the alpha channel by the given value.

Examples#

examples/ui/backdrop/src/main.cpp

Backdrop - Backdrop effects demo.

                      Backdrop {
                          Backdrop::LiquidFluid {},
                      },
//                      Border { 1_dp, AColor::GRAY.transparentize(0.7f) },
                      BoxShadow { 0, 32_dp, 32_dp, AColor::BLACK.transparentize(0.8f) },
                  },
                  Label { "boll" } AUI_WITH_STYLE {
                      FixedSize { 60_dp },
                      BorderRadius { 60_dp / 2.f },
                      Padding { 0 },