# Rosetta Examples development

**URL:** <https://discourse.processing.org/t/rosetta-examples-development/18945>\
**Category:** Development\
**Created:** [March 23, 2020, 8:04pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945 "2020-03-23T20:04:11Z")\
**Posts on this page:** 20\
**Page:** 3

<div class="post-metadata">

**Author:** ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)\
**Post date:** [April 20, 2020, 4:32pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/41 "2020-04-20T16:32:03Z")

</div>

Thank you so much, @noel. The Floodfill looks great!

To fix the import issue on openprocessing, I think we could replace java.awt.Point with PVector. Could you try that? We might also need to / want to change the linkedlist / deque into ArrayList, I’m not sure.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 20, 2020, 5:36pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/42 "2020-04-20T17:36:30Z")

</div>

That’s already done. @GoToLoop made an excellent class. but unfortunately, it’s still not running on OpenProcessing. See [here](https://discourse.processing.org/t/linkedlist-vs-arraylist/19946/14).

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [April 21, 2020, 7:08am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/43 "2020-04-21T07:08:45Z")

</div>

> [@noel](#):
>
> @glv @paulstgeorge I know you are always busy to respond to the topics which is, of course, more relevant. But maybe you could help here now and then. There still are a lot of [tasks remaining to finish](https://www.rosettacode.org/wiki/Reports:Tasks_not_implemented_in_Processing)

Wow, this looks great fun. I am looking at all the unfinished topics looking for one to tackle. The Rosetta project shows the aesthetic beauty of code _ipso facto_. Sometimes the code is more beautiful than the output and too often hidden.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [April 21, 2020, 10:16pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/44 "2020-04-21T22:16:12Z")

</div>

I would like to play too! 😃

```python
from collections import deque

tolerance = 15
allowed = False

def setup():
    global img, fill_color
    size(600, 400)
    img = loadImage("image.png")
    fill_color = color(250, 0, 0)
    fill(0, 0, 100)

    image(img, 0, 0, width, height)
    textSize(18)
    text("Tolerance = {} (Use mouse wheel to change)".format(tolerance),
         100, height - 30)
    text("Right click to reset", 100, height - 10)

def draw():
    global allowed
    if allowed:
        image(img, 0, 0, width, height)
        text("Tolerance = {} (Use mouse wheel to change)".format(tolerance), 100, height - 30)
        text("Right click to reset", 100, height - 10)
        allowed = False

def mousePressed():
    global img, allowed
    img.loadPixels()
    flood(mouseX, mouseY)
    img.updatePixels()
    allowed = True
    if mouseButton == RIGHT:
        img = loadImage("image.png")

def mouseWheel(event):
    global allowed, tolerance
    e = event.getCount()
    tolerance += 2 * e
    if tolerance > 256:
        tolerance = 256
    if tolerance < 0:
        tolerance = 0
    allowed = True

def flood(x, y):
    target_color = img.pixels[pixel_position(mouseX, mouseY)]
    queue = deque()
    queue.append((x, y))
    while len(queue) > 0:
        p_x, p_y = queue.popleft()
        if (check(p_x, p_y, target_color)):
            queue.append((p_x, p_y - 1))
            queue.append((p_x, p_y + 1))
            queue.append((p_x - 1, p_y))
            queue.append((p_x + 1, p_y))

def pixel_position(x, y):
    return x + (y * img.width)

def check(x, y, target_color):
    if x < 0 or y < 0 or y >= img.height or x >= img.width:
        return False
    pp = img.pixels[pixel_position(x, y)]
    test_tolerance = (abs(green(target_color) - green(pp)) < tolerance
                      and abs(red(target_color) - red(pp)) < tolerance
                      and abs(blue(target_color) - blue(pp)) < tolerance)
    if not test_tolerance:
        return False
    img.pixels[pixel_position(x, y)] = fill_color
    return True

```

---

<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:** [April 22, 2020, 10:23am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/45 "2020-04-22T10:23:48Z")

</div>

@noel @villares me too. See on [rosetta code](https://rosettacode.org/wiki/Bitmap/Flood_fill#Ruby), I used suggested image, and this is the result:-  
 ![flood_fill](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8e347a256c7b6c21ade3437e18c4cbd64e9066b8.png)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 24, 2020, 9:43am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/46 "2020-04-24T09:43:57Z")

</div>

I’ve added a link to play the Bitmap/Floodfill task [here](http://www.rosettacode.org/wiki/Bitmap/Flood_fill#Processing). Unfortunately, if the Device Pixel Aspect Ratio of the monitor is not 1.00, the sketch will probably not run properly. This happens for instance when you chose a different text percentage (like 125%) in your “windows appearance” settings. You will have to zoom in/out on your browser to adjust this. This aspect ratio you can discover on [this](http://tombigel.github.io/detect-zoom/) site. If anyone knows a solution for this I will be grateful.

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 24, 2020, 9:48am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/47 "2020-04-24T09:48:16Z")

</div>

I’ve added the [Maze Generation](http://www.rosettacode.org/wiki/Maze_generation) task. Here is [a link](https://www.openprocessing.org/sketch/880778) to the animated version

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [April 25, 2020, 9:43pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/48 "2020-04-25T21:43:32Z")

</div>

It’s Brillant Maze Generation! Thank you very much!  
I have just ported it to Python mode: [http://www.rosettacode.org/wiki/Maze\_generation#Processing\_Python\_mode](http://www.rosettacode.org/wiki/Maze_generation#Processing_Python_mode)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [April 25, 2020, 10:40pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/49 "2020-04-25T22:40:05Z")

</div>

I am optimizing the variable names and adding comments for better understanding Also I am taking out some leftover garbage. So maybe you want to check this later on.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [April 26, 2020, 12:10am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/50 "2020-04-26T00:10:58Z")

</div>

> [@noel](#):
>
> So maybe you want to check this later on.

OK! Count on me, I’ll have a look.

---

<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:** [May 29, 2020, 7:55pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/51 "2020-05-29T19:55:51Z")

</div>

@jeremydouglass @villares Were you aware of processing ‘plasma effect’ example? I have ported it to JRubyArt [Plasma effect - Rosetta Code](http://rosettacode.org/wiki/Plasma_effect). I have also ported colored bars task.

---

<div class="post-metadata">

**Author:** ![villares](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/villares/32/3166_2.png) [@villares](https://discourse.processing.org/u/villares)\
**Post date:** [May 31, 2020, 7:08pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/52 "2020-05-31T19:08:23Z")

</div>

Cool! I’ll try my hand at porting 🙂

---

<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:** [June 17, 2020, 9:44pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/53 "2020-06-17T21:44:32Z")

</div>

@noel, @villares I’ve just posted a somewhat object orientated version of the [Sierpinski Pentagon](https://rosettacode.org/wiki/Sierpinski_pentagon#Ruby) on rosetta code. Possibly another task to try?

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [June 17, 2020, 11:05pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/54 "2020-06-17T23:05:17Z")

</div>

> [@paulstgeorge](#):
>
> Wow, this looks great fun. I am looking at all the unfinished topics looking for one to tackle.

@paulstgeorge You still want to join us? This is a nice one?  
Because this is the message I got from discourse:

### Let others join the conversation

> This topic is clearly important to you – you’ve posted more than 28% of the replies here.
> 
> It could be even better if you gave other people space to share their points of view, too. Can you invite them over?

---

<div class="post-metadata">

**Author:** ![paulstgeorge](https://avatars.discourse-cdn.com/v4/letter/p/53a042/32.png) [@paulstgeorge](https://discourse.processing.org/u/paulstgeorge)\
**Post date:** [June 19, 2020, 12:16pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/56 "2020-06-19T12:16:44Z")

</div>

> [@noel](#):
>
> It could be even better if you gave other people space to share their points of view, too.

@Noel The churlish bot has made a mistake. Its logic only works if there is a fixed amount of total space. Only then could you give others space by contributing less.

Anyway, I have looked again and now I know the task I want to tackle: [https://www.rosettacode.org/wiki/Combinations](https://www.rosettacode.org/wiki/Combinations).

I assume it is cheating (and boring) to import a library that does the task.

---

<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 1, 2020, 9:04am UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/57 "2020-09-01T09:04:02Z")

</div>

@noel @jeremydouglass @villares The Sierpinksi arrow head curve is missing for processing and python. I’ve just published the [JRubyArt version](https://rosettacode.org/wiki/Sierpinski_arrowhead_curve#Ruby). For the benefit of @villares heres a [sierpinski lsystem](https://github.com/monkstone/processing.py-examples/blob/master/LSystems/sierpinski.py) in processing.py I did earlier.

 ![sierpinski_arrowhead](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8d3e11b9836f5f491e94b03a8a37ee951d63e386.png)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 1, 2020, 1:02pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/58 "2020-09-01T13:02:04Z")

</div>

My second sketch in P5.js. Somewhat concise?  
But now I remember; it has to be in P5.java isn’t it?

```auto
const s = {x: 20, y: 30, angle: 60};

function setup() {
  createCanvas(450, 400);
  background(0, 0, 200);
  angleMode(DEGREES);
  stroke(255);
  sc(7, 400, -60);
}

function sc(o, l, angle) {
  if (o == 0) {
    const {x, y, angle} = s;
    s.x += cos(angle) * l;
    s.y += sin(angle) * l;
    line(x, y, s.x, s.y);
  } else {
    sc(o-1, l/2, -angle);
    s.angle += angle;
    sc(o-1, l/2, angle);
    s.angle += angle;
    sc(o-1, l/2, -angle);
  }
}

```

![sp](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/88deda549b778600a4641cefc4f9284fc33a030e.png)

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 1, 2020, 1:14pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/59 "2020-09-01T13:14:55Z")

</div>

> [@paulstgeorge](#):
>
> I know the task I want to tackle

Did you succeed?..

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [September 1, 2020, 3:03pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/60 "2020-09-01T15:03:03Z")

</div>

Your Sierpinski p5.js version w/ less lines: 🙃

```auto
"use strict";

const t = { x: 20, y: 30, a: 60 };

function setup() {
  createCanvas(450, 400);
  background(0, 0, 200).stroke(255).angleMode(DEGREES);
  sc(7, 400, -60);
}

function sc(o, l, a, s = t) {
  if (o) {
    sc(--o, l *= .5, -a).a += a;
    sc(o, l, a).a += a;
    sc(o, l, -a);
  } else line(s.x, s.y, s.x += cos(s.a) * l, s.y += sin(s.a) * l);
  return s;
}

```

---

<div class="post-metadata">

**Author:** ![noel](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/noel/32/213_2.png) [@noel](https://discourse.processing.org/u/noel)\
**Post date:** [September 1, 2020, 3:16pm UTC](https://discourse.processing.org/t/rosetta-examples-development/18945/61 "2020-09-01T15:16:37Z")

</div>

> [@GoToLoop](#):
>
> ```auto
> "use strict";
> 
> ```

I guess no one is going to beat that. 😀  
Maybe just removing"use strict"  
It isn’t strict necessary is it?  
Googled a bit, and it’s said that it’s good to get rid of many “silent” errors that can occur .  
Is that it?

[Previous page](https://discourse.processing.org/t/rosetta-examples-development/18945.md?page=2)

[Next page](https://discourse.processing.org/t/rosetta-examples-development/18945.md?page=4)
