| Class | Shape |
| In: |
rubycube.c
|
| Parent: | Object |
Document-method: pos_x call-seq:
Shape.pos_x -> number
Returns the X component of the shape position.
Returns a custom shape by specifying the underlying graphics format and size of the buffer of elements. This is an advanced method and extra care should be taken.
x Initial position.x for translation y Initial position.y for translation format Underlying format to use for the shape. (see SHAPE_FORMAT_* constants) count Number of elements stored in the underlying vertex buffer and submitted
to the GPU.
Returns a new shape defined as a strip of lines where lines are connected from the first point to the last. Points n and n+1 define line n. N-1 lines are drawn.
The first parameter ‘format’ specifies how many elements define a single point. This could also be defined as the ‘stride’ of the input set.
Return a new 2D rectangle or square shape with the provided x, y, width and height. The scalars can be presented in whatever format is most convient.
Return a new 2D rectangle or square shape with the provided x, y, width and height. The scalars can be presented in whatever format is most convient.
Document-method: Shape.show
Toggle visibility for a shape off.
Move a shape position over time in a desired direction
# Move 10 units up and 10 units right for 2 seconds shape.move([10, 10], 2) # Move 10 units left immediately shape.move([-10, 0], 0) # Set a velocity of +1 in the x direction per second shape.move([1, 0], -1)
Move a shape in circle according to the parameters.
# Move towards point 10, 10 for 2 seconds shape.move_to(10, 10, 0, 2)
Move a shape position over time to a destination point
target = [10, 10] # Move to 10, 10 over 2 seconds shape.move_to(target, 2) # Move to 10, 10 instantly shape.move_to(target, 0)
Rotate a shape about the axis that passes through the camera with 2 parameters. Otherwise if all ijk vector components are specified rotate about i, j, k vectors by specified ammounts.
As with other animations -1 is infinite and treats the parameters as units/sec. Duration of 0 seconds is instant. Other durations will divide the ammount of rotation over the desired duration to arrive at the specified configuration when desired.
# In 2D rect = Shape.rect(100, 100, 50, 80) rect.rotate(45, 0) # instantly rotate 45 degrees rect.rotate(10, -1) # rotate 10 degrees a second forever rect.rotate(-45, 1) # rotate 45 degrees in 1 second # In 3D cube.rotate(10, 0, 0, 1) # rotate around the axis 10 deg in 1 second
+offset_x+ X offset from shape position in screen coords to show label +offset_y+ Y offset from shape position in screen coords to show label +string+ String value of label
Toggle visibility for a shape on.
circle = Shape.circle(10, 10, 100) circle.hide() circle.show()
c = Shape.circle(0, 0, 10) c.vel_x = 10 # begin moving 10 units/sec in the positive X
Returns the current Y component of the velocity.
c = Shape.circle(0, 0, 10)
puts "Current velocity #{c.vel_x}, #{c.vel_y}, #{c.vel_z}"
c = Shape.circle(0, 0, 10) c.vel_y = 10 # begin moving 10 units/sec in the positive Y
Returns the current Z component of the velocity.
c = Shape.circle(0, 0, 10)
puts "Current velocity #{c.vel_x}, #{c.vel_y}, #{c.vel_z}"
c = Shape.circle(0, 0, 10) c.vel_z = 10 # begin moving 10 units/sec in the positive Z