/
SilovAndrey
/
easel_examples
Обзор
Документация
Войти
/
SilovAndrey
/
easel_examples
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
paths.cpp
95 строк
3 KB
Andrey HomePC
Add easel_examples v0.1.0 with shapes, space, paths examples
10 июл 2026, 10:34
10 июл 2026, 10:34
8ecc405
Код
Авторство
О чём код?
module; #include <utility> module App; using namespace easel; constexpr auto window_size = extent{640, 420}; const Path p1{"M 100 100 L 300 100 L 200 300 z"}; const Path p2{"M100,200 C100,100 250,100 250,200 S400,300 400,200"}; const Path p3{"M200,300 Q400,50 600,300 T1000,300"}; const Path p4{"M200,300 L400,50 L600,300 L800,550 L1000,300"}; const Path p5{"M300,200 h-150 a150,150 0 1,0 150,-150 z"}; const Path p6{"M275,175 v-150 a150,150 0 0,0 -150,150 z"}; const Path p7{ "M600,350 l 50,-25" "a25,25 -30 0,1 50,-25 l 50,-25" "a25,50 -30 0,1 50,-25 l 50,-25" "a25,75 -30 0,1 50,-25 l 50,-25" "a25,100 -30 0,1 50,-25 l 50,-25" }; Path dot; void draw(canvas& cnv, int w, int h) { auto stroke_fill = [&](const Path& p, color fill_c, color stroke_c) { //auto pp = cnv.add_path(std::move(p)); cnv.fill_style(fill_c); cnv.stroke_style(stroke_c); cnv.fill(p); cnv.line_width(5); cnv.stroke(p); }; auto stroke = [&](Path const& p, color stroke_c) { //cnv.add_path(p); cnv.stroke_style(stroke_c); cnv.line_width(5); cnv.stroke(p); }; // These paths are defined using SVG-style strings lifted off the // W3C SVG documentation: https://www.w3.org/TR/SVG/paths.html { auto save = cnv.new_state(); //cnv.scale(w / window_size.x * 0.5, window_size.y / h * 0.5); cnv.scale(0.5, 0.5); cnv.translate(-40, 0); stroke_fill(p1, colors::green.opacity(0.5), colors::ivory); cnv.translate(220, 0); stroke(p2, colors::light_sky_blue); cnv.translate(-150, 250); stroke(p3, colors::light_sky_blue); stroke(p4, colors::light_gray.opacity(0.5)); cnv.fill_style(colors::white.opacity(0.5)); cnv.fill(dot); cnv.translate(150, -250); cnv.translate(350, 0); stroke_fill(p5, colors::red.opacity(0.8), colors::ivory); stroke_fill(p6, colors::blue.opacity(0.8), colors::ivory); cnv.translate(-350, 200); stroke(p7, colors::ivory); } // cnv.font(font_descr{"Open Sans", 12}.thin()); // cnv.fill_color(colors::antique_white); // cnv.text_align(cnv.bottom); // auto url = "https://www.w3.org/TR/SVG/paths.html"; // cnv.fill_text(url, {5, window_size.y-5}); } int start(int argc, char const* argv[]) { dot.add_circle(200, 300, 10); dot.add_circle(600, 300, 10); dot.add_circle(1000, 300, 10); dot.add_circle(400, 50, 10); dot.add_circle(800, 550, 10); return run_app(argc, argv, window_size, colors::gray[10]); }