Sha256: 9608db381fa17760a40d3964401a654e258696a2fd49867c55842177fcaf1bde
Contents?: true
Size: 888 Bytes
Versions: 4
Compression:
Stored size: 888 Bytes
Contents
# The bubble library, include BubbleStruct class Bubble include Processing::Proxy attr_reader :x, :y, :diameter, :name, :over # Create the Bubble def initialize(x, y, diameter, name) @x = x @y = y @diameter = diameter @name = name @over = false end # Checking if mouse is over the Bubble def rollover(px, py) d = dist(px,py,x,y) @over = (d < diameter/2)? true : false end # Display the Bubble def display stroke(0) stroke_weight(2) noFill ellipse(x,y,diameter,diameter) if (over) fill(0) text_align(CENTER) text(name, x, y + diameter/2 + 20) end end def to_hash {"position" => {"x" => x, "y" => y}, "diameter" => diameter, "label" => name} end def to_struct BubbleStruct.new(x, y, diameter, name) end end BubbleStruct = Struct.new(:x, :y, :diameter, :label)
Version data entries
4 entries across 4 versions & 1 rubygems