1 # Copyright (c) 2009 Paolo Capriotti <p.capriotti@gmail.com>
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 2 of the License, or
6 # (at your option) any later version.
8 require 'plugins/plugin'
9 require 'plugins/background'
11 class DefaultBackground
15 plugin :name => 'Default Background',
17 :keywords => %w(chess)
20 @squares = opts[:board_size] || opts[:game].size
24 Qt::Image.painted(Qt::Point.new(size.x * @squares.x, size.y * @squares.y)) do |p|
25 (0...@squares.x).each do |x|
26 (0...@squares.y).each do |y|
27 rect = Qt::RectF.new(size.x * x, size.y * y, size.x, size.y)
28 color = if (x + y) % 2 == 1
29 Qt::Color.new(0x6b, 0x82, 0x9c)
31 Qt::Color.new(0xb8, 0xc0, 0xc0)
33 p.fill_rect(rect, Qt::Brush.new(color))