Class: EduDraw::Sheet

Inherits:
Gosu::Window
  • Object
show all
Defined in:
lib/edu_draw/sheet.rb

Overview

A Sheet is a 2D-Canvas that can be drawn on using Pen

Instance Method Summary collapse

Constructor Details

#initialize(x: 100, y: 100, title: "A blank sheet") ⇒ Sheet

Creates a new Sheet

Parameters:

  • x (Fixnum) (defaults to: 100)

    width in pixels

  • y (Fixnum) (defaults to: 100)

    height in pixels

  • title (String) (defaults to: "A blank sheet")

    Caption of the window



15
16
17
18
19
# File 'lib/edu_draw/sheet.rb', line 15

def initialize(x: 100, y: 100, title: "A blank sheet")
  super x, y, false
  self.caption = title
  @pens = []
end

Instance Method Details

#new_animation_pen(x: 0, y: 0, angle: 0, color: Gosu::Color::GREEN) ⇒ Object

Create a new AnimationPen that draws something different each frame

Parameters:

  • x (Fixnum) (defaults to: 0)

    x-coordinate of starting position. Left is 0.

  • y (Fixnum) (defaults to: 0)

    y-coordinate of starting position. Top is 0.

  • angle (Fixnum) (defaults to: 0)

    Direction of pen in degree. 0 points to the right.

  • color (Gosu::Color) (defaults to: Gosu::Color::GREEN)

    Color of the pen

See Also:



41
42
43
44
45
# File 'lib/edu_draw/sheet.rb', line 41

def new_animation_pen(x: 0, y: 0, angle: 0, color: Gosu::Color::GREEN)
  pen = AnimationPen.new(x: x, y: y, angle: angle, color: color)
  pens << pen
  pen
end

#new_pen(x: 0, y: 0, angle: 0, color: Gosu::Color::GREEN) ⇒ Object

Creates a new Pen that draws on self

Parameters:

  • x (Fixnum) (defaults to: 0)

    x-coordinate of starting position. Left is 0.

  • y (Fixnum) (defaults to: 0)

    y-coordinate of starting position. Top is 0.

  • angle (Fixnum) (defaults to: 0)

    Direction of pen in degree. 0 points to the right.

  • color (Gosu::Color) (defaults to: Gosu::Color::GREEN)

    Color of the pen

See Also:



30
31
32
33
34
# File 'lib/edu_draw/sheet.rb', line 30

def new_pen(x: 0, y: 0, angle: 0, color: Gosu::Color::GREEN)
  pen = Pen.new(x: x, y: y, angle: angle, color: color)
  pens << pen
  pen
end