Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
# Processing.py (for skulpt)

This is a package for [skulpt] or on [github]. It implements as much of the Processing.py functions as possible. It is based on Processing.js.

## Instalation

When skulpt looks for `processing/__init__.js` return `skulpt_module/__init__.js`. Make sure that at that time `processing-sk.js` or `processing-sk-min.js` is loaded.

There are a few things you can configure before running processing in skulpt. After you've loaded `processing-sk(-min).js`. You can call `ProcessingSk.initProcessing` with a suspensionHandler, a breakHandler, and a eventPredicate. These things are:

- `suspensionHandler`: if you specify one in skulpt it makes sense to specify the same here. It gives you a way to handle suspensions differently or do something when a suspension is being handled it is an object with the suspension type and a function. Something like this:

```
{
'*': function() {
// do something here
}
}
```

- `breakHandler`: a break handler is needed to be able to stop processing.sk. Because processing.sk has a run loop outside skulpt you might want to implement a way to stop processing. The breakHandler is a function that gets called every run loop, so it should do as little as possible. You could have a global interrupt variable and throw an error when it's truthy. Something like this:

```
function () {
if (window.InterruptProcessing) {
throw new Error('interrupt');
}
}
```

- `eventPredicate`: a function that filters which events should be handled by processing.sk. Processing reacts to all global events that bubble up to the window. So if you want to filter out events that control your application for example key press events on your editor. This is where you do that. It'll look something like this:

```
var editor = document.getElementById('editor');

function(event) {
if (editor.contains(e.target)) {
return false
}
}


[skulpt]: http://skulpt.org
[github]: http://github.com/skulpt/skulpt
```
3,368 changes: 2,554 additions & 814 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 25 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "processing.sk",
"version": "0.0.6",
"version": "0.0.12",
"description": "A python interface for processing.js for skulpt",
"main": "main.js",
"browserslist": "> 0.2%, ie=10",
Expand All @@ -17,12 +17,30 @@
"license": "MIT",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/core": "^7.4.5",
"@babel/plugin-transform-object-assign": "^7.2.0",
"@babel/preset-env": "^7.4.5",
"eslint": "^5.5.0",
"rollup": "^0.65.2",
"rollup-plugin-babel": "^4.0.3",
"uglify-js": "^3.1.9"
"husky": "^2.5.0",
"lint-staged": "^8.2.1",
"prettier": "1.18.2",
"rollup": "^1.16.2",
"rollup-plugin-babel": "^4.3.3",
"uglify-js": "^3.6.0"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,css,json,md}": [
"prettier --write",
"git add"
],
"*.js": [
"eslint --fix",
"git add"
]
}
}
2 changes: 1 addition & 1 deletion processing-sk-min.js

Large diffs are not rendered by default.

Loading