{"id":26110,"library":"processing-transpiler","title":"processing-transpiler","description":"A Node.js utility that converts Processing (Java-based) sketches into p5.js JavaScript code. Current stable version is 1.0.1. The tool parses Processing code using java-parser, applies transformations (e.g., converting size() to createCanvas()), and formats output with js-beautify. Unlike manual conversion or similar tools, it provides automated conversion with formatting. Release cadence is low; updates are occasional.","status":"active","version":"1.0.1","language":"javascript","source_language":"en","source_url":null,"tags":["javascript","processing","p5js","transpiler","pde"],"install":[{"cmd":"npm install processing-transpiler","lang":"bash","label":"npm"},{"cmd":"yarn add processing-transpiler","lang":"bash","label":"yarn"},{"cmd":"pnpm add processing-transpiler","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Parses Processing Java code into a concrete syntax tree","package":"java-parser","optional":false},{"reason":"Formats the generated JavaScript code","package":"js-beautify","optional":false}],"imports":[{"note":"ESM-only; CommonJS require is not supported.","wrong":"const convertToP5 = require('processing-transpiler')","symbol":"convertToP5","correct":"import { convertToP5 } from 'processing-transpiler'"},{"note":"Named export, not default.","wrong":"import convertToP5 from 'processing-transpiler'","symbol":"convertToP5","correct":"import { convertToP5 } from 'processing-transpiler'"},{"note":"The library also exports a class with additional options.","wrong":"import ProcessingTranspiler from 'processing-transpiler'","symbol":"ProcessingTranspiler","correct":"import { ProcessingTranspiler } from 'processing-transpiler'"}],"quickstart":{"code":"import { convertToP5 } from 'processing-transpiler';\n\nconst processingCode = `\nvoid setup() {\n  size(400, 400);\n}\n\nvoid draw() {\n  ellipse(mouseX, mouseY, 50, 50);\n}\n`;\n\nconst jsCode = convertToP5(processingCode);\nconsole.log(jsCode);\n// Output:\n// function setup() {\n//     createCanvas(400, 400);\n// }\n// function draw() {\n//     ellipse(mouseX, mouseY, 50, 50);\n// }","lang":"javascript","description":"Shows how to import and use the convertToP5 function to transpile a simple Processing sketch."},"warnings":[{"fix":"Ensure Processing code is syntactically correct Java-like code without unsupported constructs (e.g., classes, arrays).","message":"Mismatched braces or semicolons in Processing code can cause parse errors or incomplete transpilation.","severity":"breaking","affected_versions":"all"},{"fix":"Check the p5.js reference and manually adjust unsupported calls.","message":"Some Processing functions (e.g., smooth(), noSmooth()) may not be supported in p5.js; they are either skipped or cause warnings.","severity":"deprecated","affected_versions":"<1.1"},{"fix":"Manually translate class usage to p5.js equivalents (objects, functions).","message":"The library does not handle Processing's built-in classes (e.g., PVector, PFont) or custom Java classes.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Simplify code to basic functions and variables; avoid OOP constructs.","cause":"Processing code contains Java-specific syntax like classes, generics, or enhanced for-loops.","error":"SyntaxError: Unexpected token"},{"fix":"Use `import { convertToP5 } from 'processing-transpiler'`.","cause":"Using default import instead of named import.","error":"TypeError: convertToP5 is not a function"},{"fix":"Run `npm install processing-transpiler` and ensure the import path is correct.","cause":"Package not installed or wrong import path.","error":"Error: Cannot find module 'processing-transpiler'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}