From c1c61e88c0d70aff1330aa99a629e5f12897f5b0 Mon Sep 17 00:00:00 2001 From: Ruben Van Boxem Date: Sun, 12 Feb 2017 20:35:07 +0100 Subject: [PATCH] Add some colors, make border transparent by default, --- graphics/canvas.c++ | 25 ++++++++++++++++++------- graphics/canvas.h++ | 1 + graphics/color.h++ | 17 ++++++++++------- graphics/shape.h++ | 2 +- 4 files changed, 30 insertions(+), 15 deletions(-) diff --git a/graphics/canvas.c++ b/graphics/canvas.c++ index 325a8b2..fea2d16 100644 --- a/graphics/canvas.c++ +++ b/graphics/canvas.c++ @@ -25,6 +25,7 @@ #include "graphics/canvas.h++" #include "graphics/gradient/linear_gradient.h++" +#include "graphics/gradient/sweep_gradient.h++" #include "graphics/shape/ellipse.h++" #include "graphics/shape/label.h++" @@ -36,19 +37,29 @@ namespace skui { void canvas::draw() { - rectangle square({128, 128}, {10, 10}); + rectangle square({140, 140}, {10, 10}); square.fill.color = colors::red; + square.border.thickness = 20; // black by default - ellipse circle({64, 64}, {200, 200}); - const std::vector points{{0,0},{300,300}}; - const std::vector colors{colors::green, colors::black}; - circle.fill.gradient = std::make_unique(points, colors); + rectangle marker({140,140}, {10.5,10.5}); + marker.fill.color = colors::transparent; + marker.border.thickness = 1; + marker.border.color = colors::green; + + ellipse circle({140, 140}, {150, 150}); + const scalar_position center{220,220}; + const std::vector rainbow{colors::cyan, + colors::magenta, + colors::yellow, + colors::cyan}; + circle.fill.gradient = std::make_unique(center, rainbow); label text_label("Hello Skui!", {300, 300}); - text_label.fill.color = colors::black; + text_label.fill.color = colors::white; - draw(colors::white); + draw(colors::black); draw(square); + draw(marker); draw(circle); draw(text_label); } diff --git a/graphics/canvas.h++ b/graphics/canvas.h++ index 22c327a..18d1a7e 100644 --- a/graphics/canvas.h++ +++ b/graphics/canvas.h++ @@ -46,6 +46,7 @@ namespace skui enum class canvas_flag { + none, anti_alias }; using canvas_flags = core::bitflag; diff --git a/graphics/color.h++ b/graphics/color.h++ index a3cb29e..e3bd39a 100644 --- a/graphics/color.h++ +++ b/graphics/color.h++ @@ -61,13 +61,16 @@ namespace skui namespace colors { - static constexpr color transparent{0, 0, 0, 0}; - static constexpr color white {255, 255, 255, 255}; - static constexpr color black {0, 0, 0, 255}; - static constexpr color red {255, 0, 0, 255}; - static constexpr color green {0, 255, 0, 255}; - static constexpr color blue {0, 0, 255, 255}; - static constexpr color grey {127, 127, 127, 255}; + static constexpr color transparent {0, 0, 0, 0}; + static constexpr color white {255, 255, 255, 255}; + static constexpr color black {0, 0, 0, 255}; + static constexpr color red {255, 0, 0, 255}; + static constexpr color green {0, 255, 0, 255}; + static constexpr color blue {0, 0, 255, 255}; + static constexpr color grey {127, 127, 127, 255}; + static constexpr color cyan {0, 255, 255, 255}; + static constexpr color magenta {255, 0, 255, 255}; + static constexpr color yellow {255, 255, 0, 255}; } } } diff --git a/graphics/shape.h++ b/graphics/shape.h++ index ba47833..912ba00 100644 --- a/graphics/shape.h++ +++ b/graphics/shape.h++ @@ -57,7 +57,7 @@ namespace skui { scalar thickness = 0; scalar radius = 0; - graphics::color color = graphics::colors::black; + graphics::color color = graphics::colors::transparent; } border; scalar_position position;