[fltk/fltk] Draw lines of equal width in scaled mode (#167)
wcout
Dec 02, 2020
In scaled mode lines are drawn with different widths to adapt for empty gaps when drawing adjacent lines.
This may look ugly when drawing grids. Is there a way to get lines of fixed widths?
#include<FL/Fl.H>
#include<FL/Fl_Double_Window.H>
#include<FL/Fl_Box.H>
#include<FL/fl_draw.H>classLineBox : publicFl_Box
{
typedef Fl_Box Inherited;
public:LineBox(int x_, int y_, int w_, int h_, constchar *l_ = 0) :
Inherited( x_, y_, w_, h_, l_ ) {}
voiddraw()
{
Inherited::draw();
fl_color( FL_BLACK );
fl_line_style( FL_SOLID, 1 );
for ( int x = 0; x < this->w(); x += this->w() / 10 )
fl_yxline( this->x() + x, this->y(), this->y() + this->h() );
for ( int y = 0; y < this->h(); y += this->h() / 10 )
fl_xyline( this->x(), this->y() + y, this->x() + this->w() );
fl_line_style( 0 );
}
};
intmain( int argc_, char *argv_[] )
{
staticconstint W = 200;
staticconstint H = 200;
Fl_Double_Window win( 0, 0, W, H );
LineBox b( 0, 0, W, H );
win.end();
win.resizable(win);
win.show();
returnFl::run();
}
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.
Comments are owned by the poster. All other content is copyright 1998-2025 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.