# Polyglot programming in ruby and python

**URL:** <https://discourse.processing.org/t/polyglot-programming-in-ruby-and-python/32215>\
**Category:** Gallery\
**Created:** [September 12, 2021, 10:49am UTC](https://discourse.processing.org/t/polyglot-programming-in-ruby-and-python/32215 "2021-09-12T10:49:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![monkstone](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/monkstone/32/64_2.png) [@monkstone](https://discourse.processing.org/u/monkstone)\
**Post date:** [September 12, 2021, 10:49am UTC](https://discourse.processing.org/t/polyglot-programming-in-ruby-and-python/32215/1 "2021-09-12T10:49:42Z")

</div>

Recently Jorg Kantel has taken an interest in [py5](http://py5.ixora.io/) see his recent [blog entry here](http://blog.schockwellenreiter.de/2021/09/2021091201.html). Previously I have had some fun translating his python sketches to ruby, here is the py5 Sine Wave sketch translated to JRubyArt:-

```ruby
R1 = 100 # Radius large circle
R2 = 5 # Radius smaller circles
attr_reader :t, :circle_list

def settings
  size(600, 600)
end

def setup
  sketch_title 'Sine Wave Generator'
  @t = 0
  @circle_list = Array.new(199, 0)
end

def draw
  background(132, 144, 163)
  translate(width / 4, height / 2) # center sketch
  no_fill # Don't fill larger circle
  stroke(0) # Outline: black
  circle(0, 0, 2 * R1)
  fill(250, 0, 0, 150) # semi transparent smaller circles
  y = R1 * sin(t) # coordinates large circle
  x = R1 * cos(t)
  circle(x, y, 2 * R2)
  # Insert one point at beginning of circle_list
  circle_list.unshift y
  circle_list.pop
  no_stroke
  fill(0, 255, 0, 150) # semi transparent light green
  # create ribbon trail from list
  circle_list.each_with_index do |hgt, idx|
    circle(200 + idx, hgt, R2)
  end
  stroke(0, 250, 0) # Green for connecting line …
  line(x, y, 200, y)
  fill(0, 250, 0, 150) # and small end point
  stroke(0)
  circle(200, y, 2 * R2)
  @t += 0.05
end

```

 ![sine_wave](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/cac6213d28393e5181644e4831cb8fbd628a09c5.png)
