Skip to content

Commit

Permalink
Merge Processing.js v1.3.0 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jbuck committed Aug 23, 2011
2 parents 29093c5 + ba1e2f6 commit d940447
Show file tree
Hide file tree
Showing 416 changed files with 9,054 additions and 10,740 deletions.
2 changes: 2 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ Minoo Ziaei
Ricard Marxer
Matt Postill
Tiago Moreira
Jonathan Brodsky
Roger Sodre
84 changes: 84 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,87 @@
August 24, 2011 - Release 1.3.0

* Added a chart to the perf test suite
* Added an error message to the ref test builder if 'exit()' is not found in the sketch
* Added blendColor ref tests
* Added codePointAt to the String object
* Added documentation to toP5String function
* Added equalsIgnoresCase to String object
* Added error messages to beginCamera and endCamera when used in 2D mode
* Added error messages to Processing file and I/O functions that are unsupported by Processing.js
* Added printMatrix unit tests
* Added resetMatrix unit tests
* Added rounded rect
* Added screenWidth and screenHeight variables to match Processing v2.0
* Added script to build process to replace PConstants.* with their numerical values
* Added startsWith and endsWith to the String object
* Added support for external javascript code to add images to the imageCache
* Added tint perf and ref tests
* Added toArray() to the Array object
* Added transparency perf test
* Changed function(){} to the Processing local variable 'nop'
* Changed obj.constructor type-checking to typeof(obj)
* Changed perf tests to use exit()
* Changed Processing.js errors to throw instead of print to tinylog
* Converted animated test suite tests to ref tests
* Converted XMLElement unit tests to use XMLElement.parse(string) instead of XMLElement(string)
* Fixed crisp not working properly when any transformations were applied to the sketch
* Fixed CSS font declaration when using SVG fonts
* Fixed default vertical align in textMode(halign, valign) to BASELINE
* Fixed equalsIgnoreCase to use toLowerCase rather than RegEx(//i)
* Fixed fake-dom.js returning the same canvas every time createElement is called
* Fixed font metrics (textAscent, textDescent, etc.)
* Fixed font preloading not checking whether a @font-face rule already exists
* Fixed font preloading to use tinyfont
* Fixed font quoting bug in computeFontMetrics
* Fixed HashMap.values() so that it returns an ArrayList
* Fixed hex literal #FFFFFF not being converted to an int properly
* Fixed HSB functions ignoring colorMode range in grayscale
* Fixed httpd.py webserver to be multi-threaded and MSIE compatible
* Fixed image() not working in 3D mode
* Fixed lerpColor generating incorrect values in HSB color mode
* Fixed make release-files creating the temporary file in the wrong directory
* Fixed mandelbrot.pde and histogram.pde ref tests
* Fixed MSIE crash when loading from a <script> element
* Fixed negative color and opacity values returning incorrect results
* Fixed performance loss when drawing images at fractional co-ordinates
* Fixed PImage.get not returning valid data
* Fixed rectMode() regressions caused by @pjs crisp removal
* Fixed runtests.py to use Unix paths only
* Fixed screenXYZ.pde unit test
* Fixed sketch starting before font preloading is done
* Fixed smooth() and noSmooth() to use new image-rendering modes
* Fixed SVG loading in Opera
* Fixed SVG path handling for 'z' and 'Z'
* Fixed text-width.pde ref test to use the correct font
* Fixed text$4 and text$6 font alignment
* Fixed textAlign and textMode not getting saved in pushStyle() and popStyle()
* Fixed textSize not caching textAscent, textDescent, and textLeading
* Fixed tint() to work with texture()
* Fixed vertex() not working with optional parameters
* Fixed vertical align behaviour
* Fixed XMLElement.parse when parsing a string with '.svg' or '.xml'
* Improved the performance of blend modes
* Improved the performance of blend()
* Improved the performance of images created with createImage()
* Improved the performance of PVector
* Reduced the number of canvas objects the ref test runner creates so that tests pass on Chrome in Windows
* Refactored forwardTransform and reverseTransform into modelView and modelViewInverse
* Refactored PFont
* Refactored point(), line(), and rect() to draw crisp lines
* Refactored Processing.js to have no else after return or throw
* Refactored unbinary()
* Removed @pjs crisp directive
* Removed color profiles from all images used in our ref test suite
* Removed comments from the release version of Processing.js
* Removed reliance on use3DContext variable
* Removed textMode(SCREEN)
* Removed unused 'Keys and Keystrokes' variables
* Removed unused function colorBlendWithAlpha
* Removed use of .apply(this, arguments)
* Removed use of parseFloat and parseInt as cast operators
* Replaced 'new Date().getTime()' with 'Date.now()'
* Switched back to YUI compressor for this release, as Google Closure was producing buggy code

July 14, 2011 - Release 1.2.3

* Added a note to the test suite about Opera failing Cursor
Expand Down
35 changes: 21 additions & 14 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ VERSION ?= $(shell git show -s --pretty=format:%h)
# On Windows? You can specify a FIND value for your cygwin/msys find command
FIND ?= /usr/bin/find

TMP := $(RELEASE_DIR)/.__tmp_file__
TMP := .__tmp_file__
QUIET := > $(TMP) ; rm -f $(TMP)

EMPTY :=
Expand All @@ -43,6 +43,7 @@ EXAMPLES_DIR :=$(PJS_RELEASE_PREFIX)-examples
TOOLS_DIR :=$(SRC_DIR)/tools
FAKE_DOM :=$(TOOLS_DIR)/fake-dom.js
CLOSUREJAR :=$(TOOLS_DIR)/closure/compiler.jar
YUIJAR :=$(TOOLS_DIR)/yui/yuicompressor-2.4.6.jar
RUNTESTS :=@@$(TOOLS_DIR)/runtests.py $(JSSHELL)
RUNJS :=@@$(JSSHELL) -f $(FAKE_DOM) -f

Expand All @@ -52,7 +53,12 @@ SKETCHOUTPUTSRC ?=$(SKETCHINPUT).src
SKETCHOUTPUT ?=$(SKETCHINPUT).js

preprocess =@@$(JSSHELL) -f $(TOOLS_DIR)/jspreprocess.js -e "PARSER=false;preprocess();" < $(2) >> $(1)
compile =@@java -jar $(CLOSUREJAR) --js="$(1)" --js_output_file="$(2)" $(3) --jscomp_off=nonStandardJsDocs

# Both Google Closure and YUI are in our tree. Switch compile below to whichever.
compile_closure =@@java -jar $(CLOSUREJAR) --js="$(1)" --js_output_file="$(2)" $(3) --jscomp_off=nonStandardJsDocs
compile_yui =@@java -jar $(YUIJAR) -o "$(2)" "$(1)"
compile=$(compile_yui)

copydir = @@cp -R "$(1)" "$(2)" $(QUIET) && $(FIND) $(RELEASE_DIR) -type f \( -iname '*.DS_Store' -o \
-iname 'desktop.ini' -o \
-iname 'Thumbs.db' \) -delete
Expand Down Expand Up @@ -111,19 +117,20 @@ examples: $(PJS_RELEASE_SRC)
@@cd $(RELEASE_DIR); zip -r $(PJS_VERSION_FULL)-examples.zip $(PJS_VERSION)-examples $(QUIET)
@@rm -fr $(EXAMPLES_DIR)

pretty: $(PJS_RELEASE_SRC)
@@echo "Creating beautified processing.js..."
@@$(TOOLS_DIR)/jsbeautify.py $(JSSHELL) $(PJS_RELEASE_SRC) > $(PJS_RELEASE_SRC).tmp
@@$(JSSHELL) -f $(FAKE_DOM) -f $(PJS_RELEASE_SRC).tmp
@@mv $(PJS_RELEASE_SRC).tmp $(PJS_RELEASE_SRC)

extensions: release-dir
@@echo "Copying extensions..."
@@$(call copydir,$(SRC_DIR)/extensions,$(RELEASE_DIR))

$(PJS_RELEASE_SRC): release-dir
@@echo "Creating processing.js..."
@@cp $(PJS_SRC) $(PJS_RELEASE_SRC)
$(PJS_RELEASE_SRC): $(PJS_SRC) release-dir
@@echo "Creating $(PJS_RELEASE_SRC)..."
@@$(call compile,$(PJS_SRC),$(RELEASE_DIR)/closurecompile.out,--compilation_level WHITESPACE_ONLY)
@@$(JSSHELL) -f $(TOOLS_DIR)/fake-dom.js \
-f $(PJS_SRC) \
$(TOOLS_DIR)/rewrite-pconstants.js < $(RELEASE_DIR)/closurecompile.out > \
$(RELEASE_DIR)/processing.js-no-pconstants
@@$(TOOLS_DIR)/jsbeautify.py $(JSSHELL) $(RELEASE_DIR)/processing.js-no-pconstants > $(PJS_RELEASE_SRC)
@@rm -f $(RELEASE_DIR)/closurecompile.out
@@rm -f $(RELEASE_DIR)/processing.js-no-pconstants
@@$(call addlicense,$(PJS_RELEASE_SRC),$(EMPTY))
@@$(call addversion,$(PJS_RELEASE_SRC),$(EMPTY))
@@$(RUNJS) $(PJS_RELEASE_SRC)
Expand Down Expand Up @@ -175,9 +182,9 @@ check-globals:
print-globals:
@@$(RUNJS) $(TOOLS_DIR)/jsglobals.js -e "printNames()" < $(PJS_SRC)

closure: $(PJS_SRC) release-dir
closure: $(PJS_RELEASE_SRC) release-dir
@@echo "Compiling processing.js with closure..."
@@$(call compile,$(PJS_SRC),$(PJS_RELEASE_MIN),$(EMPTY))
@@$(call compile,$(PJS_RELEASE_SRC),$(PJS_RELEASE_MIN),$(EMPTY))
@@$(call addlicense,$(PJS_RELEASE_MIN),$(EMPTY))
@@$(call addversion,$(PJS_RELEASE_MIN),$(EMPTY))
@@$(RUNJS) $(PJS_RELEASE_MIN)
Expand All @@ -200,7 +207,7 @@ package-sketch: $(PJS_SRC)

api-only: $(PJS_RELEASE_SRC)
@@echo "Creating processing.js API version..."
@@$(call preprocess,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_SRC))
@@$(call preprocess,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_RELEASE_SRC))
@@$(call addlicense,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_API_SUFFIX))
@@$(call addversion,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_API_SUFFIX))
@@$(call compile,$(PJS_RELEASE_PREFIX)-api.js,$(PJS_RELEASE_PREFIX)-api.min.js,$(EMPTY))
Expand Down
21 changes: 21 additions & 0 deletions examples/custom/fullscreen.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<title>Full Screen Sketch with screenWidth and screenHeight</title>
<script src="../../processing.js"></script>
<style>
body { margin: 0; padding 0; }
</style>
<body>
<script type="application/processing" data-processing-target="canvas">
void setup() {
size(screenWidth, screenHeight);
}

void draw() {
line(0, 0, screenWidth, screenHeight);
}
</script>
<canvas id="canvas"></canvas>
</body>
</html>
94 changes: 94 additions & 0 deletions examples/js/imagecache-js.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<!DOCTYPE html>
<html>
<head>
<script src="../../processing.js"></script>
<link rel="stylesheet" href="../style.css"/></head>
<body><h1><a href="http://processingjs.org/">Processing.js</a></h1>
<h2>Adding existing images to a Sketch's ImageCache</h2>

<div style="margin:20px;">
<h3>Example 1. Loading an image from the DOM</h3>
<p>Sometimes a developer wants to share images between a Processing sketch and the web page in which it lives. This might happen in a complex page where images are loaded at different times, and a sketch runs after the images are loaded by the web page itself. In such cases, it is helpful to be able to pass a preloaded image into the sketch's image cache, so it won't get loaded a second time before the sketch starts. The following example demonstrates this, by loading an image into the DOM by means of the img element, and then creating a Processing Sketch object in JavaScript that uses this image, without doing any other preloading.</p>
<h4>Image Element</h4><div><img id="pjs-logo" src="pjs.png" onload="loadDOMExample();"></div>
<h4>Processing Sketch in Canvas</h4><div><canvas id="canvas1"></canvas></div>
<script id="script1">
/**
* This sketch starts after an img element in the DOM finishes loading.
* The img element's onload attribute is used to let Processing know when
* it is safe to start the sketch.
*/
function loadDOMExample() {
var canvas1 = document.getElementById('canvas1'),
sketch = new Processing.Sketch(function(p) {
var pimg;
p.setup = function() {
p.size(200,200);
pimg = p.loadImage("pjs.png");
};

p.draw = function() {
p.background('#ffffff');
p.image(pimg, 0, 0);
};
});

sketch.imageCache.add("pjs.png", document.getElementById('pjs-logo'));

return new Processing(canvas1, sketch);
}
</script>

<pre id="code1"></pre>
<script>
document.getElementById("code1").textContent = document.getElementById("script1").text;
</script>
</div>

<div style="margin:20px;">
<h3>Example 2. Loading an image using only JavaScript</h3>
<p>This example is similar to Example 1, but bypasses the DOM altogether and creates an image using JavaScript. This technique is useful when you want to background load images, but not display them yet.</p>
<canvas id="canvas2"></canvas>
<script id="script2">
/**
* This sketch demonstrates how to load images via JS or the DOM separate to
* processing.js, and then pass these fully loaded images into a sketch's
* image cache, to be used by functions like loadImage(). Normally the image
* cache assumes that images need to be downloaded (e.g., only a URL is provided).
* However, an optional img argument (e.g., an Image) can be passed in too.
*/
var logo = new Image(),
canvas2 = document.getElementById('canvas2'),
sketch,
p;

// Start the sketch only after the image is fully loaded via pure JS
logo.onload = function() {
sketch = new Processing.Sketch(function(p) {
var pimg;
p.setup = function() {
p.size(200,200);
pimg = p.loadImage("pjs.png");
};

p.draw = function() {
p.background('#ffffff');
p.image(pimg, 0, 0);
};
});

sketch.imageCache.add("pjs.png", logo);

p = new Processing(canvas2, sketch);
};

// Load the image
logo.src = "pjs.png";
</script>

<pre id="code2"></pre>
<script>
document.getElementById("code2").textContent = document.getElementById("script2").text;
</script>
</div>
</body>
</html>
22 changes: 0 additions & 22 deletions examples/seneca/PMatrix3D/0.5tests.js

This file was deleted.

0 comments on commit d940447

Please sign in to comment.