Dashed Lines library issue in Python mode

Hi guys,

I ran into an issue when using the Dashed Lines library in Python mode. Basically I would like to display a rectangle with dashed lines but it seems the library doesn’t work correctly when using Python mode.

In Java:

import garciadelcastillo.dashedlines.*;
DashedLines dash;

void setup() {
  size(800, 800);
  
  dash = new DashedLines(this);
  dash.pattern(30, 10, 15, 10);
}

void draw() {
  background(255);

  noFill();
  rectMode(CORNERS);
  dash.rect(200, 100, 400, 500);
    
}

in Python


add_library('dashedlines')

def setup():
    global dash
    size(800, 800, P2D)
    smooth(8)
    
    dash = DashedLines(this)
    dash.pattern(30, 10, 15, 10)
    
def draw():
    background(255)
    
    noFill()
    rectMode(CORNERS)
    dash.rect(200, 100, 400, 500)

Only ellipse seems to work ok on both mode.

Do you think there’s a way to overcome this issue ?

Java Mode:

import garciadelcastillo.dashedlines.DashedLines;
DashedLines dash;

static final String RENDER = JAVA2D; // Works!
//static final String RENDER = FX2D;   // Works!
//static final String RENDER = P2D;    // Fails!
//static final String RENDER = P3D;    // Fails!

void setup() {
  size(512, 480, RENDER);
  noLoop();

  rectMode(CENTER);
  noFill();
  stroke(#0000FF);
  strokeWeight(2.5);

  (dash = new DashedLines(this)).pattern(30, 10, 15, 10);
}

void draw() {
  background(0350);
  dash.rect(width>>1, height>>1, width>>2, height*.75);
}

Python Mode:

add_library('dashedlines')

RENDER = JAVA2D # Works!
# RENDER = FX2D   # Works!
# RENDER = P2D    # Fails!
# RENDER = P3D    # Fails!

def setup():
    size(512, 480, RENDER)
    noLoop()

    rectMode(CENTER)
    noFill()
    stroke(0xff0000FF)
    strokeWeight(2.5)

    global dash
    dash = DashedLines(this)
    dash.pattern(30, 10, 15, 10)


def draw():
    background(0350)
    dash.rect(width>>1, height>>1, width>>2, height*.75)
3 Likes

Thank you @GoToLoop !