Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Single Pixel Wide Straight Lines
Re: Single Pixel Wide Straight Lines [message #59019 is a reply to message #59012] Fri, 14 October 2022 23:33 Go to previous messageGo to previous message
devilsclaw is currently offline  devilsclaw
Messages: 72
Registered: August 2022
Member
So I figured out what is going on. Lines are painted from the center / origin of the point so if you say line is at y coord 10 and have a line width of 3 it will be 1.5 pixels below and above instead of starting the line at 10 and having 3 lines going down from the starting point.

This means all odd line sizes as in 1,2,5,7,9 etc will be the incorrect size with any integer based drawing on everything except Draw its self it seems. I believe this is the wrong way to draw a line it should not be center radial.

This code example shows it working and clean lines

void Paint(Draw &w) {
  Size sz = GetSize();
  ImageBuffer ib(sz);
  BufferPainter sw(ib, MODE_ANTIALIASED);
  
  sw.DrawRect(sz, Black());
  
  int pos_y = 0;
  for(int stroke = 1; true; stroke += 1) {
    double center_of_line = stroke / 2.0;
    sw.Move( 0, pos_y + center_of_line).Line(sz.cx, pos_y + center_of_line).Stroke(stroke, Red());
    pos_y += (stroke * 2);
    if(pos_y >= sz.cy) {
     break;
    }
  }
}


index.php?t=getfile&id=6681&private=0

[Updated on: Fri, 14 October 2022 23:35]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Text painting issue with 'const char*'
Next Topic: Crash when loading some jpeg files
Goto Forum:
  


Current Time: Tue May 07 16:07:25 CEST 2024

Total time taken to generate the page: 0.01907 seconds