Class: Ray::Vertex

Inherits:
Object
  • Object
show all
Includes:
PP
Defined in:
lib/ray/vertex.rb,
ext/vertex.c

Instance Method Summary collapse

Methods included from PP

#pretty_print_attributes

Constructor Details

#initialize(pos = [0, 0], color = Color.white, tex = [0, 0]) ⇒ Object

Parameters:

  • pos (Ray::Vector2) (defaults to: [0, 0])

    Position of the vertex

  • color (Ray::Color) (defaults to: Color.white)

    Color of the vertex

  • tex (Ray::Vector2) (defaults to: [0, 0])

    Texture position of the vertex


29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'ext/vertex.c', line 29

static
VALUE ray_vertex_init(int argc, VALUE *argv, VALUE self) {
  say_vertex *vertex = ray_rb2vertex(self);

  VALUE pos, col, tex;
  rb_scan_args(argc, argv, "03", &pos, &col, &tex);

  vertex->pos = NIL_P(pos) ? say_make_vector2(0, 0) : ray_convert_to_vector2(pos);
  vertex->col = NIL_P(col) ? say_make_color(255, 255, 255, 255) : ray_rb2col(col);
  vertex->tex = NIL_P(tex) ? say_make_vector2(0, 0) : ray_convert_to_vector2(tex);

  return self;
}

Instance Method Details

#colRay::Color Also known as: color

Returns Color of the vertex.

Returns:


70
71
72
73
# File 'ext/vertex.c', line 70

static
VALUE ray_vertex_col(VALUE self) {
  return ray_col2rb(ray_rb2vertex(self)->col);
}

#col=(val) ⇒ Object Also known as: color=


75
76
77
78
79
80
# File 'ext/vertex.c', line 75

static
VALUE ray_vertex_set_col(VALUE self, VALUE val) {
  rb_check_frozen(self);
  ray_rb2vertex(self)->col = ray_rb2col(val);
  return val;
}

#posRay::Vector2 Also known as: position

Returns Position of the vertex.

Returns:


44
45
46
47
# File 'ext/vertex.c', line 44

static
VALUE ray_vertex_pos(VALUE self) {
  return ray_vector2_to_rb(ray_rb2vertex(self)->pos);
}

#pos=(val) ⇒ Object Also known as: position=


49
50
51
52
53
54
# File 'ext/vertex.c', line 49

static
VALUE ray_vertex_set_pos(VALUE self, VALUE val) {
  rb_check_frozen(self);
  ray_rb2vertex(self)->pos = ray_convert_to_vector2(val);
  return val;
}

#pretty_print(q) ⇒ Object


20
21
22
# File 'lib/ray/vertex.rb', line 20

def pretty_print(q)
  pretty_print_attributes q, ["pos", "col", "tex"]
end

#texRay::Vector2

Returns Texture position of the vertex.

Returns:


57
58
59
60
# File 'ext/vertex.c', line 57

static
VALUE ray_vertex_tex(VALUE self) {
  return ray_vector2_to_rb(ray_rb2vertex(self)->tex);
}

#tex=(val) ⇒ Object


62
63
64
65
66
67
# File 'ext/vertex.c', line 62

static
VALUE ray_vertex_set_tex(VALUE self, VALUE val) {
  rb_check_frozen(self);
  ray_rb2vertex(self)->tex = ray_convert_to_vector2(val);
  return val;
}

#tex_xObject


14
# File 'lib/ray/vertex.rb', line 14

def tex_x; tex.x; end

#tex_x=(val) ⇒ Object


17
# File 'lib/ray/vertex.rb', line 17

def tex_x=(val); self.tex = [val, tex_y]; end

#tex_yObject


15
# File 'lib/ray/vertex.rb', line 15

def tex_y; tex.y; end

#tex_y=(val) ⇒ Object


18
# File 'lib/ray/vertex.rb', line 18

def tex_y=(val); self.tex = [tex_x, val]; end

#xObject


8
# File 'lib/ray/vertex.rb', line 8

def x; pos.x; end

#x=(val) ⇒ Object


11
# File 'lib/ray/vertex.rb', line 11

def x=(val); self.pos = [val, y]; end

#yObject


9
# File 'lib/ray/vertex.rb', line 9

def y; pos.y; end

#y=(val) ⇒ Object


12
# File 'lib/ray/vertex.rb', line 12

def y=(val); self.pos = [x, val]; end