Skip to content

Commit

Permalink
Add some colors, make border transparent by default,
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvb committed Feb 12, 2017
1 parent d213edb commit c1c61e8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 15 deletions.
25 changes: 18 additions & 7 deletions graphics/canvas.c++
Original file line number Diff line number Diff line change
Expand Up @@ -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++"
Expand All @@ -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<scalar_position> points{{0,0},{300,300}};
const std::vector<color> colors{colors::green, colors::black};
circle.fill.gradient = std::make_unique<linear_gradient>(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<color> rainbow{colors::cyan,
colors::magenta,
colors::yellow,
colors::cyan};
circle.fill.gradient = std::make_unique<sweep_gradient>(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);
}
Expand Down
1 change: 1 addition & 0 deletions graphics/canvas.h++
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ namespace skui

enum class canvas_flag
{
none,
anti_alias
};
using canvas_flags = core::bitflag<canvas_flag>;
Expand Down
17 changes: 10 additions & 7 deletions graphics/color.h++
Original file line number Diff line number Diff line change
Expand Up @@ -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};
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion graphics/shape.h++
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c1c61e8

Please sign in to comment.