graphic_board
= cluster is create, destroy, square2pixel, pixel2square, square_color, translate_size, translate_color,
get_window, get_size
- Overview
- a graphic_board is a visible, immutable object. It is a pattern of black and white squares displayed in a window.
- written by pepellet
- create = proc(w: window, size: square_size, x: int, y: int) returns(cvt)
- requires: w has not been destroyed
- modifies: w
- effects: creates rectangles in w to represent the chess board, and returns a new graphic_board
- destroy = proc(gb: cvt)
- requires: gb has not been destroyed, and the window containing gb has not been destroyed.
- modifies: the window which contains gb
- effects: removes the rectangles which represent the chess board.
- square2pixel = proc(gb: cvt, r: int, c: int) returns(pixel, pixel) signals (illegal_location)
- effects: If row r and column c represent a legal square on the chess board, returns the pixel location of the upper left corner of that square, relative to the window which contains gb. Else signals illegal_location.
- pixel2square = proc(gb: cvt, x: pixel, y: pixel) returns(int,int) signals (illegal_location)
- effects: If x and y represent a pixel position (relative to the window which contains gb) which is on gb, then returns the row and column number of the square which that pixel is on. Else signals illegal_location.
- square_color = proc(r: int, c: int) returns(bool) signals(illegal_location)
- effects: If row r and column c represent a legal square on the chess board, returns true if the square is white and false if the square is black. Else signals illegal_location.
- translate_size = proc(size: square_size) returns (pixel)
- effects: Returns the length of a side of a square of size size.
- translate_color = proc(c: bool) returns(string)
- effects: Returns the string "white" if c is true and returns the string "black" if c is false.
- get_window = proc(gb: cvt) returns(window)
- effects: Returns the window which gb exists in.
- get_size = proc(gb: cvt) returns(square_size)
- effects: Returns the size of the squares in gb.