Class

IpuzNonogramColor

Description [src]

class Ipuz.NonogramColor : Ipuz.Nonogram
{
  /* No available fields */
}

A color nonogram puzzle.

A nonogram is a picture-based logic puzzle in which the player uses hints on the edge of the puzzle to reveal a picture. Unlike a more traditional monochrome nonogram, color nonograms use different colors with its hints to reveal a multi-colored image.

Representation

The IpuzCellType is used to determine whether a cell is filled in or blank. If it’s a BLOCK, then it’s filled in, while NORMAL indicates a blank cell. A NULL cell could indicate a shaped puzzle, though is not traditionally used with nonograms.

With color nonograms, if the cell is a block then the solution field is set to a string to indicate which grouping the cell belongs to. This grouping is also reflected in the IpuzNonogramClue segments. All other fields of IpuzCell (such as number and label) are ignored.

Color nonograms are expected to have a style with the same style_name as the group to indicate the color to be used with a given group. All other fields of the style are undefined. If a style with that name doesn’t exist, apps can choose an arbitrary color to define that group.

Representation Examples

For example, here’s a simple example of a color nonogram puzzle’s on-disk representation. In this example, there are two different colors in use.

 {
    "version": "http://ipuz.org/v2",
    "kind": [ "https://libipuz.org/nonogram#1", "https://libipuz.org/nonogram/colornonogram#1" ],
    "dimensions": { "width": 3, "height": 3 },
    "styles": {
        "A": {"color": "#f8e45c" },
        "B": {"color": "#813d9c" }
    },
    "puzzle": [ [ 0 , "A",  0  ],
                ["A", "B", "B" ],
                ["B" , 0 , "A" ] ]
}

Here’s an example of working with the styles:

static void
paint_cell (IpuzPuzzle    *puzzle,
            IpuzCellCoord *coord)
{
  IpuzCell *cell;

  cell = ipuz_grid_get_cell (IPUZ_GRID (puzzle), coord);

  if (ipuz_cell_get_cell_type (cell) == IPUZ_CELL_BLOCK)
    {
       IpuzStyle *style;

       style = ipuz_cell_get_style (cell);

       // If a puzzle doesn't have a style defined, then pick a random one for that group
       if (style == NULL)
         style = get_default_style (ipuz_cell_get_solution (cell));

       // Do something with the color
       paint_block_at_coord (coord, ipuz_style_get_bg_color (style));
    }
}

Note that ipuz_puzzle_get_style() can also return the style for a style_group. This is useful when matching to a group with a IpuzNonogramClue.

Guesses

IpuzNonogramColor objects follow a similar convention to regular nonograms to record player progress in solving a puzzle.

  • A guess of a block uses the style name to indicate
  • A guess of IpuzNonogram:space is used to indicate that a cell has been eliminated as a possible block. This defaults to the string ".".
  • A guess of NULL is used to indicate that the player has yet to determine if a cell is a block or not.

In addition, IpuzNonogramColor uses the stride_guess of the guesses struct to keep track of whether the cells for the number hints have been found. This is required for puzzle games that let the user manually cross off numbers. See IpuzNonogram for full details.

Constructors

ipuz_nonogram_color_new

Returns a newly created color nonogram puzzle.

Instance methods

Methods inherited from IpuzNonogram (10)
ipuz_nonogram_fix_clues

Fixes the clues of self to match the current grid state.

ipuz_nonogram_get_cells_by_group

Returns all the cells that are set to group. For monochrome nonograms, the group should be IpuzPuzzle:block.

ipuz_nonogram_get_clues

Returns an array containing the run of IpuzNonogramClue indicated by index and direction.

ipuz_nonogram_get_count_crossed_off

Returns TRUE if the number identified by the arguments should be crossed off. This function is essentially a wrapper around parsing the stride_guess directly.

ipuz_nonogram_get_group

Returns the group at index.

ipuz_nonogram_get_n_groups

Returns the number of different groups within self.

ipuz_nonogram_get_space

Returns the text value that represents a space in IpuzGuesses. That is to say, a cell that has been eliminated from possibly being a block.

ipuz_nonogram_print

Prints self to stdout. This method is meant to be used for debugging.

ipuz_nonogram_set_count_crossed_off

Crosses off a number within the guesses in the IpuzGuesses associated with self.

ipuz_nonogram_set_space

Sets the text value that represents a space. That is to say, a cell that has been eliminated from possibly being a block.

Methods inherited from IpuzGrid (11)
ipuz_grid_check_cell

Invokes the operation determined by check_type on cell and guesses at coord.

ipuz_grid_check_stride

Invokes the operation determined by check_type on the stride guess determined by direction and index.

ipuz_grid_create_guesses

Creates a fresh IpuzGuesses. It will be initialized to the current state of the grid.

ipuz_grid_fix_guesses

Fixes the guesses associated with self. The result will be a playable IpuzGuesses struct.

ipuz_grid_foreach_cell

Calls func for each IpuzCell in self.

ipuz_grid_get_cell

Retrieves the cell at coord. If the coordinates are outside the bounds of the grid then NULL will be returned.

ipuz_grid_get_guesses

Returns the IpuzGuesses associated with self.

ipuz_grid_get_height

Returns the number of rows in self.

ipuz_grid_get_width

Returns the number of columns in self.

ipuz_grid_resize

Resizes self to the new size.

ipuz_grid_set_guesses

Sets guesses for self. If there’s a mismatch in the cell types between guesses and self then FALSE is returned. guesses will be set regardless of the return value.

Methods inherited from IpuzPuzzle (55)

Please see IpuzPuzzle for a full list of methods.

Methods inherited from GObject (43)

Please see GObject for a full list of methods.

Properties

Properties inherited from IpuzNonogram (1)
Ipuz.Nonogram:space

The text value that represents a space in the saved file.

Properties inherited from IpuzGrid (3)
Ipuz.Grid:guesses

The IpuzGuesses associated with the grid.

Ipuz.Grid:height

Number of rows in the grid.

Ipuz.Grid:width

Number of columns in the grid.

Properties inherited from IpuzPuzzle (24)
Ipuz.Puzzle:annotation

Non-displayed annotation.

Ipuz.Puzzle:author

Author of the puzzle.

Ipuz.Puzzle:block

The text value that represents a block in the saved file.

Ipuz.Puzzle:charset

Characters that can be entered in the puzzle. Setting this explicitly will override the charset defined by IpuzPuzzle:locale.

Ipuz.Puzzle:charset-str

Characters that can be entered in the puzzle, in string form. Setting this explicitly will override the charset defined by IpuzPuzzle:locale.

Ipuz.Puzzle:copyright

Copyright information for the puzzle.

Ipuz.Puzzle:date

Date of puzzle or publication date.

Ipuz.Puzzle:difficulty

Difficulty of the puzzle. Advisory only, as there is no standard for difficulty.

Ipuz.Puzzle:editor

Editor of the puzzle.

Ipuz.Puzzle:empty

Text value that represents an empty cell.

Ipuz.Puzzle:explanation

Text to be displayed after a successful solve.

Ipuz.Puzzle:intro

Text displayed above the puzzle.

Ipuz.Puzzle:license

License of the puzzle.

Ipuz.Puzzle:locale

Locale of the puzzle.

Ipuz.Puzzle:notes

Notes about the puzzle.

Ipuz.Puzzle:origin

Program-specific information about the program that wrote the puzzle file.

Ipuz.Puzzle:publication

Bibliographic reference for a published puzzle.

Ipuz.Puzzle:publisher

Name and/or reference for a publisher.

Ipuz.Puzzle:puzzle-kind

The kind type of the puzzle.

Ipuz.Puzzle:styles

A GHash table containing all the named styles for the puzzle. These can be added or removed by calling ipuz_puzzle_set_style().

Ipuz.Puzzle:title

Title of the puzzle.

Ipuz.Puzzle:uniqueid

Globally unique identifier for the puzzle.

Ipuz.Puzzle:url

Permanent URL for the puzzle.

Ipuz.Puzzle:version

Version of the ipuz spec used for the puzzle.

Signals

Signals inherited from GObject (1)
GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

Class structure

struct IpuzNonogramColorClass {
  IpuzNonogramClass parent_class;
  
}

The class structure for IpuzNonogramColors.

Class members
parent_class: IpuzNonogramClass

The nonogram class structure representing the parent.