This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "gosu/zen" | |
include Gosu::Zen | |
# patch | |
module Gosu | |
module Zen | |
def init(&body) | |
ZenWindow.send(:define_method, :init, &body) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
require "shogi_koma" | |
PIECES = [ | |
["歩兵", "FU"], | |
["香車", "KY"], | |
["桂馬", "KE"], | |
["銀将", "GI"], | |
["金将", "KI"], |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "gosu" | |
module CatchHats | |
module ZOrder | |
Background, Object, Text = *0..2 | |
end | |
class Player | |
attr_reader :x, :y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
begin | |
require "gosu" | |
rescue LoadError | |
$stderr.puts(<<-END_OF_MESSAGE) | |
LoadError: #{$!.message}. Please try `gem install gosu`. | |
If you are using Linux, please see https://github.com/jlnr/gosu/wiki/Getting-Started-on-Linux | |
END_OF_MESSAGE | |
exit(false) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "matrix" | |
# 変換前後の座標から射影変換のパラメーターを求める | |
# x11-x14: 変換前のX座標(左上から時計回り) | |
# y11-y14: 変換前のY座標 | |
# x21-x24: 変換後のX座標 | |
# y21-y24: 変換後のY座標 | |
def homography_params(x11, y11, x12, y12, | |
x13, y13, x14, y14, | |
x21, y21, x22, y22, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "cairo" | |
module Cairo | |
class Context | |
def show_graph(graph) | |
graph.draw(self) | |
end | |
end | |
class Graph |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "test-unit" | |
class RegexpTest < Test::Unit::TestCase | |
def setup | |
@regexp = /\bCairo(?:::[A-Z][\w\d_]+)*(?:[#.][\[_@\w\d]*(?:[=?!_*+\-\]]|\b)|\b)/ | |
end | |
def test_front | |
line = "Cairo::Contextはrcairoで描画するときに使用する主要なオブジェ\n" | |
assert_equal(["Cairo::Context"], line.gsub(@regexp).to_a) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= ひどか(仮) | |
= ひどかとは | |
* 「ひ」とり | |
* 「ど」くしょ(読書) | |
* 「か」い(会) | |
= 読書とは |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "cairo" | |
def draw_bowl(context, width, height) | |
context.save do | |
context.set_source_color(:black) | |
context.scale(width, height) | |
context.line_width = 0.01 | |
fill_inner(context) | |
fill_outer(context) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "cairo" | |
# http://www.dafont.com/ubuntu-title.font | |
FONT = "Ubuntu-Title" | |
# http://www.dafont.com/fifa-welcome.font | |
#FONT = "FIFA Welcome" | |
def draw(context, width, height, text) | |
context.save do | |
context.set_source_color(:black) |