FLTK logo

[fltk/fltk] Draw lines of equal width in scaled mode (#167)

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.issues  ]
 
Previous Message ]New Message | Reply ]Next Message ]

[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>

class LineBox : public Fl_Box
{
typedef Fl_Box Inherited;
public:
	LineBox(int x_, int y_, int w_, int h_, const char *l_ = 0) :
		Inherited( x_, y_, w_, h_, l_ ) {}
	void draw()
	{
		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 );
	}
};

int main( int argc_, char *argv_[] )
{
	static const int W = 200;
	static const int H = 200;
	Fl_Double_Window win( 0, 0, W, H );

	LineBox b( 0, 0, W, H );

	win.end();
	win.resizable(win);
	win.show();
	return Fl::run();
}

lines


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.