++ed by:
NEYASOV EGOR SYP TOMITA MOSHEN

31 PAUSE user(s)
17 non-PAUSE user(s).

Tony Cook

NAME

hlines.c - implements a "class" for managing sets of horizontal line segments

SYNOPSIS

  i_int_hlines hlines;
  // just for the specified range of y
  i_int_init_hlines(&hlines, start_y, count_y, start_x, width_x);
  // to cover a whole image
  i_int_init_hlines_img(&hlines, img);
  // add a hline segment, merging into existing
  i_int_hlines_add(&hlines, y, x, width);

  // work over the lines
  for (y = hlines.start; y < hlines.limit; ++y) {
    i_int_hline_entry *entry = hlines.entries[i];
    if (entry) {
      for (i = 0; i < entry->count; ++i) {
        i_int_hline_seg *seg = entry->segs+i;
        // do something on line y for seg->minx to x_limit
      }
    }
  }

  // free it all up
  i_int_hlines_destroy(&hlines);

DESCRIPTION

Provides a class to manage sets of horizontal line segments. The intent is that when drawing shapes where the algorithm used might cause overlaps we can use this class to resolve the overlaps.

Note that segment lists are intended to remain small, if we end up with a need for longer lists we should use different structure for the segment lists.

i_int_init_hlines

i_int_init_hlines(&hlines, start_y, count_y, start_x, width_x)

Initializes the structure based on drawing an object within the given range. Any x or y values outside the given ranges will be ignored.

i_int_init_hlines_img

i_int_init_hlines_img(img);

Initialize a hlines object as if we could potentially draw anywhere on the image.

i_int_hlines_add

i_int_hlines_add(hlines, y, x, width)

Add to the list, merging with existing entries.

i_int_hlines_destroy

i_int_hlines_destroy(&hlines)

Releases all memory associated with the structure.

i_int_hlines_fill_color

i_int_hlines_fill(im, hlines, color)

Fill the areas given by hlines with color.

i_int_hlines_fill_fill

i_int_hlines_fill_fill(im, hlines, fill)

AUTHOR

Tony Cook <tonyc@cpan.org>

REVISION

$Revision$