samples/05_mouse/03_mouse_move_paint_app/app/main.rb
def add_grid

    # Sets the x, y, height, and width of the grid.
    # There are 31 horizontal lines and 31 vertical lines in the grid.
    # Feel free to count them yourself before continuing!
    x, y, h, w = 640 - 500/2, 640 - 500, 500, 500 # calculations done so the grid appears in screen's center
    lines_h = 31
    lines_v = 31

    # Sets values for the grid's border, grid lines, and filled squares.
    # The filled_squares variable is initially set to an empty array.
    state.grid_border ||= [ x, y, h, w ] # definition of grid's outer border
    state.grid_lines ||= draw_grid(x, y, h, w, lines_h, lines_v) # calls draw_grid method
    state.filled_squares ||= [] # there are no filled squares until the user fills them in

    # Outputs the grid lines, border, and filled squares onto the screen.
    outputs.lines.concat state.grid_lines
    outputs.borders << state.grid_border
    outputs.solids << state.filled_squares
  end
# Outputs a border and a grid containing empty squares onto the screen.
Outputs a border and a grid containing empty squares onto the screen.
Outputs a border and a grid containing empty squares onto the screen .
def add_grid
    x, y, h, w = 640 - 500/2, 640 - 500, 500, 500 
    lines_h = 31
    lines_v = 31
    state.grid_border ||= [ x, y, h, w ] 
    state.grid_lines ||= draw_grid(x, y, h, w, lines_h, lines_v) 
    state.filled_squares ||= [] 
    outputs.lines.concat state.grid_lines
    outputs.borders << state.grid_border
    outputs.solids << state.filled_squares
  end
def add_grid x , y , h , w = 640 - 500 / 2 , 640 - 500 , 500 , 500 lines_h = 31 lines_v = 31 state . grid_border ||= [ x , y , h , w ] state . grid_lines ||= draw_grid ( x , y , h , w , lines_h , lines_v ) state . filled_squares ||= [ ] outputs . lines . concat state . grid_lines outputs . borders << state . grid_border outputs . solids << state . filled_squares end
Outputs a border and a grid containing empty squares onto the screen.
Outputs a border and a grid containing empty squares onto the screen .
# Sets the x, y, height, and width of the grid. # There are 31 horizontal lines and 31 vertical lines in the grid. # Feel free to count them yourself before continuing! # calculations done so the grid appears in screen's center # Sets values for the grid's border, grid lines, and filled squares. # The filled_squares variable is initially set to an empty array. # definition of grid's outer border # calls draw_grid method # there are no filled squares until the user fills them in # Outputs the grid lines, border, and filled squares onto the screen.