# Create sliding loop

**URL:** <https://discourse.processing.org/t/create-sliding-loop/27409>\
**Category:** Coding Questions\
**Created:** [January 27, 2021, 2:01pm UTC](https://discourse.processing.org/t/create-sliding-loop/27409 "2021-01-27T14:01:41Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![javagar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/javagar/32/11434_2.png) [@javagar](https://discourse.processing.org/u/javagar)\
**Post date:** [January 27, 2021, 2:32pm UTC](https://discourse.processing.org/t/create-sliding-loop/27409/2 "2021-01-27T14:32:32Z")

</div>

Hi @codeflow,

Below is an example that was inspired by code from your previous thread, [Translating Processing to P5js](https://discourse.processing.org/t/translating-processing-to-p5js/27332). It might not be exactly what you want, but you may be able to adapt it to your needs.

```auto
// code originally by codeflow

let montserrat;
function preload() {
    montserrat = loadFont("Montserrat-Bold.otf"); 
}

function setup() {
    createCanvas(1200, 800);
}

function draw() {
    // set up environment
    background(240);
    textAlign(CENTER, CENTER);
    textFont(montserrat);
    fontSize = 144;
    textSize(fontSize);
    rectMode(CENTER);
    noStroke();
    let spacing_buffer = 600;
    // set up text strings
    let alpha = "Alpha";
    let beta = "Beta";
    let gamma = "Gamma";
    // draw text and rectangle
    fill(0);
    text(alpha, frameCount * 1.9 % (width + spacing_buffer) - spacing_buffer / 2, 70);
    fill(0);
    rect(width / 2, height * 3 / 8, width, height / 4);
    fill(255);
    text(beta, frameCount * 2.7 % (width + spacing_buffer) - spacing_buffer / 2, 140 + fontSize);
    fill(0);
    text(gamma, frameCount * 3.0 % (width + spacing_buffer) - spacing_buffer / 2, 220 + 2 * fontSize);
}

```

You will need to substitute your own file for `"Montserrat-Bold.otf"` for it to work.

_Edited on January 27, 2021 to place comments in the code._

---

_[View the full topic](https://discourse.processing.org/t/create-sliding-loop/27409)._
