2

I am trying to learn Cimg but simetimes the documentation is very vague. I am playing with the drawing functions and I want to draw a line. the functoon declaration is very simple:

CImg<T>& draw_line  (   const int   x0,
        const int   y0,
        const int   x1,
        const int   y1,
        const tc *const     color,
        const float     opacity = 1,
        const unsigned int      pattern = ~0U,
        const bool      init_hatch = true 
    )   

where

x0  X-coordinate of the starting line point. 
y0  Y-coordinate of the starting line point.
x1  X-coordinate of the ending line point.
y1  Y-coordinate of the ending line point.
color   Pointer to spectrum() consecutive values of type T, defining    the drawing color.
opacity Drawing opacity.
**pattern   An integer whose bits describe the line pattern.**
init_hatch  Tells if a reinitialization of the hash state must be done. 

My question is with pattern, I haven't been able to find in the documentation which integers represent which kind of lines. Does anyone now how to manipulate the pattern?

Thank you in advance

Diego Fernando Pava
  • 899
  • 3
  • 11
  • 24

1 Answers1

3

One of the developers responded this question to me via e-mail, I post it here for anyone who has the same question.

The pattern is given by how the bits in the unsigned int are sets. You have to look at your unsigned integer as a pattern of 32 pixels (i.e. 32bits) that can be either transparent (bit set to 0) or opaque (bit set to 1). For instance, a pattern where all bits are set to 1 is full opaque, and corresponds to pattern value 0xFFFFFFFF. A pattern where 8 pixels are transparent, then 8 pixels are opaque corresponds to pattern 0xFF00FF00. A pattern like 0xCCCCCCCC means 1 pixel transparent, then 1 pixel opaque, etc...

Diego Fernando Pava
  • 899
  • 3
  • 11
  • 24