Sha256: 55ad22108ef5fc4a9ea8e6161d7d5c0ce15e409652c4c22cd075fdd211233cab

Contents?: true

Size: 953 Bytes

Versions: 10

Compression:

Stored size: 953 Bytes

Contents

# Get Child. 
# 
# SVG files can be made of many individual shapes. 
# Each of these shapes (called a "child") has its own name 
# that can be used to extract it from the "parent" file.
# This example loads a map of the United States and creates
# two new PShape objects by extracting the data from two states.
#

attr_reader :usa, :michigan, :ohio

def setup
  size(640, 360)  
  @usa = load_shape("usa-wikipedia.svg")
  @michigan = usa.get_child("MI")
  @ohio = usa.get_child("OH")
end

def draw
  background(255)
  
  # Draw the full map
  shape(usa, -600, -180)
  
  # Disable the colors found in the SVG file
  michigan.disableStyle
  # Set our own coloring
  fill(0, 51, 102)
  no_stroke
  # Draw a single state
  shape(michigan, -600, -180) # Wolverines!
  
  # Disable the colors found in the SVG file
  ohio.disable_style
  # Set our own coloring
  fill(153, 0, 0)
  no_stroke
  # Draw a single state
  shape(ohio, -600, -180)  # Buckeyes!
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ruby-processing-2.6.3 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.6.2 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.6.1 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.6.0 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.5.1 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.5.0 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.4.4 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.4.3 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.4.2 samples/processing_app/basics/shape/get_child.rb
ruby-processing-2.4.1 samples/processing_app/basics/shape/get_child.rb