Sha256: f4cd05bd400a907b1ef2e4f5e3816b8f3f3b9ec0d53036af011b7b29155a5ffb

Contents?: true

Size: 651 Bytes

Versions: 10

Compression:

Stored size: 651 Bytes

Contents

#
# PrimitivePShape. 
# 
# Using a PShape to display a primitive shape (in this case, ellipse). 
#


# The PShape object
attr_reader :circle

def setup 
  size(640, 360, P2D)
  # Creating the PShape as an ellipse
  # The corner is -50,-50 so that the center is at 0,0 
  @circle = create_shape(ELLIPSE, -50, -25, 100, 50)
end

def draw
  background(51)
  # We can dynamically set the stroke and fill of the shape
  circle.set_stroke(color(255))  
  circle.set_stroke_weight(4)
  circle.set_fill(color(map(mouseX, 0, width, 0, 255)))
  # We can use translate to move the PShape
  translate(mouse_x, mouse_y)
  # Drawing the PShape
  shape(circle)
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.6.2 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.6.1 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.6.0 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.5.1 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.5.0 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.4.4 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.4.3 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.4.2 samples/processing_app/topics/create_shapes/primitive_pshape.rb
ruby-processing-2.4.1 samples/processing_app/topics/create_shapes/primitive_pshape.rb