From 421c2649b03bf9d74ee7a09ee39bd6759b320f87 Mon Sep 17 00:00:00 2001 From: "S. Kramm" Date: Sat, 16 Mar 2024 20:26:20 +0100 Subject: [PATCH] done: added demo drawing of points size/style --- homog2d.hpp | 16 ++++ misc/figures_src/src/drawparams_checking.cpp | 82 +++++++++++++------- 2 files changed, 71 insertions(+), 27 deletions(-) diff --git a/homog2d.hpp b/homog2d.hpp index 4be120f..9fb7c39 100644 --- a/homog2d.hpp +++ b/homog2d.hpp @@ -602,6 +602,22 @@ enum class PtStyle: uint8_t Dot ///< dot (circle) }; +inline +const char* getString( PtStyle t ) +{ + const char* s=0; + switch( t ) + { + case PtStyle::Plus: s="Plus"; break; + case PtStyle::Times: s="Times"; break; + case PtStyle::Star: s="Star"; break; + case PtStyle::Diam: s="Diam"; break; + case PtStyle::Dot: s="Dot"; break; + default: assert(0); + } + return s; +} + //------------------------------------------------------------------ /// Draw parameters, independent of back-end library class DrawParams diff --git a/misc/figures_src/src/drawparams_checking.cpp b/misc/figures_src/src/drawparams_checking.cpp index 5519ee7..bd1a2ba 100644 --- a/misc/figures_src/src/drawparams_checking.cpp +++ b/misc/figures_src/src/drawparams_checking.cpp @@ -4,45 +4,73 @@ #include "fig_src.header" -/// Used to check the drawing parameters for points -/// \todo issue here, the size is not used for type PtStyle::Dot -int main() +template +void process( img::Image& im, std::string fn, int width ) { img::DrawParams dp; -// dp.setThickness(1).showPoints().showIndex(); - dp.setThickness(1).showPoints(); + dp.setColor(220,220,220); dp.setDefault(); - img::Image im1( 400,300 ); - img::Image im2( 400,300 ); + int x0=30; + int y0=40; + int deltax=50; + int deltay=42; + Point2d pt( x0, y0 ); + int nbSize = 5; + int nbTypes = (int)img::PtStyle::Dot + 1; - dp.setColor( 250,0,0); - img::PtStyle newPointStyle = img::PtStyle::Plus; +// grid: vertical lines + Line2d lv(pt, Point2d(x0,nbSize*deltay)); + auto textColor = DrawParams().setColor(0,0,0); + for( int j=0;j im1( 400,300 ); + process( im1, "drawparams_1.svg", 1 ); + process( im1, "drawparams_2.svg", 2 ); + + img::Image im2( 400,300 ); + process( im2, "drawparams_1.png", 1 ); + process( im2, "drawparams_2.png", 2 ); +} +