Skip to content

Commit 799f95a

Browse files
committed
Add p5js mode PoC into Processing repo
Allow console output in Electron renderer process to be sent to main process
1 parent 3f36db5 commit 799f95a

File tree

11 files changed

+1414
-1
lines changed

11 files changed

+1414
-1
lines changed

p5js/build.gradle.kts

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
plugins {
2+
kotlin("jvm") version "2.0.20"
3+
kotlin("plugin.serialization") version "1.9.0"
4+
}
5+
6+
group = "org.processing"
7+
version = "1.0-SNAPSHOT"
8+
9+
repositories {
10+
mavenCentral()
11+
google()
12+
maven { url = uri("https://jogamp.org/deployment/maven") }
13+
}
14+
15+
dependencies {
16+
// compileOnly(files("/Applications/Processing.app/Contents/Java/pde.jar/**/"))
17+
implementation(project(":core"))
18+
implementation(project(":app"))
19+
20+
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3")
21+
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.5.1")
22+
23+
testImplementation(kotlin("test"))
24+
}
25+
26+
project(":app").tasks.named("run").configure {
27+
dependsOn(tasks.named("installLibrary"))
28+
}
29+
tasks.create<Copy>("copyJars") {
30+
group = "processing"
31+
dependsOn(tasks.jar)
32+
from(layout.buildDirectory.dir("libs")){
33+
include("**/*.jar")
34+
}
35+
from(configurations.compileClasspath)
36+
into(layout.buildDirectory.dir("library/mode"))
37+
duplicatesStrategy = DuplicatesStrategy.INCLUDE
38+
}
39+
tasks.create<Copy>("createLibrary") {
40+
group = "processing"
41+
from("library")
42+
into(layout.buildDirectory.dir("library"))
43+
}
44+
tasks.create<Copy>("installLibrary") {
45+
group = "processing"
46+
dependsOn(tasks.named("createLibrary"))
47+
dependsOn(tasks.named("copyJars"))
48+
from(layout.buildDirectory.dir("library"))
49+
into("${System.getProperty("user.home")}/sketchbook/modes/p5js")
50+
}
51+
//tasks.register<JavaExec>("runProcessing") {
52+
// dependsOn(tasks.named("installLibrary"))
53+
// group = "processing"
54+
// classpath = files(fileTree("/Applications/Processing.app/Contents/Java/"){
55+
// include("*.jar")
56+
// })
57+
// mainClass.set("processing.app.Base") // Your main class
58+
//
59+
// // Optional: Add arguments if needed
60+
// args = listOf("")
61+
//
62+
// // Optional: Add JVM arguments if needed
63+
// jvmArgs = listOf("-Xmx2g")
64+
//}
65+
tasks.jar {
66+
archiveVersion.set("")
67+
archiveBaseName.set("p5js")
68+
}
69+
tasks.test {
70+
useJUnitPlatform()
71+
}
72+
kotlin {
73+
jvmToolchain(17)
74+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
const fs = require('fs');
2+
3+
let version
4+
function setup() {
5+
createCanvas(400, 400);
6+
7+
// Read a file (for example, package.json)
8+
fs.readFile('package.json', 'utf8', (err, data) => {
9+
if (err) {
10+
console.error('Error reading file:', err);
11+
return;
12+
}
13+
var json = JSON.parse(data)
14+
version = json.version;
15+
});
16+
}
17+
18+
function draw() {
19+
background(220);
20+
21+
textAlign(CENTER)
22+
text(`I'm version ${version}`, width / 2, height / 2)
23+
}

0 commit comments

Comments
 (0)