Skip to content

File loading is relative to the electron subdirectory instead of the sketch or data folder #19

@davepagurek

Description

@davepagurek

Most appropriate sub-area of Processing 4?

IO

Processing version

p5 mode 0.6

Operating system

MacOS 15.2

Bug description

It looks like currently one needs to load files in the sketch folder by navigating up a directory in the file path. Maybe electron/index.html needs a <base> tag to change the relative path root to be ../data?

Steps to reproduce this

I put this code in sketch..js and dropped a file called data/test.png next to it:

let img

async function setup() {
  createCanvas(400, 400);

  // This does not work:
  // img = await loadImage('test.png')

  // This works:
  img = await loadImage('../data/test.png')
}

function draw() {
  background(220);
  image(img, 0, 0, width, height)
}

snippet

// Paste your code below :)

void setup() {

}

void draw() {

}

Additional context

Another thought: the data/ directory thing is also a Processing thing, coming from p5 there's not usually any special handling of a data/ folder. I feel like making data/ the root makes sense when migrating from Processing, but was not initially on my radar as a thing to try when converting a regular p5 sketch. Maybe this could be accompanied by some docs or examples saying to use data? And possibly initializing an empty data folder when you create a project?

Would you like to work on the issue?

No, I’m just reporting the issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions