propane 3.4.2-java → 3.5.0-java
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.mvn/wrapper/MavenWrapperDownloader.java +1 -1
- data/.travis.yml +1 -1
- data/CHANGELOG.md +5 -1
- data/Gemfile +2 -0
- data/README.md +15 -3
- data/Rakefile +9 -10
- data/bin/propane +3 -1
- data/lib/propane.rb +2 -1
- data/lib/propane/app.rb +2 -1
- data/lib/propane/creators/sketch_class.rb +7 -1
- data/lib/propane/creators/sketch_factory.rb +4 -2
- data/lib/propane/creators/sketch_writer.rb +1 -0
- data/lib/propane/helper_methods.rb +22 -22
- data/lib/propane/helpers/numeric.rb +2 -0
- data/lib/propane/helpers/version_error.rb +1 -0
- data/lib/propane/library.rb +5 -1
- data/lib/propane/library_loader.rb +2 -0
- data/lib/propane/native_folder.rb +10 -9
- data/lib/propane/native_loader.rb +3 -0
- data/lib/propane/runner.rb +11 -5
- data/lib/propane/version.rb +2 -1
- data/library/boids/boids.rb +21 -11
- data/library/color_group/color_group.rb +2 -0
- data/library/control_panel/control_panel.rb +8 -5
- data/library/dxf/dxf.rb +2 -0
- data/library/file_chooser/chooser.rb +10 -9
- data/library/file_chooser/file_chooser.rb +10 -9
- data/library/library_proxy/library_proxy.rb +2 -0
- data/library/net/net.rb +2 -0
- data/library/simplex_noise/simplex_noise.rb +2 -0
- data/library/slider/slider.rb +23 -22
- data/library/vector_utils/vector_utils.rb +4 -0
- data/library/video_event/video_event.rb +2 -0
- data/pom.rb +46 -45
- data/pom.xml +4 -4
- data/propane.gemspec +8 -7
- data/src/main/java/monkstone/ColorUtil.java +1 -3
- data/src/main/java/monkstone/MathToolModule.java +1 -1
- data/src/main/java/monkstone/PropaneLibrary.java +2 -2
- data/src/main/java/monkstone/fastmath/Deglut.java +1 -1
- data/src/main/java/monkstone/filechooser/Chooser.java +1 -1
- data/src/main/java/monkstone/noise/SimplexNoise.java +2 -2
- data/src/main/java/monkstone/slider/CustomHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/CustomVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleHorizontalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SimpleVerticalSlider.java +1 -1
- data/src/main/java/monkstone/slider/SliderBar.java +1 -1
- data/src/main/java/monkstone/slider/SliderGroup.java +1 -1
- data/src/main/java/monkstone/slider/WheelHandler.java +1 -1
- data/src/main/java/monkstone/vecmath/package-info.java +1 -1
- data/src/main/java/monkstone/vecmath/vec2/Vec2.java +1 -1
- data/src/main/java/monkstone/vecmath/vec3/Vec3.java +1 -2
- data/src/main/java/monkstone/videoevent/CaptureEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/MovieEvent.java +1 -1
- data/src/main/java/monkstone/videoevent/package-info.java +1 -1
- data/src/main/java/processing/awt/PGraphicsJava2D.java +788 -283
- data/src/main/java/processing/awt/PImageAWT.java +260 -0
- data/src/main/java/processing/awt/PShapeJava2D.java +56 -53
- data/src/main/java/processing/awt/PSurfaceAWT.java +309 -211
- data/src/main/java/processing/awt/ShimAWT.java +580 -0
- data/src/main/java/processing/core/PApplet.java +2877 -2098
- data/src/main/java/processing/core/PConstants.java +477 -447
- data/src/main/java/processing/core/PFont.java +930 -884
- data/src/main/java/processing/core/PGraphics.java +337 -309
- data/src/main/java/processing/core/PImage.java +1689 -1689
- data/src/main/java/processing/core/PMatrix.java +172 -159
- data/src/main/java/processing/core/PMatrix2D.java +456 -410
- data/src/main/java/processing/core/PMatrix3D.java +755 -735
- data/src/main/java/processing/core/PShape.java +2910 -2656
- data/src/main/java/processing/core/PShapeOBJ.java +97 -94
- data/src/main/java/processing/core/PShapeSVG.java +1656 -1462
- data/src/main/java/processing/core/PStyle.java +40 -37
- data/src/main/java/processing/core/PSurface.java +134 -97
- data/src/main/java/processing/core/PSurfaceNone.java +292 -218
- data/src/main/java/processing/core/PVector.java +991 -966
- data/src/main/java/processing/core/ThinkDifferent.java +12 -8
- data/src/main/java/processing/data/DoubleDict.java +756 -710
- data/src/main/java/processing/data/DoubleList.java +749 -696
- data/src/main/java/processing/data/FloatDict.java +748 -702
- data/src/main/java/processing/data/FloatList.java +751 -697
- data/src/main/java/processing/data/IntDict.java +720 -673
- data/src/main/java/processing/data/IntList.java +699 -633
- data/src/main/java/processing/data/JSONArray.java +931 -873
- data/src/main/java/processing/data/JSONObject.java +1262 -1165
- data/src/main/java/processing/data/JSONTokener.java +351 -341
- data/src/main/java/processing/data/LongDict.java +710 -663
- data/src/main/java/processing/data/LongList.java +701 -635
- data/src/main/java/processing/data/Sort.java +37 -41
- data/src/main/java/processing/data/StringDict.java +525 -486
- data/src/main/java/processing/data/StringList.java +626 -580
- data/src/main/java/processing/data/Table.java +3693 -3513
- data/src/main/java/processing/data/TableRow.java +182 -183
- data/src/main/java/processing/data/XML.java +954 -880
- data/src/main/java/processing/event/Event.java +87 -67
- data/src/main/java/processing/event/KeyEvent.java +48 -41
- data/src/main/java/processing/event/MouseEvent.java +87 -113
- data/src/main/java/processing/event/TouchEvent.java +10 -6
- data/src/main/java/processing/javafx/PSurfaceFX.java +26 -0
- data/src/main/java/processing/net/Client.java +20 -20
- data/src/main/java/processing/net/Server.java +9 -9
- data/src/main/java/processing/opengl/FontTexture.java +286 -266
- data/src/main/java/processing/opengl/FrameBuffer.java +390 -376
- data/src/main/java/processing/opengl/LinePath.java +130 -91
- data/src/main/java/processing/opengl/LineStroker.java +593 -582
- data/src/main/java/processing/opengl/PGL.java +645 -579
- data/src/main/java/processing/opengl/PGraphics2D.java +408 -315
- data/src/main/java/processing/opengl/PGraphics3D.java +107 -72
- data/src/main/java/processing/opengl/PGraphicsOpenGL.java +12287 -12030
- data/src/main/java/processing/opengl/PJOGL.java +1743 -1672
- data/src/main/java/processing/opengl/PShader.java +345 -416
- data/src/main/java/processing/opengl/PShapeOpenGL.java +4601 -4543
- data/src/main/java/processing/opengl/PSurfaceJOGL.java +1113 -1029
- data/src/main/java/processing/opengl/Texture.java +1489 -1401
- data/src/main/java/processing/opengl/VertexBuffer.java +57 -55
- data/test/create_test.rb +21 -20
- data/test/deglut_spec_test.rb +4 -2
- data/test/helper_methods_test.rb +49 -20
- data/test/math_tool_test.rb +39 -32
- data/test/native_folder.rb +47 -0
- data/test/respond_to_test.rb +3 -2
- data/test/sketches/key_event.rb +2 -2
- data/test/sketches/library/my_library/my_library.rb +3 -0
- data/test/test_helper.rb +2 -0
- data/test/vecmath_spec_test.rb +35 -22
- data/vendors/Rakefile +28 -22
- metadata +13 -13
- data/src/main/java/processing/opengl/shaders/LightVert-brcm.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/LightVert-vc4.glsl +0 -154
- data/src/main/java/processing/opengl/shaders/TexLightVert-brcm.glsl +0 -160
- data/src/main/java/processing/opengl/shaders/TexLightVert-vc4.glsl +0 -160
data/pom.xml
CHANGED
|
@@ -11,7 +11,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
|
11
11
|
<modelVersion>4.0.0</modelVersion>
|
|
12
12
|
<groupId>propane</groupId>
|
|
13
13
|
<artifactId>propane</artifactId>
|
|
14
|
-
<version>3.
|
|
14
|
+
<version>3.5.0</version>
|
|
15
15
|
<name>propane</name>
|
|
16
16
|
<description>An integrated processing-core (somewhat hacked), with additional java code for a jruby version of processing.</description>
|
|
17
17
|
<url>https://github.com/monkstone/propane</url>
|
|
@@ -74,7 +74,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
|
74
74
|
<dependency>
|
|
75
75
|
<groupId>org.jruby</groupId>
|
|
76
76
|
<artifactId>jruby</artifactId>
|
|
77
|
-
<version>9.2.
|
|
77
|
+
<version>9.2.11.1</version>
|
|
78
78
|
<type>pom</type>
|
|
79
79
|
</dependency>
|
|
80
80
|
<dependency>
|
|
@@ -132,7 +132,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
|
132
132
|
</plugin>
|
|
133
133
|
<plugin>
|
|
134
134
|
<artifactId>maven-javadoc-plugin</artifactId>
|
|
135
|
-
<version>3.
|
|
135
|
+
<version>3.2.0</version>
|
|
136
136
|
<configuration>
|
|
137
137
|
<detectOfflineLinks>false</detectOfflineLinks>
|
|
138
138
|
<links>
|
|
@@ -143,7 +143,7 @@ DO NOT MODIFIY - GENERATED CODE
|
|
|
143
143
|
</plugin>
|
|
144
144
|
<plugin>
|
|
145
145
|
<artifactId>maven-jar-plugin</artifactId>
|
|
146
|
-
<version>3.
|
|
146
|
+
<version>3.2.0</version>
|
|
147
147
|
<configuration>
|
|
148
148
|
<archive>
|
|
149
149
|
<manifestEntries>
|
data/propane.gemspec
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
5
|
require 'propane/version'
|
|
5
6
|
|
|
@@ -8,13 +9,13 @@ Gem::Specification.new do |gem|
|
|
|
8
9
|
gem.version = Propane::VERSION
|
|
9
10
|
gem.authors = ['monkstone']
|
|
10
11
|
gem.email = ['mamba2928@yahoo.co.uk']
|
|
11
|
-
gem.licenses = %w
|
|
12
|
+
gem.licenses = %w[GPL-3.0 LGPL-2.0]
|
|
12
13
|
gem.description = <<-EOS
|
|
13
14
|
A batteries included version of processing in ruby targetting jdk11.
|
|
14
15
|
EOS
|
|
15
|
-
gem.summary =
|
|
16
|
+
gem.summary = 'ruby implementation of processing-4.0 on MacOS, linux and windows (64bit only)'
|
|
16
17
|
gem.homepage = 'https://ruby-processing.github.io/propane/'
|
|
17
|
-
gem.files = `git ls-files`.split(
|
|
18
|
+
gem.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
|
18
19
|
gem.files << "lib/propane-#{Propane::VERSION}.jar"
|
|
19
20
|
gem.files << 'lib/gluegen-rt.jar'
|
|
20
21
|
gem.files << 'lib/jogl-all.jar'
|
|
@@ -24,10 +25,10 @@ Gem::Specification.new do |gem|
|
|
|
24
25
|
gem.files << 'lib/jogl-all-natives-linux-amd64.jar'
|
|
25
26
|
gem.files << 'lib/jogl-all-natives-macosx-universal.jar'
|
|
26
27
|
gem.files << 'lib/jogl-all-natives-windows-amd64.jar'
|
|
27
|
-
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
|
28
|
+
gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) }
|
|
28
29
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
|
29
|
-
gem.add_development_dependency 'rake', '~> 12.3'
|
|
30
30
|
gem.add_development_dependency 'minitest', '~> 5.11'
|
|
31
|
+
gem.add_development_dependency 'rake', '~> 12.3'
|
|
31
32
|
gem.add_runtime_dependency 'arcball', '~> 1.0', '>= 1.0.0'
|
|
32
33
|
gem.require_paths = ['lib']
|
|
33
34
|
gem.platform = 'java'
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* in their sketches. Includes a method to efficiently convert an array of web
|
|
4
4
|
* strings to an array of color int, and another to convert an array of color
|
|
5
5
|
* int to a string that can be used in ruby code (to generate web color array).
|
|
6
|
-
* Copyright (c) 2015-
|
|
6
|
+
* Copyright (c) 2015-20 Martin Prout.
|
|
7
7
|
* This utility is free software; you can redistribute it and/or modify
|
|
8
8
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
9
9
|
* the Free Software Foundation; either version 2.1 of the License, or (at
|
|
@@ -13,8 +13,6 @@
|
|
|
13
13
|
*/
|
|
14
14
|
package monkstone;
|
|
15
15
|
|
|
16
|
-
import java.util.ArrayList;
|
|
17
|
-
import java.util.List;
|
|
18
16
|
import java.util.Random;
|
|
19
17
|
/**
|
|
20
18
|
*
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The purpose of this tool is to allow JRubyArt users to use an alternative
|
|
3
3
|
* to processing.org map, lerp and norm methods in their sketches and to implement
|
|
4
4
|
* JRubyArt convenenience method grid(width, height, stepW, stepH) { |x, y| do stuff }
|
|
5
|
-
* Copyright (c) 2015-
|
|
5
|
+
* Copyright (c) 2015-20 Martin Prout. This tool is free software; you can
|
|
6
6
|
* redistribute it and/or modify it under the terms of the GNU Lesser General
|
|
7
7
|
* Public License as published by the Free Software Foundation; either version
|
|
8
8
|
* 2.1 of the License, or (at your option) any later version.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The purpose of this class is to load the MathTool into ruby-processing runtime
|
|
3
|
-
* Copyright (C) 2015-
|
|
3
|
+
* Copyright (C) 2015-20 Martin Prout. This code is free software; you can
|
|
4
4
|
* redistribute it and/or modify it under the terms of the GNU Lesser General
|
|
5
5
|
* Public License as published by the Free Software Foundation; either version
|
|
6
6
|
* 2.1 of the License, or (at your option) any later version.
|
|
@@ -41,6 +41,6 @@ public class PropaneLibrary implements Library {
|
|
|
41
41
|
*/
|
|
42
42
|
@Override
|
|
43
43
|
public void load(final Ruby runtime, boolean wrap) throws IOException {
|
|
44
|
-
load(runtime);
|
|
44
|
+
PropaneLibrary.load(runtime);
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -31,7 +31,7 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
|
|
|
31
31
|
new Grad(1, 1, 1, 0), new Grad(1, 1, -1, 0), new Grad(1, -1, 1, 0), new Grad(1, -1, -1, 0),
|
|
32
32
|
new Grad(-1, 1, 1, 0), new Grad(-1, 1, -1, 0), new Grad(-1, -1, 1, 0), new Grad(-1, -1, -1, 0)};
|
|
33
33
|
|
|
34
|
-
private static short p[] = {151, 160, 137, 91, 90, 15,
|
|
34
|
+
private final static short p[] = {151, 160, 137, 91, 90, 15,
|
|
35
35
|
131, 13, 201, 95, 96, 53, 194, 233, 7, 225, 140, 36, 103, 30, 69, 142, 8, 99, 37, 240, 21, 10, 23,
|
|
36
36
|
190, 6, 148, 247, 120, 234, 75, 0, 26, 197, 62, 94, 252, 219, 203, 117, 35, 11, 32, 57, 177, 33,
|
|
37
37
|
88, 237, 149, 56, 87, 174, 20, 125, 136, 171, 168, 68, 175, 74, 165, 71, 134, 139, 48, 27, 166,
|
|
@@ -45,7 +45,7 @@ public class SimplexNoise { // Simplex noise in 2D, 3D and 4D
|
|
|
45
45
|
49, 192, 214, 31, 181, 199, 106, 157, 184, 84, 204, 176, 115, 121, 50, 45, 127, 4, 150, 254,
|
|
46
46
|
138, 236, 205, 93, 222, 114, 67, 29, 24, 72, 243, 141, 128, 195, 78, 66, 215, 61, 156, 180};
|
|
47
47
|
// To remove the need for index wrapping, double the permutation table length
|
|
48
|
-
static short[] PERM = new short[512];
|
|
48
|
+
final static short[] PERM = new short[512];
|
|
49
49
|
static short[] PERM_MOD_12 = new short[512];
|
|
50
50
|
|
|
51
51
|
static {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
package monkstone.vecmath.vec3;
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
|
-
* Copyright (c) 2015-
|
|
4
|
+
* Copyright (c) 2015-20 Martin Prout
|
|
5
5
|
*
|
|
6
6
|
* This library is free software; you can redistribute it and/or
|
|
7
7
|
* modify it under the terms of the GNU Lesser General Public
|
|
@@ -33,7 +33,6 @@ import org.jruby.runtime.ThreadContext;
|
|
|
33
33
|
import org.jruby.runtime.builtin.IRubyObject;
|
|
34
34
|
import monkstone.vecmath.JRender;
|
|
35
35
|
import monkstone.vecmath.vec2.Vec2;
|
|
36
|
-
import org.jruby.RubyNumeric;
|
|
37
36
|
|
|
38
37
|
/**
|
|
39
38
|
*
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/* -*- mode: java; c-basic-offset: 2; indent-tabs-mode: nil -*- */
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
Part of the Processing project - http://processing.org
|
|
3
5
|
|
|
@@ -18,7 +20,8 @@
|
|
|
18
20
|
Public License along with this library; if not, write to the
|
|
19
21
|
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
|
20
22
|
Boston, MA 02111-1307 USA
|
|
21
|
-
|
|
23
|
+
*/
|
|
24
|
+
|
|
22
25
|
package processing.awt;
|
|
23
26
|
|
|
24
27
|
import java.awt.*;
|
|
@@ -31,20 +34,20 @@ import java.util.Map;
|
|
|
31
34
|
|
|
32
35
|
import processing.core.*;
|
|
33
36
|
|
|
37
|
+
|
|
34
38
|
/**
|
|
35
39
|
* Subclass for PGraphics that implements the graphics API using Java2D.
|
|
36
40
|
* <p>
|
|
37
|
-
* To get access to the Java 2D "Graphics2D" object for the default
|
|
38
|
-
* use:
|
|
41
|
+
* To get access to the Java 2D "Graphics2D" object for the default
|
|
42
|
+
* renderer, use:
|
|
39
43
|
* <PRE>
|
|
40
44
|
* Graphics2D g2 = (Graphics2D) g.getNative();
|
|
41
|
-
* </PRE>
|
|
42
|
-
*
|
|
43
|
-
*
|
|
45
|
+
* </PRE>
|
|
46
|
+
* This will let you do Graphics2D calls directly, but is not supported
|
|
47
|
+
* in any way shape or form. Which just means "have fun, but don't complain
|
|
48
|
+
* if it breaks."
|
|
44
49
|
* <p>
|
|
45
|
-
* Advanced
|
|
46
|
-
* <a href="http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/java2d.html">debugging
|
|
47
|
-
* notes</a> for Java2D.
|
|
50
|
+
* Advanced <a href="http://docs.oracle.com/javase/7/docs/webnotes/tsg/TSG-Desktop/html/java2d.html">debugging notes</a> for Java2D.
|
|
48
51
|
*/
|
|
49
52
|
public class PGraphicsJava2D extends PGraphics {
|
|
50
53
|
//// BufferStrategy strategy;
|
|
@@ -79,8 +82,8 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
79
82
|
float[] curveDrawY;
|
|
80
83
|
|
|
81
84
|
int transformCount;
|
|
82
|
-
AffineTransform transformStack
|
|
83
|
-
|
|
85
|
+
AffineTransform[] transformStack =
|
|
86
|
+
new AffineTransform[MATRIX_STACK_DEPTH];
|
|
84
87
|
double[] transform = new double[6];
|
|
85
88
|
|
|
86
89
|
Line2D.Float line = new Line2D.Float();
|
|
@@ -101,14 +104,25 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
101
104
|
|
|
102
105
|
Font fontObject;
|
|
103
106
|
|
|
107
|
+
|
|
108
|
+
|
|
104
109
|
//////////////////////////////////////////////////////////////
|
|
110
|
+
|
|
105
111
|
// INTERNAL
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
public PGraphicsJava2D() { }
|
|
115
|
+
|
|
108
116
|
|
|
109
117
|
//public void setParent(PApplet parent)
|
|
118
|
+
|
|
119
|
+
|
|
110
120
|
//public void setPrimary(boolean primary)
|
|
121
|
+
|
|
122
|
+
|
|
111
123
|
//public void setPath(String path)
|
|
124
|
+
|
|
125
|
+
|
|
112
126
|
// /**
|
|
113
127
|
// * Called in response to a resize event, handles setting the
|
|
114
128
|
// * new width and height internally, as well as re-allocating
|
|
@@ -124,11 +138,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
124
138
|
// allocate();
|
|
125
139
|
// reapplySettings();
|
|
126
140
|
// }
|
|
141
|
+
|
|
142
|
+
|
|
127
143
|
// @Override
|
|
128
144
|
// protected void allocate() {
|
|
129
145
|
// //surface.initImage(this, width, height);
|
|
130
146
|
// surface.initImage(this);
|
|
131
147
|
// }
|
|
148
|
+
|
|
149
|
+
|
|
132
150
|
/*
|
|
133
151
|
@Override
|
|
134
152
|
protected void allocate() {
|
|
@@ -201,9 +219,9 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
201
219
|
image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
|
|
202
220
|
g2 = (Graphics2D) image.getGraphics();
|
|
203
221
|
}
|
|
204
|
-
|
|
222
|
+
*/
|
|
205
223
|
|
|
206
|
-
|
|
224
|
+
/*
|
|
207
225
|
if (primarySurface) {
|
|
208
226
|
Canvas canvas = ((PSurfaceAWT) surface).canvas;
|
|
209
227
|
|
|
@@ -223,40 +241,47 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
223
241
|
}
|
|
224
242
|
g2 = (Graphics2D) image.getGraphics();
|
|
225
243
|
}
|
|
226
|
-
|
|
244
|
+
*/
|
|
245
|
+
|
|
246
|
+
|
|
227
247
|
//public void dispose()
|
|
248
|
+
|
|
249
|
+
|
|
228
250
|
@Override
|
|
229
251
|
public PSurface createSurface() {
|
|
230
252
|
return surface = new PSurfaceAWT(this);
|
|
231
253
|
}
|
|
232
254
|
|
|
233
|
-
/**
|
|
234
|
-
* Still need a means to get the java.awt.Image object, since getNative() is
|
|
235
|
-
* going to return the {@link Graphics2D} object.
|
|
236
|
-
*
|
|
237
|
-
* @return
|
|
238
|
-
*/
|
|
239
|
-
@Override
|
|
240
|
-
public Image getImage() {
|
|
241
|
-
return image;
|
|
242
|
-
}
|
|
243
255
|
|
|
244
|
-
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
|
|
248
|
-
|
|
256
|
+
// /**
|
|
257
|
+
// * Still need a means to get the java.awt.Image object, since getNative()
|
|
258
|
+
// * is going to return the {@link Graphics2D} object.
|
|
259
|
+
// */
|
|
260
|
+
// @Override
|
|
261
|
+
// public Image getImage() {
|
|
262
|
+
// return image;
|
|
263
|
+
// }
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
/** Returns the java.awt.Graphics2D object used by this renderer.
|
|
267
|
+
* @return */
|
|
249
268
|
@Override
|
|
250
269
|
public Object getNative() {
|
|
251
270
|
return g2;
|
|
252
271
|
}
|
|
253
272
|
|
|
273
|
+
|
|
254
274
|
//////////////////////////////////////////////////////////////
|
|
275
|
+
|
|
255
276
|
// FRAME
|
|
277
|
+
|
|
278
|
+
|
|
256
279
|
// @Override
|
|
257
280
|
// public boolean canDraw() {
|
|
258
281
|
// return true;
|
|
259
282
|
// }
|
|
283
|
+
|
|
284
|
+
|
|
260
285
|
// @Override
|
|
261
286
|
// public void requestDraw() {
|
|
262
287
|
//// EventQueue.invokeLater(new Runnable() {
|
|
@@ -265,11 +290,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
265
290
|
//// }
|
|
266
291
|
//// });
|
|
267
292
|
// }
|
|
293
|
+
|
|
294
|
+
|
|
268
295
|
// Graphics2D g2old;
|
|
296
|
+
|
|
269
297
|
public Graphics2D checkImage() {
|
|
270
|
-
if (image == null
|
|
271
|
-
|
|
272
|
-
|
|
298
|
+
if (image == null ||
|
|
299
|
+
((BufferedImage) image).getWidth() != width*pixelDensity ||
|
|
300
|
+
((BufferedImage) image).getHeight() != height*pixelDensity) {
|
|
273
301
|
// ((VolatileImage) image).getWidth() != width ||
|
|
274
302
|
// ((VolatileImage) image).getHeight() != height) {
|
|
275
303
|
// image = new BufferedImage(width * pixelFactor, height * pixelFactor
|
|
@@ -294,6 +322,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
294
322
|
// GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
|
|
295
323
|
// gc = ge.getDefaultScreenDevice().getDefaultConfiguration();
|
|
296
324
|
// }
|
|
325
|
+
|
|
297
326
|
// Formerly this was broken into separate versions based on offscreen or
|
|
298
327
|
// not, but we may as well create a compatible image; it won't hurt, right?
|
|
299
328
|
// P.S.: Three years later, I'm happy to report it did in fact hurt [jv 2018-06-01]
|
|
@@ -313,6 +342,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
313
342
|
return (Graphics2D) image.getGraphics();
|
|
314
343
|
}
|
|
315
344
|
|
|
345
|
+
|
|
316
346
|
@Override
|
|
317
347
|
public void beginDraw() {
|
|
318
348
|
g2 = checkImage();
|
|
@@ -384,12 +414,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
384
414
|
reapplySettings = true;
|
|
385
415
|
}
|
|
386
416
|
}
|
|
387
|
-
|
|
417
|
+
*/
|
|
418
|
+
|
|
388
419
|
checkSettings();
|
|
389
420
|
resetMatrix(); // reset model matrix
|
|
390
421
|
vertexCount = 0;
|
|
391
422
|
}
|
|
392
423
|
|
|
424
|
+
|
|
393
425
|
/**
|
|
394
426
|
* Smoothing for Java2D is 2 for bilinear, and 3 for bicubic (the default).
|
|
395
427
|
* Internally, smooth(1) is the default, smooth(0) is noSmooth().
|
|
@@ -397,33 +429,33 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
397
429
|
protected void handleSmooth() {
|
|
398
430
|
if (smooth == 0) {
|
|
399
431
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
|
400
|
-
|
|
432
|
+
RenderingHints.VALUE_ANTIALIAS_OFF);
|
|
401
433
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
|
402
|
-
|
|
434
|
+
RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR);
|
|
403
435
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
404
|
-
|
|
436
|
+
RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
|
405
437
|
|
|
406
438
|
} else {
|
|
407
439
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
|
408
|
-
|
|
440
|
+
RenderingHints.VALUE_ANTIALIAS_ON);
|
|
409
441
|
|
|
410
442
|
if (smooth == 1 || smooth == 3) { // default is bicubic
|
|
411
443
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
|
412
|
-
|
|
444
|
+
RenderingHints.VALUE_INTERPOLATION_BICUBIC);
|
|
413
445
|
} else if (smooth == 2) {
|
|
414
446
|
g2.setRenderingHint(RenderingHints.KEY_INTERPOLATION,
|
|
415
|
-
|
|
447
|
+
RenderingHints.VALUE_INTERPOLATION_BILINEAR);
|
|
416
448
|
}
|
|
417
449
|
|
|
418
450
|
// http://docs.oracle.com/javase/tutorial/2d/text/renderinghints.html
|
|
419
451
|
// Oracle Java text anti-aliasing on OS X looks like s*t compared to the
|
|
420
452
|
// text rendering with Apple's old Java 6. Below, several attempts to fix:
|
|
421
453
|
g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
422
|
-
|
|
454
|
+
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
|
|
423
455
|
// Turns out this is the one that actually makes things work.
|
|
424
456
|
// Kerning is still screwed up, however.
|
|
425
457
|
g2.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS,
|
|
426
|
-
|
|
458
|
+
RenderingHints.VALUE_FRACTIONALMETRICS_ON);
|
|
427
459
|
// g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
428
460
|
// RenderingHints.VALUE_TEXT_ANTIALIAS_GASP);
|
|
429
461
|
// g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
@@ -434,6 +466,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
434
466
|
}
|
|
435
467
|
}
|
|
436
468
|
|
|
469
|
+
|
|
437
470
|
@Override
|
|
438
471
|
public void endDraw() {
|
|
439
472
|
// hm, mark pixels as changed, because this will instantly do a full
|
|
@@ -469,7 +502,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
469
502
|
// g2.dispose();
|
|
470
503
|
// System.out.println("not doing anything special in endDraw()");
|
|
471
504
|
}
|
|
472
|
-
|
|
505
|
+
*/
|
|
473
506
|
} else {
|
|
474
507
|
// TODO this is probably overkill for most tasks...
|
|
475
508
|
loadPixels();
|
|
@@ -481,6 +514,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
481
514
|
// // full copy of the pixels to the surface in this.updatePixels().
|
|
482
515
|
// setModified();
|
|
483
516
|
// super.updatePixels();
|
|
517
|
+
|
|
484
518
|
// Marks pixels as modified so that the pixels will be updated.
|
|
485
519
|
// Also sets mx1/y1/x2/y2 so that OpenGL will pick it up.
|
|
486
520
|
setModified();
|
|
@@ -507,7 +541,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
507
541
|
// try {
|
|
508
542
|
// ImageIO.write(image, "jpg", new java.io.File("/Users/fry/Desktop/buff.jpg"));
|
|
509
543
|
// } catch (IOException e) {
|
|
510
|
-
//
|
|
544
|
+
//
|
|
511
545
|
// }
|
|
512
546
|
// }
|
|
513
547
|
// }
|
|
@@ -532,10 +566,18 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
532
566
|
} while (strategy.contentsLost());
|
|
533
567
|
PApplet.debug("PGraphicsJava2D.redraw() out of do { } block");
|
|
534
568
|
}
|
|
535
|
-
|
|
569
|
+
*/
|
|
570
|
+
|
|
571
|
+
|
|
572
|
+
|
|
536
573
|
//////////////////////////////////////////////////////////////
|
|
574
|
+
|
|
537
575
|
// SETTINGS
|
|
576
|
+
|
|
577
|
+
|
|
538
578
|
//protected void checkSettings()
|
|
579
|
+
|
|
580
|
+
|
|
539
581
|
@Override
|
|
540
582
|
protected void defaultSettings() {
|
|
541
583
|
// if (!useCanvas) {
|
|
@@ -552,9 +594,16 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
552
594
|
super.defaultSettings();
|
|
553
595
|
}
|
|
554
596
|
|
|
597
|
+
|
|
555
598
|
//protected void reapplySettings()
|
|
599
|
+
|
|
600
|
+
|
|
601
|
+
|
|
556
602
|
//////////////////////////////////////////////////////////////
|
|
603
|
+
|
|
557
604
|
// HINT
|
|
605
|
+
|
|
606
|
+
|
|
558
607
|
@Override
|
|
559
608
|
public void hint(int which) {
|
|
560
609
|
// take care of setting the hint
|
|
@@ -566,29 +615,38 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
566
615
|
// stroke in many standard Processing examples really gross.
|
|
567
616
|
if (which == ENABLE_STROKE_PURE) {
|
|
568
617
|
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
|
|
569
|
-
|
|
618
|
+
RenderingHints.VALUE_STROKE_PURE);
|
|
570
619
|
} else if (which == DISABLE_STROKE_PURE) {
|
|
571
620
|
g2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL,
|
|
572
|
-
|
|
621
|
+
RenderingHints.VALUE_STROKE_DEFAULT);
|
|
573
622
|
}
|
|
574
623
|
}
|
|
575
624
|
|
|
625
|
+
|
|
626
|
+
|
|
576
627
|
//////////////////////////////////////////////////////////////
|
|
628
|
+
|
|
577
629
|
// SHAPE CREATION
|
|
630
|
+
|
|
631
|
+
|
|
578
632
|
@Override
|
|
579
633
|
protected PShape createShapeFamily(int type) {
|
|
580
634
|
return new PShape(this, type);
|
|
581
635
|
}
|
|
582
636
|
|
|
637
|
+
|
|
583
638
|
@Override
|
|
584
639
|
protected PShape createShapePrimitive(int kind, float... p) {
|
|
585
640
|
return new PShape(this, kind, p);
|
|
586
641
|
}
|
|
587
642
|
|
|
643
|
+
|
|
588
644
|
// @Override
|
|
589
645
|
// public PShape createShape(PShape source) {
|
|
590
646
|
// return PShapeOpenGL.createShape2D(this, source);
|
|
591
647
|
// }
|
|
648
|
+
|
|
649
|
+
|
|
592
650
|
/*
|
|
593
651
|
protected PShape createShapeImpl(PGraphicsJava2D pg, int type) {
|
|
594
652
|
PShape shape = null;
|
|
@@ -604,7 +662,9 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
604
662
|
return shape;
|
|
605
663
|
}
|
|
606
664
|
*/
|
|
607
|
-
|
|
665
|
+
|
|
666
|
+
|
|
667
|
+
/*
|
|
608
668
|
static protected PShape createShapeImpl(PGraphicsJava2D pg,
|
|
609
669
|
int kind, float... p) {
|
|
610
670
|
PShape shape = null;
|
|
@@ -676,9 +736,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
676
736
|
|
|
677
737
|
return shape;
|
|
678
738
|
}
|
|
679
|
-
|
|
739
|
+
*/
|
|
740
|
+
|
|
741
|
+
|
|
742
|
+
|
|
680
743
|
//////////////////////////////////////////////////////////////
|
|
744
|
+
|
|
681
745
|
// SHAPES
|
|
746
|
+
|
|
747
|
+
|
|
682
748
|
@Override
|
|
683
749
|
public void beginShape(int kind) {
|
|
684
750
|
//super.beginShape(kind);
|
|
@@ -695,21 +761,29 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
695
761
|
auxPath = null;
|
|
696
762
|
}
|
|
697
763
|
|
|
764
|
+
|
|
698
765
|
//public boolean edge(boolean e)
|
|
766
|
+
|
|
767
|
+
|
|
699
768
|
//public void normal(float nx, float ny, float nz) {
|
|
769
|
+
|
|
770
|
+
|
|
700
771
|
//public void textureMode(int mode)
|
|
772
|
+
|
|
773
|
+
|
|
701
774
|
@Override
|
|
702
775
|
public void texture(PImage image) {
|
|
703
776
|
showMethodWarning("texture");
|
|
704
777
|
}
|
|
705
778
|
|
|
779
|
+
|
|
706
780
|
@Override
|
|
707
781
|
public void vertex(float x, float y) {
|
|
708
782
|
curveVertexCount = 0;
|
|
709
783
|
//float vertex[];
|
|
710
784
|
|
|
711
785
|
if (vertexCount == vertices.length) {
|
|
712
|
-
float
|
|
786
|
+
float[][] temp = new float[vertexCount<<1][VERTEX_FIELD_COUNT];
|
|
713
787
|
System.arraycopy(vertices, 0, temp, 0, vertexCount);
|
|
714
788
|
vertices = temp;
|
|
715
789
|
//message(CHATTER, "allocating more vertices " + vertices.length);
|
|
@@ -722,98 +796,99 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
722
796
|
|
|
723
797
|
switch (shape) {
|
|
724
798
|
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
case LINES:
|
|
730
|
-
if ((vertexCount % 2) == 0) {
|
|
731
|
-
line(vertices[vertexCount - 2][X],
|
|
732
|
-
vertices[vertexCount - 2][Y], x, y);
|
|
733
|
-
}
|
|
734
|
-
break;
|
|
735
|
-
|
|
736
|
-
case TRIANGLES:
|
|
737
|
-
if ((vertexCount % 3) == 0) {
|
|
738
|
-
triangle(vertices[vertexCount - 3][X],
|
|
739
|
-
vertices[vertexCount - 3][Y],
|
|
740
|
-
vertices[vertexCount - 2][X],
|
|
741
|
-
vertices[vertexCount - 2][Y],
|
|
742
|
-
x, y);
|
|
743
|
-
}
|
|
744
|
-
break;
|
|
745
|
-
|
|
746
|
-
case TRIANGLE_STRIP:
|
|
747
|
-
if (vertexCount >= 3) {
|
|
748
|
-
triangle(vertices[vertexCount - 2][X],
|
|
749
|
-
vertices[vertexCount - 2][Y],
|
|
750
|
-
vertices[vertexCount - 1][X],
|
|
751
|
-
vertices[vertexCount - 1][Y],
|
|
752
|
-
vertices[vertexCount - 3][X],
|
|
753
|
-
vertices[vertexCount - 3][Y]);
|
|
754
|
-
}
|
|
755
|
-
break;
|
|
756
|
-
|
|
757
|
-
case TRIANGLE_FAN:
|
|
758
|
-
if (vertexCount >= 3) {
|
|
759
|
-
// This is an unfortunate implementation because the stroke for an
|
|
760
|
-
// adjacent triangle will be repeated. However, if the stroke is not
|
|
761
|
-
// redrawn, it will replace the adjacent line (when it lines up
|
|
762
|
-
// perfectly) or show a faint line (when off by a small amount).
|
|
763
|
-
// The alternative would be to wait, then draw the shape as a
|
|
764
|
-
// polygon fill, followed by a series of vertices. But that's a
|
|
765
|
-
// poor method when used with PDF, DXF, or other recording objects,
|
|
766
|
-
// since discrete triangles would likely be preferred.
|
|
767
|
-
triangle(vertices[0][X],
|
|
768
|
-
vertices[0][Y],
|
|
769
|
-
vertices[vertexCount - 2][X],
|
|
770
|
-
vertices[vertexCount - 2][Y],
|
|
771
|
-
x, y);
|
|
772
|
-
}
|
|
773
|
-
break;
|
|
774
|
-
|
|
775
|
-
case QUAD:
|
|
776
|
-
case QUADS:
|
|
777
|
-
if ((vertexCount % 4) == 0) {
|
|
778
|
-
quad(vertices[vertexCount - 4][X],
|
|
779
|
-
vertices[vertexCount - 4][Y],
|
|
780
|
-
vertices[vertexCount - 3][X],
|
|
781
|
-
vertices[vertexCount - 3][Y],
|
|
782
|
-
vertices[vertexCount - 2][X],
|
|
783
|
-
vertices[vertexCount - 2][Y],
|
|
784
|
-
x, y);
|
|
785
|
-
}
|
|
786
|
-
break;
|
|
787
|
-
|
|
788
|
-
case QUAD_STRIP:
|
|
789
|
-
// 0---2---4
|
|
790
|
-
// | | |
|
|
791
|
-
// 1---3---5
|
|
792
|
-
if ((vertexCount >= 4) && ((vertexCount % 2) == 0)) {
|
|
793
|
-
quad(vertices[vertexCount - 4][X],
|
|
794
|
-
vertices[vertexCount - 4][Y],
|
|
795
|
-
vertices[vertexCount - 2][X],
|
|
796
|
-
vertices[vertexCount - 2][Y],
|
|
797
|
-
x, y,
|
|
798
|
-
vertices[vertexCount - 3][X],
|
|
799
|
-
vertices[vertexCount - 3][Y]);
|
|
800
|
-
}
|
|
801
|
-
break;
|
|
799
|
+
case POINTS:
|
|
800
|
+
point(x, y);
|
|
801
|
+
break;
|
|
802
802
|
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
803
|
+
case LINES:
|
|
804
|
+
if ((vertexCount % 2) == 0) {
|
|
805
|
+
line(vertices[vertexCount-2][X],
|
|
806
|
+
vertices[vertexCount-2][Y], x, y);
|
|
807
|
+
}
|
|
808
|
+
break;
|
|
809
|
+
|
|
810
|
+
case TRIANGLES:
|
|
811
|
+
if ((vertexCount % 3) == 0) {
|
|
812
|
+
triangle(vertices[vertexCount - 3][X],
|
|
813
|
+
vertices[vertexCount - 3][Y],
|
|
814
|
+
vertices[vertexCount - 2][X],
|
|
815
|
+
vertices[vertexCount - 2][Y],
|
|
816
|
+
x, y);
|
|
817
|
+
}
|
|
818
|
+
break;
|
|
819
|
+
|
|
820
|
+
case TRIANGLE_STRIP:
|
|
821
|
+
if (vertexCount >= 3) {
|
|
822
|
+
triangle(vertices[vertexCount - 2][X],
|
|
823
|
+
vertices[vertexCount - 2][Y],
|
|
824
|
+
vertices[vertexCount - 1][X],
|
|
825
|
+
vertices[vertexCount - 1][Y],
|
|
826
|
+
vertices[vertexCount - 3][X],
|
|
827
|
+
vertices[vertexCount - 3][Y]);
|
|
828
|
+
}
|
|
829
|
+
break;
|
|
830
|
+
|
|
831
|
+
case TRIANGLE_FAN:
|
|
832
|
+
if (vertexCount >= 3) {
|
|
833
|
+
// This is an unfortunate implementation because the stroke for an
|
|
834
|
+
// adjacent triangle will be repeated. However, if the stroke is not
|
|
835
|
+
// redrawn, it will replace the adjacent line (when it lines up
|
|
836
|
+
// perfectly) or show a faint line (when off by a small amount).
|
|
837
|
+
// The alternative would be to wait, then draw the shape as a
|
|
838
|
+
// polygon fill, followed by a series of vertices. But that's a
|
|
839
|
+
// poor method when used with PDF, DXF, or other recording objects,
|
|
840
|
+
// since discrete triangles would likely be preferred.
|
|
841
|
+
triangle(vertices[0][X],
|
|
842
|
+
vertices[0][Y],
|
|
843
|
+
vertices[vertexCount - 2][X],
|
|
844
|
+
vertices[vertexCount - 2][Y],
|
|
845
|
+
x, y);
|
|
846
|
+
}
|
|
847
|
+
break;
|
|
848
|
+
|
|
849
|
+
case QUAD:
|
|
850
|
+
case QUADS:
|
|
851
|
+
if ((vertexCount % 4) == 0) {
|
|
852
|
+
quad(vertices[vertexCount - 4][X],
|
|
853
|
+
vertices[vertexCount - 4][Y],
|
|
854
|
+
vertices[vertexCount - 3][X],
|
|
855
|
+
vertices[vertexCount - 3][Y],
|
|
856
|
+
vertices[vertexCount - 2][X],
|
|
857
|
+
vertices[vertexCount - 2][Y],
|
|
858
|
+
x, y);
|
|
859
|
+
}
|
|
860
|
+
break;
|
|
861
|
+
|
|
862
|
+
case QUAD_STRIP:
|
|
863
|
+
// 0---2---4
|
|
864
|
+
// | | |
|
|
865
|
+
// 1---3---5
|
|
866
|
+
if ((vertexCount >= 4) && ((vertexCount % 2) == 0)) {
|
|
867
|
+
quad(vertices[vertexCount - 4][X],
|
|
868
|
+
vertices[vertexCount - 4][Y],
|
|
869
|
+
vertices[vertexCount - 2][X],
|
|
870
|
+
vertices[vertexCount - 2][Y],
|
|
871
|
+
x, y,
|
|
872
|
+
vertices[vertexCount - 3][X],
|
|
873
|
+
vertices[vertexCount - 3][Y]);
|
|
874
|
+
}
|
|
875
|
+
break;
|
|
876
|
+
|
|
877
|
+
case POLYGON:
|
|
878
|
+
if (gpath == null) {
|
|
879
|
+
gpath = new GeneralPath();
|
|
880
|
+
gpath.moveTo(x, y);
|
|
881
|
+
} else if (breakShape) {
|
|
882
|
+
gpath.moveTo(x, y);
|
|
883
|
+
breakShape = false;
|
|
884
|
+
} else {
|
|
885
|
+
gpath.lineTo(x, y);
|
|
886
|
+
}
|
|
887
|
+
break;
|
|
814
888
|
}
|
|
815
889
|
}
|
|
816
890
|
|
|
891
|
+
|
|
817
892
|
@Override
|
|
818
893
|
public void vertex(float x, float y, float z) {
|
|
819
894
|
showDepthWarningXYZ("vertex");
|
|
@@ -824,16 +899,19 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
824
899
|
vertex(v[X], v[Y]);
|
|
825
900
|
}
|
|
826
901
|
|
|
902
|
+
|
|
827
903
|
@Override
|
|
828
904
|
public void vertex(float x, float y, float u, float v) {
|
|
829
905
|
showVariationWarning("vertex(x, y, u, v)");
|
|
830
906
|
}
|
|
831
907
|
|
|
908
|
+
|
|
832
909
|
@Override
|
|
833
910
|
public void vertex(float x, float y, float z, float u, float v) {
|
|
834
911
|
showDepthWarningXYZ("vertex");
|
|
835
912
|
}
|
|
836
913
|
|
|
914
|
+
|
|
837
915
|
@Override
|
|
838
916
|
public void beginContour() {
|
|
839
917
|
if (openContour) {
|
|
@@ -853,6 +931,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
853
931
|
openContour = true;
|
|
854
932
|
}
|
|
855
933
|
|
|
934
|
+
|
|
856
935
|
@Override
|
|
857
936
|
public void endContour() {
|
|
858
937
|
if (!openContour) {
|
|
@@ -861,9 +940,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
861
940
|
}
|
|
862
941
|
|
|
863
942
|
// close this contour
|
|
864
|
-
if (gpath != null)
|
|
865
|
-
gpath.closePath();
|
|
866
|
-
}
|
|
943
|
+
if (gpath != null) gpath.closePath();
|
|
867
944
|
|
|
868
945
|
// switch back to main path
|
|
869
946
|
GeneralPath contourPath = gpath;
|
|
@@ -873,6 +950,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
873
950
|
openContour = false;
|
|
874
951
|
}
|
|
875
952
|
|
|
953
|
+
|
|
876
954
|
@Override
|
|
877
955
|
public void endShape(int mode) {
|
|
878
956
|
if (openContour) { // correct automagically, notify user
|
|
@@ -894,24 +972,32 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
894
972
|
}
|
|
895
973
|
|
|
896
974
|
//////////////////////////////////////////////////////////////
|
|
975
|
+
|
|
897
976
|
// CLIPPING
|
|
977
|
+
|
|
978
|
+
|
|
898
979
|
@Override
|
|
899
980
|
protected void clipImpl(float x1, float y1, float x2, float y2) {
|
|
900
981
|
g2.setClip(new Rectangle2D.Float(x1, y1, x2 - x1, y2 - y1));
|
|
901
982
|
}
|
|
902
983
|
|
|
984
|
+
|
|
903
985
|
@Override
|
|
904
986
|
public void noClip() {
|
|
905
987
|
g2.setClip(null);
|
|
906
988
|
}
|
|
907
989
|
|
|
990
|
+
|
|
991
|
+
|
|
908
992
|
//////////////////////////////////////////////////////////////
|
|
993
|
+
|
|
909
994
|
// BLEND
|
|
995
|
+
|
|
910
996
|
/**
|
|
911
|
-
* ( begin auto-generated from blendMode.xml )
|
|
912
997
|
*
|
|
913
|
-
* This is a new reference entry for Processing 2.0.It will be updated
|
|
914
|
-
*
|
|
998
|
+
* This is a new reference entry for Processing 2.0.It will be updated shortly.
|
|
999
|
+
*
|
|
1000
|
+
*
|
|
915
1001
|
*
|
|
916
1002
|
* @webref Rendering
|
|
917
1003
|
*/
|
|
@@ -925,11 +1011,11 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
925
1011
|
}
|
|
926
1012
|
}
|
|
927
1013
|
|
|
1014
|
+
|
|
928
1015
|
// Blending implementation cribbed from portions of Romain Guy's
|
|
929
1016
|
// demo and terrific writeup on blending modes in Java 2D.
|
|
930
1017
|
// http://www.curious-creature.org/2006/09/20/new-blendings-modes-for-java2d/
|
|
931
1018
|
private static final class BlendingContext implements CompositeContext {
|
|
932
|
-
|
|
933
1019
|
private final int mode;
|
|
934
1020
|
|
|
935
1021
|
private BlendingContext(int mode) {
|
|
@@ -937,15 +1023,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
937
1023
|
}
|
|
938
1024
|
|
|
939
1025
|
@Override
|
|
940
|
-
public void dispose() {
|
|
941
|
-
}
|
|
1026
|
+
public void dispose() { }
|
|
942
1027
|
|
|
943
1028
|
@Override
|
|
944
1029
|
public void compose(Raster src, Raster dstIn, WritableRaster dstOut) {
|
|
945
1030
|
// not sure if this is really necessary, since we control our buffers
|
|
946
|
-
if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT
|
|
947
|
-
|
|
948
|
-
|
|
1031
|
+
if (src.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
|
|
1032
|
+
dstIn.getSampleModel().getDataType() != DataBuffer.TYPE_INT ||
|
|
1033
|
+
dstOut.getSampleModel().getDataType() != DataBuffer.TYPE_INT) {
|
|
949
1034
|
throw new IllegalStateException("Source and destination must store pixels as INT.");
|
|
950
1035
|
}
|
|
951
1036
|
|
|
@@ -966,47 +1051,64 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
966
1051
|
}
|
|
967
1052
|
}
|
|
968
1053
|
|
|
1054
|
+
|
|
1055
|
+
|
|
969
1056
|
//////////////////////////////////////////////////////////////
|
|
1057
|
+
|
|
970
1058
|
// BEZIER VERTICES
|
|
1059
|
+
|
|
1060
|
+
|
|
971
1061
|
@Override
|
|
972
1062
|
public void bezierVertex(float x1, float y1,
|
|
973
|
-
|
|
974
|
-
|
|
1063
|
+
float x2, float y2,
|
|
1064
|
+
float x3, float y3) {
|
|
975
1065
|
bezierVertexCheck();
|
|
976
1066
|
gpath.curveTo(x1, y1, x2, y2, x3, y3);
|
|
977
1067
|
}
|
|
978
1068
|
|
|
1069
|
+
|
|
979
1070
|
@Override
|
|
980
1071
|
public void bezierVertex(float x2, float y2, float z2,
|
|
981
|
-
|
|
982
|
-
|
|
1072
|
+
float x3, float y3, float z3,
|
|
1073
|
+
float x4, float y4, float z4) {
|
|
983
1074
|
showDepthWarningXYZ("bezierVertex");
|
|
984
1075
|
}
|
|
985
1076
|
|
|
1077
|
+
|
|
1078
|
+
|
|
986
1079
|
//////////////////////////////////////////////////////////////
|
|
1080
|
+
|
|
987
1081
|
// QUADRATIC BEZIER VERTICES
|
|
1082
|
+
|
|
1083
|
+
|
|
988
1084
|
@Override
|
|
989
1085
|
public void quadraticVertex(float ctrlX, float ctrlY,
|
|
990
|
-
|
|
1086
|
+
float endX, float endY) {
|
|
991
1087
|
bezierVertexCheck();
|
|
992
1088
|
Point2D cur = gpath.getCurrentPoint();
|
|
993
1089
|
|
|
994
1090
|
float x1 = (float) cur.getX();
|
|
995
1091
|
float y1 = (float) cur.getY();
|
|
996
1092
|
|
|
997
|
-
bezierVertex(x1 + ((ctrlX
|
|
998
|
-
|
|
999
|
-
|
|
1093
|
+
bezierVertex(x1 + ((ctrlX-x1)*2/3.0f), y1 + ((ctrlY-y1)*2/3.0f),
|
|
1094
|
+
endX + ((ctrlX-endX)*2/3.0f), endY + ((ctrlY-endY)*2/3.0f),
|
|
1095
|
+
endX, endY);
|
|
1000
1096
|
}
|
|
1001
1097
|
|
|
1098
|
+
|
|
1002
1099
|
@Override
|
|
1003
1100
|
public void quadraticVertex(float x2, float y2, float z2,
|
|
1004
|
-
|
|
1101
|
+
float x4, float y4, float z4) {
|
|
1005
1102
|
showDepthWarningXYZ("quadVertex");
|
|
1006
1103
|
}
|
|
1007
1104
|
|
|
1105
|
+
|
|
1106
|
+
|
|
1008
1107
|
//////////////////////////////////////////////////////////////
|
|
1108
|
+
|
|
1009
1109
|
// CURVE VERTICES
|
|
1110
|
+
|
|
1111
|
+
|
|
1010
1112
|
@Override
|
|
1011
1113
|
protected void curveVertexCheck() {
|
|
1012
1114
|
super.curveVertexCheck();
|
|
@@ -1019,11 +1121,12 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1019
1121
|
}
|
|
1020
1122
|
}
|
|
1021
1123
|
|
|
1124
|
+
|
|
1022
1125
|
@Override
|
|
1023
1126
|
protected void curveVertexSegment(float x1, float y1,
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1127
|
+
float x2, float y2,
|
|
1128
|
+
float x3, float y3,
|
|
1129
|
+
float x4, float y4) {
|
|
1027
1130
|
curveCoordX[0] = x1;
|
|
1028
1131
|
curveCoordY[0] = y1;
|
|
1029
1132
|
|
|
@@ -1047,20 +1150,32 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1047
1150
|
}
|
|
1048
1151
|
|
|
1049
1152
|
gpath.curveTo(curveDrawX[1], curveDrawY[1],
|
|
1050
|
-
|
|
1051
|
-
|
|
1153
|
+
curveDrawX[2], curveDrawY[2],
|
|
1154
|
+
curveDrawX[3], curveDrawY[3]);
|
|
1052
1155
|
}
|
|
1053
1156
|
|
|
1157
|
+
|
|
1054
1158
|
@Override
|
|
1055
1159
|
public void curveVertex(float x, float y, float z) {
|
|
1056
1160
|
showDepthWarningXYZ("curveVertex");
|
|
1057
1161
|
}
|
|
1058
1162
|
|
|
1163
|
+
|
|
1164
|
+
|
|
1059
1165
|
//////////////////////////////////////////////////////////////
|
|
1166
|
+
|
|
1060
1167
|
// RENDERER
|
|
1168
|
+
|
|
1169
|
+
|
|
1061
1170
|
//public void flush()
|
|
1171
|
+
|
|
1172
|
+
|
|
1173
|
+
|
|
1062
1174
|
//////////////////////////////////////////////////////////////
|
|
1175
|
+
|
|
1063
1176
|
// POINT, LINE, TRIANGLE, QUAD
|
|
1177
|
+
|
|
1178
|
+
|
|
1064
1179
|
@Override
|
|
1065
1180
|
public void point(float x, float y) {
|
|
1066
1181
|
if (stroke) {
|
|
@@ -1072,15 +1187,17 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1072
1187
|
}
|
|
1073
1188
|
}
|
|
1074
1189
|
|
|
1190
|
+
|
|
1075
1191
|
@Override
|
|
1076
1192
|
public void line(float x1, float y1, float x2, float y2) {
|
|
1077
1193
|
line.setLine(x1, y1, x2, y2);
|
|
1078
1194
|
strokeShape(line);
|
|
1079
1195
|
}
|
|
1080
1196
|
|
|
1197
|
+
|
|
1081
1198
|
@Override
|
|
1082
1199
|
public void triangle(float x1, float y1, float x2, float y2,
|
|
1083
|
-
|
|
1200
|
+
float x3, float y3) {
|
|
1084
1201
|
gpath = new GeneralPath();
|
|
1085
1202
|
gpath.moveTo(x1, y1);
|
|
1086
1203
|
gpath.lineTo(x2, y2);
|
|
@@ -1089,9 +1206,10 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1089
1206
|
drawShape(gpath);
|
|
1090
1207
|
}
|
|
1091
1208
|
|
|
1209
|
+
|
|
1092
1210
|
@Override
|
|
1093
1211
|
public void quad(float x1, float y1, float x2, float y2,
|
|
1094
|
-
|
|
1212
|
+
float x3, float y3, float x4, float y4) {
|
|
1095
1213
|
GeneralPath gp = new GeneralPath();
|
|
1096
1214
|
gp.moveTo(x1, y1);
|
|
1097
1215
|
gp.lineTo(x2, y2);
|
|
@@ -1101,33 +1219,58 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1101
1219
|
drawShape(gp);
|
|
1102
1220
|
}
|
|
1103
1221
|
|
|
1222
|
+
|
|
1223
|
+
|
|
1104
1224
|
//////////////////////////////////////////////////////////////
|
|
1225
|
+
|
|
1105
1226
|
// RECT
|
|
1227
|
+
|
|
1228
|
+
|
|
1106
1229
|
//public void rectMode(int mode)
|
|
1230
|
+
|
|
1231
|
+
|
|
1107
1232
|
//public void rect(float a, float b, float c, float d)
|
|
1233
|
+
|
|
1234
|
+
|
|
1108
1235
|
@Override
|
|
1109
1236
|
protected void rectImpl(float x1, float y1, float x2, float y2) {
|
|
1110
|
-
rect.setFrame(x1, y1, x2
|
|
1237
|
+
rect.setFrame(x1, y1, x2-x1, y2-y1);
|
|
1111
1238
|
drawShape(rect);
|
|
1112
1239
|
}
|
|
1113
1240
|
|
|
1241
|
+
|
|
1242
|
+
|
|
1114
1243
|
//////////////////////////////////////////////////////////////
|
|
1244
|
+
|
|
1115
1245
|
// ELLIPSE
|
|
1246
|
+
|
|
1247
|
+
|
|
1116
1248
|
//public void ellipseMode(int mode)
|
|
1249
|
+
|
|
1250
|
+
|
|
1117
1251
|
//public void ellipse(float a, float b, float c, float d)
|
|
1252
|
+
|
|
1253
|
+
|
|
1118
1254
|
@Override
|
|
1119
1255
|
protected void ellipseImpl(float x, float y, float w, float h) {
|
|
1120
1256
|
ellipse.setFrame(x, y, w, h);
|
|
1121
1257
|
drawShape(ellipse);
|
|
1122
1258
|
}
|
|
1123
1259
|
|
|
1260
|
+
|
|
1261
|
+
|
|
1124
1262
|
//////////////////////////////////////////////////////////////
|
|
1263
|
+
|
|
1125
1264
|
// ARC
|
|
1265
|
+
|
|
1266
|
+
|
|
1126
1267
|
//public void arc(float a, float b, float c, float d,
|
|
1127
1268
|
// float start, float stop)
|
|
1269
|
+
|
|
1270
|
+
|
|
1128
1271
|
@Override
|
|
1129
1272
|
protected void arcImpl(float x, float y, float w, float h,
|
|
1130
|
-
|
|
1273
|
+
float start, float stop, int mode) {
|
|
1131
1274
|
// 0 to 90 in java would be 0 to -90 for p5 renderer
|
|
1132
1275
|
// but that won't work, so -90 to 0?
|
|
1133
1276
|
|
|
@@ -1180,8 +1323,13 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1180
1323
|
}
|
|
1181
1324
|
}
|
|
1182
1325
|
|
|
1326
|
+
|
|
1327
|
+
|
|
1183
1328
|
//////////////////////////////////////////////////////////////
|
|
1329
|
+
|
|
1184
1330
|
// JAVA2D SHAPE/PATH HANDLING
|
|
1331
|
+
|
|
1332
|
+
|
|
1185
1333
|
protected void fillShape(Shape s) {
|
|
1186
1334
|
if (fillGradient) {
|
|
1187
1335
|
g2.setPaint(fillGradientObject);
|
|
@@ -1192,6 +1340,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1192
1340
|
}
|
|
1193
1341
|
}
|
|
1194
1342
|
|
|
1343
|
+
|
|
1195
1344
|
protected void strokeShape(Shape s) {
|
|
1196
1345
|
if (strokeGradient) {
|
|
1197
1346
|
g2.setPaint(strokeGradientObject);
|
|
@@ -1202,6 +1351,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1202
1351
|
}
|
|
1203
1352
|
}
|
|
1204
1353
|
|
|
1354
|
+
|
|
1205
1355
|
protected void drawShape(Shape s) {
|
|
1206
1356
|
if (fillGradient) {
|
|
1207
1357
|
g2.setPaint(fillGradientObject);
|
|
@@ -1219,66 +1369,115 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1219
1369
|
}
|
|
1220
1370
|
}
|
|
1221
1371
|
|
|
1372
|
+
|
|
1373
|
+
|
|
1222
1374
|
//////////////////////////////////////////////////////////////
|
|
1375
|
+
|
|
1223
1376
|
// BOX
|
|
1377
|
+
|
|
1378
|
+
|
|
1224
1379
|
//public void box(float size)
|
|
1380
|
+
|
|
1381
|
+
|
|
1225
1382
|
@Override
|
|
1226
1383
|
public void box(float w, float h, float d) {
|
|
1227
1384
|
showMethodWarning("box");
|
|
1228
1385
|
}
|
|
1229
1386
|
|
|
1387
|
+
|
|
1388
|
+
|
|
1230
1389
|
//////////////////////////////////////////////////////////////
|
|
1390
|
+
|
|
1231
1391
|
// SPHERE
|
|
1392
|
+
|
|
1393
|
+
|
|
1232
1394
|
//public void sphereDetail(int res)
|
|
1395
|
+
|
|
1396
|
+
|
|
1233
1397
|
//public void sphereDetail(int ures, int vres)
|
|
1398
|
+
|
|
1399
|
+
|
|
1234
1400
|
@Override
|
|
1235
1401
|
public void sphere(float r) {
|
|
1236
1402
|
showMethodWarning("sphere");
|
|
1237
1403
|
}
|
|
1238
1404
|
|
|
1405
|
+
|
|
1406
|
+
|
|
1239
1407
|
//////////////////////////////////////////////////////////////
|
|
1408
|
+
|
|
1240
1409
|
// BEZIER
|
|
1410
|
+
|
|
1411
|
+
|
|
1241
1412
|
//public float bezierPoint(float a, float b, float c, float d, float t)
|
|
1413
|
+
|
|
1414
|
+
|
|
1242
1415
|
//public float bezierTangent(float a, float b, float c, float d, float t)
|
|
1416
|
+
|
|
1417
|
+
|
|
1243
1418
|
//protected void bezierInitCheck()
|
|
1419
|
+
|
|
1420
|
+
|
|
1244
1421
|
//protected void bezierInit()
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1422
|
+
|
|
1423
|
+
|
|
1424
|
+
/** Ignored (not needed) in Java 2D. */
|
|
1248
1425
|
@Override
|
|
1249
1426
|
public void bezierDetail(int detail) {
|
|
1250
1427
|
}
|
|
1251
1428
|
|
|
1429
|
+
|
|
1252
1430
|
//public void bezier(float x1, float y1,
|
|
1253
1431
|
// float x2, float y2,
|
|
1254
1432
|
// float x3, float y3,
|
|
1255
1433
|
// float x4, float y4)
|
|
1434
|
+
|
|
1435
|
+
|
|
1256
1436
|
//public void bezier(float x1, float y1, float z1,
|
|
1257
1437
|
// float x2, float y2, float z2,
|
|
1258
1438
|
// float x3, float y3, float z3,
|
|
1259
1439
|
// float x4, float y4, float z4)
|
|
1440
|
+
|
|
1441
|
+
|
|
1442
|
+
|
|
1260
1443
|
//////////////////////////////////////////////////////////////
|
|
1444
|
+
|
|
1261
1445
|
// CURVE
|
|
1262
|
-
|
|
1446
|
+
|
|
1447
|
+
|
|
1448
|
+
//public float curvePoint(float a, float b, float c, float d, float t)
|
|
1449
|
+
|
|
1450
|
+
|
|
1263
1451
|
//public float curveTangent(float a, float b, float c, float d, float t)
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1452
|
+
|
|
1453
|
+
|
|
1454
|
+
/** Ignored (not needed) in Java 2D. */
|
|
1267
1455
|
@Override
|
|
1268
1456
|
public void curveDetail(int detail) {
|
|
1269
1457
|
}
|
|
1270
1458
|
|
|
1271
1459
|
//public void curveTightness(float tightness)
|
|
1460
|
+
|
|
1461
|
+
|
|
1272
1462
|
//protected void curveInitCheck()
|
|
1463
|
+
|
|
1464
|
+
|
|
1273
1465
|
//protected void curveInit()
|
|
1466
|
+
|
|
1467
|
+
|
|
1274
1468
|
//public void curve(float x1, float y1,
|
|
1275
1469
|
// float x2, float y2,
|
|
1276
1470
|
// float x3, float y3,
|
|
1277
1471
|
// float x4, float y4)
|
|
1472
|
+
|
|
1473
|
+
|
|
1278
1474
|
//public void curve(float x1, float y1, float z1,
|
|
1279
1475
|
// float x2, float y2, float z2,
|
|
1280
1476
|
// float x3, float y3, float z3,
|
|
1281
1477
|
// float x4, float y4, float z4)
|
|
1478
|
+
|
|
1479
|
+
|
|
1480
|
+
|
|
1282
1481
|
// //////////////////////////////////////////////////////////////
|
|
1283
1482
|
//
|
|
1284
1483
|
// // SMOOTH
|
|
@@ -1342,34 +1541,53 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1342
1541
|
// g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
|
|
1343
1542
|
// RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
|
|
1344
1543
|
// }
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
|
|
1345
1547
|
//////////////////////////////////////////////////////////////
|
|
1548
|
+
|
|
1346
1549
|
// IMAGE
|
|
1550
|
+
|
|
1551
|
+
|
|
1347
1552
|
//public void imageMode(int mode)
|
|
1553
|
+
|
|
1554
|
+
|
|
1348
1555
|
//public void image(PImage image, float x, float y)
|
|
1556
|
+
|
|
1557
|
+
|
|
1349
1558
|
//public void image(PImage image, float x, float y, float c, float d)
|
|
1559
|
+
|
|
1560
|
+
|
|
1350
1561
|
//public void image(PImage image,
|
|
1351
1562
|
// float a, float b, float c, float d,
|
|
1352
1563
|
// int u1, int v1, int u2, int v2)
|
|
1564
|
+
|
|
1565
|
+
|
|
1353
1566
|
/**
|
|
1354
1567
|
* Handle renderer-specific image drawing.
|
|
1355
|
-
*
|
|
1356
1568
|
* @param who
|
|
1569
|
+
* @param x1
|
|
1570
|
+
* @param y1
|
|
1571
|
+
* @param x2
|
|
1572
|
+
* @param y2
|
|
1573
|
+
* @param u1
|
|
1574
|
+
* @param v1
|
|
1575
|
+
* @param u2
|
|
1576
|
+
* @param v2
|
|
1357
1577
|
*/
|
|
1358
1578
|
@Override
|
|
1359
1579
|
protected void imageImpl(PImage who,
|
|
1360
|
-
|
|
1361
|
-
|
|
1580
|
+
float x1, float y1, float x2, float y2,
|
|
1581
|
+
int u1, int v1, int u2, int v2) {
|
|
1362
1582
|
// Image not ready yet, or an error
|
|
1363
|
-
if (who.width <= 0 || who.height <= 0)
|
|
1364
|
-
return;
|
|
1365
|
-
}
|
|
1583
|
+
if (who.width <= 0 || who.height <= 0) return;
|
|
1366
1584
|
|
|
1367
1585
|
ImageCache cash = (ImageCache) getCache(who);
|
|
1368
1586
|
|
|
1369
1587
|
// Nuke the cache if the image was resized
|
|
1370
1588
|
if (cash != null) {
|
|
1371
|
-
if (who.pixelWidth != cash.image.getWidth()
|
|
1372
|
-
|
|
1589
|
+
if (who.pixelWidth != cash.image.getWidth() ||
|
|
1590
|
+
who.pixelHeight != cash.image.getHeight()) {
|
|
1373
1591
|
cash = null;
|
|
1374
1592
|
}
|
|
1375
1593
|
}
|
|
@@ -1384,9 +1602,9 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1384
1602
|
|
|
1385
1603
|
// If image previously was tinted, or the color changed
|
|
1386
1604
|
// or the image was tinted, and tint is now disabled
|
|
1387
|
-
if ((tint && !cash.tinted)
|
|
1388
|
-
|
|
1389
|
-
|
|
1605
|
+
if ((tint && !cash.tinted) ||
|
|
1606
|
+
(tint && (cash.tintedColor != tintColor)) ||
|
|
1607
|
+
(!tint && cash.tinted)) {
|
|
1390
1608
|
// For tint change, mark all pixels as needing update.
|
|
1391
1609
|
who.updatePixels();
|
|
1392
1610
|
}
|
|
@@ -1408,8 +1626,8 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1408
1626
|
v2 *= who.pixelDensity;
|
|
1409
1627
|
|
|
1410
1628
|
g2.drawImage(((ImageCache) getCache(who)).image,
|
|
1411
|
-
|
|
1412
|
-
|
|
1629
|
+
(int) x1, (int) y1, (int) x2, (int) y2,
|
|
1630
|
+
u1, v1, u2, v2, null);
|
|
1413
1631
|
|
|
1414
1632
|
// Every few years I think "nah, Java2D couldn't possibly be that f*king
|
|
1415
1633
|
// slow, why are we doing this by hand?" then comes the affirmation:
|
|
@@ -1434,8 +1652,8 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1434
1652
|
// }
|
|
1435
1653
|
}
|
|
1436
1654
|
|
|
1437
|
-
static class ImageCache {
|
|
1438
1655
|
|
|
1656
|
+
static class ImageCache {
|
|
1439
1657
|
boolean tinted;
|
|
1440
1658
|
int tintedColor;
|
|
1441
1659
|
int[] tintedTemp; // one row of tinted pixels
|
|
@@ -1450,10 +1668,11 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1450
1668
|
// //System.out.println("making new buffered image");
|
|
1451
1669
|
//// image = new BufferedImage(source.width, source.height, type);
|
|
1452
1670
|
// }
|
|
1671
|
+
|
|
1453
1672
|
/**
|
|
1454
1673
|
* Update the pixels of the cache image. Already determined that the tint
|
|
1455
|
-
* has changed, or the pixels have changed, so should just go through
|
|
1456
|
-
* the update without further checks.
|
|
1674
|
+
* has changed, or the pixels have changed, so should just go through
|
|
1675
|
+
* with the update without further checks.
|
|
1457
1676
|
*/
|
|
1458
1677
|
public void update(PImage source, boolean tint, int tintColor) {
|
|
1459
1678
|
//int bufferType = BufferedImage.TYPE_INT_ARGB;
|
|
@@ -1474,7 +1693,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1474
1693
|
// https://github.com/processing/processing/issues/2030
|
|
1475
1694
|
if (image == null) {
|
|
1476
1695
|
image = new BufferedImage(source.pixelWidth, source.pixelHeight,
|
|
1477
|
-
|
|
1696
|
+
BufferedImage.TYPE_INT_ARGB);
|
|
1478
1697
|
}
|
|
1479
1698
|
|
|
1480
1699
|
WritableRaster wr = image.getRaster();
|
|
@@ -1504,10 +1723,10 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1504
1723
|
// Prior to 2.1, the alpha channel was commented out here,
|
|
1505
1724
|
// but can't remember why (just thought unnecessary b/c of RGB?)
|
|
1506
1725
|
// https://github.com/processing/processing/issues/2030
|
|
1507
|
-
tintedTemp[x] = 0xFF000000
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1726
|
+
tintedTemp[x] = 0xFF000000 |
|
|
1727
|
+
(((r2 * r1) & 0xff00) << 8) |
|
|
1728
|
+
((g2 * g1) & 0xff00) |
|
|
1729
|
+
(((b2 * b1) & 0xff00) >> 8);
|
|
1511
1730
|
}
|
|
1512
1731
|
wr.setDataElements(0, y, source.pixelWidth, 1, tintedTemp);
|
|
1513
1732
|
}
|
|
@@ -1517,10 +1736,10 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1517
1736
|
// RescaleOp op = new RescaleOp(scales, offsets, null);
|
|
1518
1737
|
// op.filter(image, image);
|
|
1519
1738
|
|
|
1520
|
-
|
|
1739
|
+
//} else if (bufferType == BufferedImage.TYPE_INT_ARGB) {
|
|
1521
1740
|
} else if (targetType == ARGB) {
|
|
1522
|
-
if (source.format == RGB
|
|
1523
|
-
|
|
1741
|
+
if (source.format == RGB &&
|
|
1742
|
+
(tintColor & 0xffffff) == 0xffffff) {
|
|
1524
1743
|
int hi = tintColor & 0xff000000;
|
|
1525
1744
|
int index = 0;
|
|
1526
1745
|
for (int y = 0; y < source.pixelHeight; y++) {
|
|
@@ -1540,12 +1759,11 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1540
1759
|
int r1 = (argb1 >> 16) & 0xff;
|
|
1541
1760
|
int g1 = (argb1 >> 8) & 0xff;
|
|
1542
1761
|
int b1 = (argb1) & 0xff;
|
|
1543
|
-
tintedTemp[x] = alpha
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
}
|
|
1548
|
-
break;
|
|
1762
|
+
tintedTemp[x] = alpha |
|
|
1763
|
+
(((r2 * r1) & 0xff00) << 8) |
|
|
1764
|
+
((g2 * g1) & 0xff00) |
|
|
1765
|
+
(((b2 * b1) & 0xff00) >> 8);
|
|
1766
|
+
} break;
|
|
1549
1767
|
case ARGB:
|
|
1550
1768
|
for (int x = 0; x < source.pixelWidth; x++) {
|
|
1551
1769
|
int argb1 = source.pixels[index++];
|
|
@@ -1553,21 +1771,19 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1553
1771
|
int r1 = (argb1 >> 16) & 0xff;
|
|
1554
1772
|
int g1 = (argb1 >> 8) & 0xff;
|
|
1555
1773
|
int b1 = (argb1) & 0xff;
|
|
1556
|
-
tintedTemp[x]
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
}
|
|
1562
|
-
break;
|
|
1774
|
+
tintedTemp[x] =
|
|
1775
|
+
(((a2 * a1) & 0xff00) << 16) |
|
|
1776
|
+
(((r2 * r1) & 0xff00) << 8) |
|
|
1777
|
+
((g2 * g1) & 0xff00) |
|
|
1778
|
+
(((b2 * b1) & 0xff00) >> 8);
|
|
1779
|
+
} break;
|
|
1563
1780
|
case ALPHA:
|
|
1564
1781
|
int lower = tintColor & 0xFFFFFF;
|
|
1565
1782
|
for (int x = 0; x < source.pixelWidth; x++) {
|
|
1566
1783
|
int a1 = source.pixels[index++];
|
|
1567
|
-
tintedTemp[x]
|
|
1568
|
-
|
|
1569
|
-
}
|
|
1570
|
-
break;
|
|
1784
|
+
tintedTemp[x] =
|
|
1785
|
+
(((a2 * a1) & 0xff00) << 16) | lower;
|
|
1786
|
+
} break;
|
|
1571
1787
|
default:
|
|
1572
1788
|
break;
|
|
1573
1789
|
}
|
|
@@ -1607,15 +1823,33 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1607
1823
|
}
|
|
1608
1824
|
}
|
|
1609
1825
|
|
|
1826
|
+
|
|
1827
|
+
|
|
1610
1828
|
//////////////////////////////////////////////////////////////
|
|
1829
|
+
|
|
1611
1830
|
// SHAPE
|
|
1831
|
+
|
|
1832
|
+
|
|
1612
1833
|
//public void shapeMode(int mode)
|
|
1834
|
+
|
|
1835
|
+
|
|
1613
1836
|
//public void shape(PShape shape)
|
|
1837
|
+
|
|
1838
|
+
|
|
1614
1839
|
//public void shape(PShape shape, float x, float y)
|
|
1840
|
+
|
|
1841
|
+
|
|
1615
1842
|
//public void shape(PShape shape, float x, float y, float c, float d)
|
|
1843
|
+
|
|
1844
|
+
|
|
1616
1845
|
//////////////////////////////////////////////////////////////
|
|
1846
|
+
|
|
1617
1847
|
// SHAPE I/O
|
|
1848
|
+
|
|
1849
|
+
|
|
1618
1850
|
//public PShape loadShape(String filename)
|
|
1851
|
+
|
|
1852
|
+
|
|
1619
1853
|
@Override
|
|
1620
1854
|
public PShape loadShape(String filename, String options) {
|
|
1621
1855
|
String extension = PApplet.getExtension(filename);
|
|
@@ -1626,10 +1860,19 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1626
1860
|
return null;
|
|
1627
1861
|
}
|
|
1628
1862
|
|
|
1863
|
+
|
|
1864
|
+
|
|
1629
1865
|
//////////////////////////////////////////////////////////////
|
|
1866
|
+
|
|
1630
1867
|
// TEXT ATTRIBTUES
|
|
1868
|
+
|
|
1869
|
+
|
|
1631
1870
|
//public void textAlign(int align)
|
|
1871
|
+
|
|
1872
|
+
|
|
1632
1873
|
//public void textAlign(int alignX, int alignY)
|
|
1874
|
+
|
|
1875
|
+
|
|
1633
1876
|
@Override
|
|
1634
1877
|
public float textAscent() {
|
|
1635
1878
|
if (textFont == null) {
|
|
@@ -1644,6 +1887,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1644
1887
|
return super.textAscent();
|
|
1645
1888
|
}
|
|
1646
1889
|
|
|
1890
|
+
|
|
1647
1891
|
@Override
|
|
1648
1892
|
public float textDescent() {
|
|
1649
1893
|
if (textFont == null) {
|
|
@@ -1657,20 +1901,30 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1657
1901
|
return super.textDescent();
|
|
1658
1902
|
}
|
|
1659
1903
|
|
|
1904
|
+
|
|
1660
1905
|
//public void textFont(PFont which)
|
|
1906
|
+
|
|
1907
|
+
|
|
1661
1908
|
//public void textFont(PFont which, float size)
|
|
1909
|
+
|
|
1910
|
+
|
|
1662
1911
|
//public void textLeading(float leading)
|
|
1912
|
+
|
|
1913
|
+
|
|
1663
1914
|
//public void textMode(int mode)
|
|
1915
|
+
|
|
1916
|
+
|
|
1664
1917
|
@Override
|
|
1665
1918
|
protected boolean textModeCheck(int mode) {
|
|
1666
1919
|
return mode == MODEL;
|
|
1667
1920
|
}
|
|
1668
1921
|
|
|
1922
|
+
|
|
1669
1923
|
/**
|
|
1670
1924
|
* Same as parent, but override for native version of the font.
|
|
1671
|
-
*
|
|
1672
|
-
* Called from textFontImpl and textSizeImpl, so the metrics
|
|
1673
|
-
* properly.
|
|
1925
|
+
*
|
|
1926
|
+
* Called from textFontImpl and textSizeImpl, so the metrics
|
|
1927
|
+
* will get recorded properly.
|
|
1674
1928
|
*/
|
|
1675
1929
|
@Override
|
|
1676
1930
|
protected void handleTextSize(float size) {
|
|
@@ -1679,11 +1933,11 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1679
1933
|
// don't derive again if the font size has not changed
|
|
1680
1934
|
if (font != null) {
|
|
1681
1935
|
if (font.getSize2D() != size) {
|
|
1682
|
-
Map<TextAttribute, Object> map
|
|
1683
|
-
|
|
1936
|
+
Map<TextAttribute, Object> map =
|
|
1937
|
+
new HashMap<>();
|
|
1684
1938
|
map.put(TextAttribute.SIZE, size);
|
|
1685
1939
|
map.put(TextAttribute.KERNING,
|
|
1686
|
-
|
|
1940
|
+
TextAttribute.KERNING_ON);
|
|
1687
1941
|
// map.put(TextAttribute.TRACKING,
|
|
1688
1942
|
// TextAttribute.TRACKING_TIGHT);
|
|
1689
1943
|
font = font.deriveFont(map);
|
|
@@ -1697,7 +1951,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1697
1951
|
for (TextAttribute ta : attrs.keySet()) {
|
|
1698
1952
|
System.out.println(ta + " -> " + attrs.get(ta));
|
|
1699
1953
|
}
|
|
1700
|
-
|
|
1954
|
+
*/
|
|
1701
1955
|
}
|
|
1702
1956
|
|
|
1703
1957
|
// take care of setting the textSize and textLeading vars
|
|
@@ -1706,10 +1960,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1706
1960
|
super.handleTextSize(size);
|
|
1707
1961
|
}
|
|
1708
1962
|
|
|
1963
|
+
|
|
1709
1964
|
//public float textWidth(char c)
|
|
1965
|
+
|
|
1966
|
+
|
|
1710
1967
|
//public float textWidth(String str)
|
|
1968
|
+
|
|
1969
|
+
|
|
1711
1970
|
@Override
|
|
1712
|
-
protected float textWidthImpl(char buffer
|
|
1971
|
+
protected float textWidthImpl(char[] buffer, int start, int stop) {
|
|
1713
1972
|
if (textFont == null) {
|
|
1714
1973
|
defaultFontOrDeath("textWidth");
|
|
1715
1974
|
}
|
|
@@ -1742,28 +2001,44 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1742
2001
|
//// return m2;
|
|
1743
2002
|
//// return metrics.charsWidth(buffer, start, length);
|
|
1744
2003
|
// return m2;
|
|
1745
|
-
return (float)
|
|
2004
|
+
return (float)
|
|
2005
|
+
metrics.getStringBounds(buffer, start, stop, g2).getWidth();
|
|
1746
2006
|
}
|
|
1747
2007
|
// System.err.println("not native");
|
|
1748
2008
|
return super.textWidthImpl(buffer, start, stop);
|
|
1749
2009
|
}
|
|
1750
2010
|
|
|
2011
|
+
|
|
1751
2012
|
// protected void beginTextScreenMode() {
|
|
1752
2013
|
// loadPixels();
|
|
1753
2014
|
// }
|
|
2015
|
+
|
|
2016
|
+
|
|
1754
2017
|
// protected void endTextScreenMode() {
|
|
1755
2018
|
// updatePixels();
|
|
1756
2019
|
// }
|
|
2020
|
+
|
|
2021
|
+
|
|
1757
2022
|
//////////////////////////////////////////////////////////////
|
|
2023
|
+
|
|
1758
2024
|
// TEXT
|
|
2025
|
+
|
|
1759
2026
|
// None of the variations of text() are overridden from PGraphics.
|
|
2027
|
+
|
|
2028
|
+
|
|
2029
|
+
|
|
1760
2030
|
//////////////////////////////////////////////////////////////
|
|
2031
|
+
|
|
1761
2032
|
// TEXT IMPL
|
|
2033
|
+
|
|
2034
|
+
|
|
1762
2035
|
//protected void textLineAlignImpl(char buffer[], int start, int stop,
|
|
1763
2036
|
// float x, float y)
|
|
2037
|
+
|
|
2038
|
+
|
|
1764
2039
|
@Override
|
|
1765
|
-
protected void textLineImpl(char buffer
|
|
1766
|
-
|
|
2040
|
+
protected void textLineImpl(char[] buffer, int start, int stop,
|
|
2041
|
+
float x, float y) {
|
|
1767
2042
|
Font font = (Font) textFont.getNative();
|
|
1768
2043
|
// if (font != null && (textFont.isStream() || hints[ENABLE_NATIVE_FONTS])) {
|
|
1769
2044
|
if (font != null) {
|
|
@@ -1781,9 +2056,9 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1781
2056
|
textFont.smooth ?
|
|
1782
2057
|
RenderingHints.VALUE_ANTIALIAS_ON :
|
|
1783
2058
|
RenderingHints.VALUE_ANTIALIAS_OFF);
|
|
1784
|
-
|
|
1785
|
-
Object antialias
|
|
1786
|
-
|
|
2059
|
+
*/
|
|
2060
|
+
Object antialias =
|
|
2061
|
+
g2.getRenderingHint(RenderingHints.KEY_ANTIALIASING);
|
|
1787
2062
|
if (antialias == null) {
|
|
1788
2063
|
// if smooth() and noSmooth() not called, this will be null (0120)
|
|
1789
2064
|
antialias = RenderingHints.VALUE_ANTIALIAS_DEFAULT;
|
|
@@ -1793,22 +2068,23 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1793
2068
|
// also changes global setting for antialiasing, but this is because it's
|
|
1794
2069
|
// not possible to enable/disable them independently in some situations.
|
|
1795
2070
|
g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
2071
|
+
textFont.isSmooth() ?
|
|
2072
|
+
RenderingHints.VALUE_ANTIALIAS_ON :
|
|
2073
|
+
RenderingHints.VALUE_ANTIALIAS_OFF);
|
|
1799
2074
|
|
|
1800
2075
|
g2.setColor(fillColorObject);
|
|
1801
2076
|
|
|
1802
2077
|
int length = stop - start;
|
|
1803
2078
|
if (length != 0) {
|
|
1804
|
-
|
|
1805
|
-
|
|
2079
|
+
g2.drawChars(buffer, start, length, (int) (x + 0.5f), (int) (y + 0.5f));
|
|
2080
|
+
// better to use round here? also, drawChars now just calls drawString
|
|
1806
2081
|
// g2.drawString(new String(buffer, start, stop - start), Math.round(x), Math.round(y));
|
|
1807
2082
|
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
2083
|
+
// better to use drawString() with floats? (nope, draws the same)
|
|
2084
|
+
//g2.drawString(new String(buffer, start, length), x, y);
|
|
2085
|
+
|
|
2086
|
+
// this didn't seem to help the scaling issue, and creates garbage
|
|
2087
|
+
// because of a fairly heavyweight new temporary object
|
|
1812
2088
|
// java.awt.font.GlyphVector gv =
|
|
1813
2089
|
// font.createGlyphVector(g2.getFontRenderContext(), new String(buffer, start, stop - start));
|
|
1814
2090
|
// g2.drawGlyphVector(gv, x, y);
|
|
@@ -1823,6 +2099,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1823
2099
|
}
|
|
1824
2100
|
}
|
|
1825
2101
|
|
|
2102
|
+
|
|
1826
2103
|
// /**
|
|
1827
2104
|
// * Convenience method to get a legit FontMetrics object. Where possible,
|
|
1828
2105
|
// * override this any renderer subclass so that you're not using what's
|
|
@@ -1862,121 +2139,161 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1862
2139
|
return toolkit.getFontMetrics(font);
|
|
1863
2140
|
//return (g2 != null) ? g2.getFontMetrics(font) : super.getFontMetrics(font);
|
|
1864
2141
|
}
|
|
1865
|
-
|
|
2142
|
+
*/
|
|
2143
|
+
|
|
2144
|
+
|
|
1866
2145
|
//////////////////////////////////////////////////////////////
|
|
2146
|
+
|
|
1867
2147
|
// MATRIX STACK
|
|
2148
|
+
|
|
2149
|
+
|
|
1868
2150
|
@Override
|
|
1869
2151
|
public void pushMatrix() {
|
|
1870
2152
|
if (transformCount == transformStack.length) {
|
|
1871
|
-
throw new RuntimeException("pushMatrix() cannot use push more than "
|
|
1872
|
-
|
|
2153
|
+
throw new RuntimeException("pushMatrix() cannot use push more than " +
|
|
2154
|
+
transformStack.length + " times");
|
|
1873
2155
|
}
|
|
1874
2156
|
transformStack[transformCount] = g2.getTransform();
|
|
1875
2157
|
transformCount++;
|
|
1876
2158
|
}
|
|
1877
2159
|
|
|
2160
|
+
|
|
1878
2161
|
@Override
|
|
1879
2162
|
public void popMatrix() {
|
|
1880
2163
|
if (transformCount == 0) {
|
|
1881
|
-
throw new RuntimeException("missing a pushMatrix() "
|
|
1882
|
-
|
|
2164
|
+
throw new RuntimeException("missing a pushMatrix() " +
|
|
2165
|
+
"to go with that popMatrix()");
|
|
1883
2166
|
}
|
|
1884
2167
|
transformCount--;
|
|
1885
2168
|
g2.setTransform(transformStack[transformCount]);
|
|
1886
2169
|
}
|
|
1887
2170
|
|
|
2171
|
+
|
|
2172
|
+
|
|
1888
2173
|
//////////////////////////////////////////////////////////////
|
|
2174
|
+
|
|
1889
2175
|
// MATRIX TRANSFORMS
|
|
2176
|
+
|
|
2177
|
+
|
|
1890
2178
|
@Override
|
|
1891
2179
|
public void translate(float tx, float ty) {
|
|
1892
2180
|
g2.translate(tx, ty);
|
|
1893
2181
|
}
|
|
1894
2182
|
|
|
2183
|
+
|
|
1895
2184
|
//public void translate(float tx, float ty, float tz)
|
|
2185
|
+
|
|
2186
|
+
|
|
1896
2187
|
@Override
|
|
1897
2188
|
public void rotate(float angle) {
|
|
1898
2189
|
g2.rotate(angle);
|
|
1899
2190
|
}
|
|
1900
2191
|
|
|
2192
|
+
|
|
1901
2193
|
@Override
|
|
1902
2194
|
public void rotateX(float angle) {
|
|
1903
2195
|
showDepthWarning("rotateX");
|
|
1904
2196
|
}
|
|
1905
2197
|
|
|
2198
|
+
|
|
1906
2199
|
@Override
|
|
1907
2200
|
public void rotateY(float angle) {
|
|
1908
2201
|
showDepthWarning("rotateY");
|
|
1909
2202
|
}
|
|
1910
2203
|
|
|
2204
|
+
|
|
1911
2205
|
@Override
|
|
1912
2206
|
public void rotateZ(float angle) {
|
|
1913
2207
|
showDepthWarning("rotateZ");
|
|
1914
2208
|
}
|
|
1915
2209
|
|
|
2210
|
+
|
|
1916
2211
|
@Override
|
|
1917
2212
|
public void rotate(float angle, float vx, float vy, float vz) {
|
|
1918
2213
|
showVariationWarning("rotate");
|
|
1919
2214
|
}
|
|
1920
2215
|
|
|
2216
|
+
|
|
1921
2217
|
@Override
|
|
1922
2218
|
public void scale(float s) {
|
|
1923
2219
|
g2.scale(s, s);
|
|
1924
2220
|
}
|
|
1925
2221
|
|
|
2222
|
+
|
|
1926
2223
|
@Override
|
|
1927
2224
|
public void scale(float sx, float sy) {
|
|
1928
2225
|
g2.scale(sx, sy);
|
|
1929
2226
|
}
|
|
1930
2227
|
|
|
2228
|
+
|
|
1931
2229
|
@Override
|
|
1932
2230
|
public void scale(float sx, float sy, float sz) {
|
|
1933
2231
|
showDepthWarningXYZ("scale");
|
|
1934
2232
|
}
|
|
1935
2233
|
|
|
2234
|
+
|
|
1936
2235
|
@Override
|
|
1937
2236
|
public void shearX(float angle) {
|
|
1938
2237
|
g2.shear(Math.tan(angle), 0);
|
|
1939
2238
|
}
|
|
1940
2239
|
|
|
2240
|
+
|
|
1941
2241
|
@Override
|
|
1942
2242
|
public void shearY(float angle) {
|
|
1943
2243
|
g2.shear(0, Math.tan(angle));
|
|
1944
2244
|
}
|
|
1945
2245
|
|
|
2246
|
+
|
|
2247
|
+
|
|
1946
2248
|
//////////////////////////////////////////////////////////////
|
|
2249
|
+
|
|
1947
2250
|
// MATRIX MORE
|
|
2251
|
+
|
|
2252
|
+
|
|
1948
2253
|
@Override
|
|
1949
2254
|
public void resetMatrix() {
|
|
1950
2255
|
g2.setTransform(new AffineTransform());
|
|
1951
2256
|
g2.scale(pixelDensity, pixelDensity);
|
|
1952
2257
|
}
|
|
1953
2258
|
|
|
2259
|
+
|
|
1954
2260
|
//public void applyMatrix(PMatrix2D source)
|
|
2261
|
+
|
|
2262
|
+
|
|
1955
2263
|
@Override
|
|
1956
2264
|
public void applyMatrix(float n00, float n01, float n02,
|
|
1957
|
-
|
|
2265
|
+
float n10, float n11, float n12) {
|
|
1958
2266
|
//System.out.println("PGraphicsJava2D.applyMatrix()");
|
|
1959
2267
|
//System.out.println(new AffineTransform(n00, n10, n01, n11, n02, n12));
|
|
1960
2268
|
g2.transform(new AffineTransform(n00, n10, n01, n11, n02, n12));
|
|
1961
2269
|
//g2.transform(new AffineTransform(n00, n01, n02, n10, n11, n12));
|
|
1962
2270
|
}
|
|
1963
2271
|
|
|
2272
|
+
|
|
1964
2273
|
//public void applyMatrix(PMatrix3D source)
|
|
2274
|
+
|
|
2275
|
+
|
|
1965
2276
|
@Override
|
|
1966
2277
|
public void applyMatrix(float n00, float n01, float n02, float n03,
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
2278
|
+
float n10, float n11, float n12, float n13,
|
|
2279
|
+
float n20, float n21, float n22, float n23,
|
|
2280
|
+
float n30, float n31, float n32, float n33) {
|
|
1970
2281
|
showVariationWarning("applyMatrix");
|
|
1971
2282
|
}
|
|
1972
2283
|
|
|
2284
|
+
|
|
2285
|
+
|
|
1973
2286
|
//////////////////////////////////////////////////////////////
|
|
2287
|
+
|
|
1974
2288
|
// MATRIX GET/SET
|
|
2289
|
+
|
|
2290
|
+
|
|
1975
2291
|
@Override
|
|
1976
2292
|
public PMatrix getMatrix() {
|
|
1977
2293
|
return getMatrix((PMatrix2D) null);
|
|
1978
2294
|
}
|
|
1979
2295
|
|
|
2296
|
+
|
|
1980
2297
|
@Override
|
|
1981
2298
|
public PMatrix2D getMatrix(PMatrix2D target) {
|
|
1982
2299
|
if (target == null) {
|
|
@@ -1984,37 +2301,49 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
1984
2301
|
}
|
|
1985
2302
|
g2.getTransform().getMatrix(transform);
|
|
1986
2303
|
target.set((float) transform[0], (float) transform[2], (float) transform[4],
|
|
1987
|
-
|
|
2304
|
+
(float) transform[1], (float) transform[3], (float) transform[5]);
|
|
1988
2305
|
return target;
|
|
1989
2306
|
}
|
|
1990
2307
|
|
|
2308
|
+
|
|
1991
2309
|
@Override
|
|
1992
2310
|
public PMatrix3D getMatrix(PMatrix3D target) {
|
|
1993
2311
|
showVariationWarning("getMatrix");
|
|
1994
2312
|
return target;
|
|
1995
2313
|
}
|
|
1996
2314
|
|
|
2315
|
+
|
|
1997
2316
|
//public void setMatrix(PMatrix source)
|
|
2317
|
+
|
|
2318
|
+
|
|
1998
2319
|
@Override
|
|
1999
2320
|
public void setMatrix(PMatrix2D source) {
|
|
2000
2321
|
g2.setTransform(new AffineTransform(source.m00, source.m10,
|
|
2001
|
-
|
|
2002
|
-
|
|
2322
|
+
source.m01, source.m11,
|
|
2323
|
+
source.m02, source.m12));
|
|
2003
2324
|
}
|
|
2004
2325
|
|
|
2326
|
+
|
|
2005
2327
|
@Override
|
|
2006
2328
|
public void setMatrix(PMatrix3D source) {
|
|
2007
2329
|
showVariationWarning("setMatrix");
|
|
2008
2330
|
}
|
|
2009
2331
|
|
|
2332
|
+
|
|
2010
2333
|
@Override
|
|
2011
2334
|
public void printMatrix() {
|
|
2012
2335
|
getMatrix((PMatrix2D) null).print();
|
|
2013
2336
|
}
|
|
2014
2337
|
|
|
2338
|
+
|
|
2339
|
+
|
|
2015
2340
|
//////////////////////////////////////////////////////////////
|
|
2341
|
+
|
|
2016
2342
|
// CAMERA and PROJECTION
|
|
2343
|
+
|
|
2017
2344
|
// Inherit the plaintive warnings from PGraphics
|
|
2345
|
+
|
|
2346
|
+
|
|
2018
2347
|
//public void beginCamera()
|
|
2019
2348
|
//public void endCamera()
|
|
2020
2349
|
//public void camera()
|
|
@@ -2022,6 +2351,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2022
2351
|
// float centerX, float centerY, float centerZ,
|
|
2023
2352
|
// float upX, float upY, float upZ)
|
|
2024
2353
|
//public void printCamera()
|
|
2354
|
+
|
|
2025
2355
|
//public void ortho()
|
|
2026
2356
|
//public void ortho(float left, float right,
|
|
2027
2357
|
// float bottom, float top,
|
|
@@ -2032,64 +2362,93 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2032
2362
|
// float bottom, float top,
|
|
2033
2363
|
// float near, float far)
|
|
2034
2364
|
//public void printProjection()
|
|
2365
|
+
|
|
2366
|
+
|
|
2367
|
+
|
|
2035
2368
|
//////////////////////////////////////////////////////////////
|
|
2369
|
+
|
|
2036
2370
|
// SCREEN and MODEL transforms
|
|
2371
|
+
|
|
2372
|
+
|
|
2037
2373
|
@Override
|
|
2038
2374
|
public float screenX(float x, float y) {
|
|
2039
2375
|
g2.getTransform().getMatrix(transform);
|
|
2040
|
-
return (float)
|
|
2376
|
+
return (float)transform[0]*x + (float)transform[2]*y + (float)transform[4];
|
|
2041
2377
|
}
|
|
2042
2378
|
|
|
2379
|
+
|
|
2043
2380
|
@Override
|
|
2044
2381
|
public float screenY(float x, float y) {
|
|
2045
2382
|
g2.getTransform().getMatrix(transform);
|
|
2046
|
-
return (float)
|
|
2383
|
+
return (float)transform[1]*x + (float)transform[3]*y + (float)transform[5];
|
|
2047
2384
|
}
|
|
2048
2385
|
|
|
2386
|
+
|
|
2049
2387
|
@Override
|
|
2050
2388
|
public float screenX(float x, float y, float z) {
|
|
2051
2389
|
showDepthWarningXYZ("screenX");
|
|
2052
2390
|
return 0;
|
|
2053
2391
|
}
|
|
2054
2392
|
|
|
2393
|
+
|
|
2055
2394
|
@Override
|
|
2056
2395
|
public float screenY(float x, float y, float z) {
|
|
2057
2396
|
showDepthWarningXYZ("screenY");
|
|
2058
2397
|
return 0;
|
|
2059
2398
|
}
|
|
2060
2399
|
|
|
2400
|
+
|
|
2061
2401
|
@Override
|
|
2062
2402
|
public float screenZ(float x, float y, float z) {
|
|
2063
2403
|
showDepthWarningXYZ("screenZ");
|
|
2064
2404
|
return 0;
|
|
2065
2405
|
}
|
|
2066
2406
|
|
|
2407
|
+
|
|
2067
2408
|
//public float modelX(float x, float y, float z)
|
|
2409
|
+
|
|
2410
|
+
|
|
2068
2411
|
//public float modelY(float x, float y, float z)
|
|
2412
|
+
|
|
2413
|
+
|
|
2069
2414
|
//public float modelZ(float x, float y, float z)
|
|
2415
|
+
|
|
2416
|
+
|
|
2417
|
+
|
|
2070
2418
|
//////////////////////////////////////////////////////////////
|
|
2419
|
+
|
|
2071
2420
|
// STYLE
|
|
2421
|
+
|
|
2072
2422
|
// pushStyle(), popStyle(), style() and getStyle() inherited.
|
|
2423
|
+
|
|
2424
|
+
|
|
2425
|
+
|
|
2073
2426
|
//////////////////////////////////////////////////////////////
|
|
2427
|
+
|
|
2074
2428
|
// STROKE CAP/JOIN/WEIGHT
|
|
2429
|
+
|
|
2430
|
+
|
|
2075
2431
|
@Override
|
|
2076
2432
|
public void strokeCap(int cap) {
|
|
2077
2433
|
super.strokeCap(cap);
|
|
2078
2434
|
strokeImpl();
|
|
2079
2435
|
}
|
|
2080
2436
|
|
|
2437
|
+
|
|
2081
2438
|
@Override
|
|
2082
2439
|
public void strokeJoin(int join) {
|
|
2083
2440
|
super.strokeJoin(join);
|
|
2084
2441
|
strokeImpl();
|
|
2085
2442
|
}
|
|
2086
2443
|
|
|
2444
|
+
|
|
2087
2445
|
@Override
|
|
2088
2446
|
public void strokeWeight(float weight) {
|
|
2089
2447
|
super.strokeWeight(weight);
|
|
2090
2448
|
strokeImpl();
|
|
2091
2449
|
}
|
|
2092
2450
|
|
|
2451
|
+
|
|
2093
2452
|
protected void strokeImpl() {
|
|
2094
2453
|
int cap = BasicStroke.CAP_BUTT;
|
|
2095
2454
|
if (strokeCap == ROUND) {
|
|
@@ -2109,9 +2468,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2109
2468
|
g2.setStroke(strokeObject);
|
|
2110
2469
|
}
|
|
2111
2470
|
|
|
2471
|
+
|
|
2472
|
+
|
|
2112
2473
|
//////////////////////////////////////////////////////////////
|
|
2474
|
+
|
|
2113
2475
|
// STROKE
|
|
2476
|
+
|
|
2114
2477
|
// noStroke() and stroke() inherited from PGraphics.
|
|
2478
|
+
|
|
2479
|
+
|
|
2115
2480
|
@Override
|
|
2116
2481
|
protected void strokeFromCalc() {
|
|
2117
2482
|
super.strokeFromCalc();
|
|
@@ -2119,9 +2484,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2119
2484
|
strokeGradient = false;
|
|
2120
2485
|
}
|
|
2121
2486
|
|
|
2487
|
+
|
|
2488
|
+
|
|
2122
2489
|
//////////////////////////////////////////////////////////////
|
|
2490
|
+
|
|
2123
2491
|
// TINT
|
|
2492
|
+
|
|
2124
2493
|
// noTint() and tint() inherited from PGraphics.
|
|
2494
|
+
|
|
2495
|
+
|
|
2125
2496
|
@Override
|
|
2126
2497
|
protected void tintFromCalc() {
|
|
2127
2498
|
super.tintFromCalc();
|
|
@@ -2129,9 +2500,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2129
2500
|
tintColorObject = new Color(tintColor, true);
|
|
2130
2501
|
}
|
|
2131
2502
|
|
|
2503
|
+
|
|
2504
|
+
|
|
2132
2505
|
//////////////////////////////////////////////////////////////
|
|
2506
|
+
|
|
2133
2507
|
// FILL
|
|
2508
|
+
|
|
2134
2509
|
// noFill() and fill() inherited from PGraphics.
|
|
2510
|
+
|
|
2511
|
+
|
|
2135
2512
|
@Override
|
|
2136
2513
|
protected void fillFromCalc() {
|
|
2137
2514
|
super.fillFromCalc();
|
|
@@ -2139,8 +2516,13 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2139
2516
|
fillGradient = false;
|
|
2140
2517
|
}
|
|
2141
2518
|
|
|
2519
|
+
|
|
2520
|
+
|
|
2142
2521
|
//////////////////////////////////////////////////////////////
|
|
2522
|
+
|
|
2143
2523
|
// MATERIAL PROPERTIES
|
|
2524
|
+
|
|
2525
|
+
|
|
2144
2526
|
//public void ambient(int rgb)
|
|
2145
2527
|
//public void ambient(float gray)
|
|
2146
2528
|
//public void ambient(float x, float y, float z)
|
|
@@ -2154,8 +2536,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2154
2536
|
//public void emissive(float gray)
|
|
2155
2537
|
//public void emissive(float x, float y, float z )
|
|
2156
2538
|
//protected void emissiveFromCalc()
|
|
2539
|
+
|
|
2540
|
+
|
|
2541
|
+
|
|
2157
2542
|
//////////////////////////////////////////////////////////////
|
|
2543
|
+
|
|
2158
2544
|
// LIGHTS
|
|
2545
|
+
|
|
2546
|
+
|
|
2159
2547
|
//public void lights()
|
|
2160
2548
|
//public void noLights()
|
|
2161
2549
|
//public void ambientLight(float red, float green, float blue)
|
|
@@ -2173,8 +2561,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2173
2561
|
//public void lightSpecular(float x, float y, float z)
|
|
2174
2562
|
//protected void lightPosition(int num, float x, float y, float z)
|
|
2175
2563
|
//protected void lightDirection(int num, float x, float y, float z)
|
|
2564
|
+
|
|
2565
|
+
|
|
2566
|
+
|
|
2176
2567
|
//////////////////////////////////////////////////////////////
|
|
2568
|
+
|
|
2177
2569
|
// BACKGROUND
|
|
2570
|
+
|
|
2571
|
+
|
|
2178
2572
|
int[] clearPixels;
|
|
2179
2573
|
|
|
2180
2574
|
protected void clearPixels(int color) {
|
|
@@ -2202,7 +2596,11 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2202
2596
|
|
|
2203
2597
|
// background() methods inherited from PGraphics, along with the
|
|
2204
2598
|
// PImage version of backgroundImpl(), since it just calls set().
|
|
2599
|
+
|
|
2600
|
+
|
|
2205
2601
|
//public void backgroundImpl(PImage image)
|
|
2602
|
+
|
|
2603
|
+
|
|
2206
2604
|
@Override
|
|
2207
2605
|
public void backgroundImpl() {
|
|
2208
2606
|
if (backgroundAlpha) {
|
|
@@ -2239,45 +2637,98 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2239
2637
|
}
|
|
2240
2638
|
}
|
|
2241
2639
|
|
|
2640
|
+
|
|
2641
|
+
|
|
2242
2642
|
//////////////////////////////////////////////////////////////
|
|
2643
|
+
|
|
2243
2644
|
// COLOR MODE
|
|
2645
|
+
|
|
2244
2646
|
// All colorMode() variations are inherited from PGraphics.
|
|
2647
|
+
|
|
2648
|
+
|
|
2649
|
+
|
|
2245
2650
|
//////////////////////////////////////////////////////////////
|
|
2651
|
+
|
|
2246
2652
|
// COLOR CALC
|
|
2653
|
+
|
|
2247
2654
|
// colorCalc() and colorCalcARGB() inherited from PGraphics.
|
|
2655
|
+
|
|
2656
|
+
|
|
2657
|
+
|
|
2248
2658
|
//////////////////////////////////////////////////////////////
|
|
2659
|
+
|
|
2249
2660
|
// COLOR DATATYPE STUFFING
|
|
2661
|
+
|
|
2250
2662
|
// final color() variations inherited.
|
|
2663
|
+
|
|
2664
|
+
|
|
2665
|
+
|
|
2251
2666
|
//////////////////////////////////////////////////////////////
|
|
2667
|
+
|
|
2252
2668
|
// COLOR DATATYPE EXTRACTION
|
|
2669
|
+
|
|
2253
2670
|
// final methods alpha, red, green, blue,
|
|
2254
2671
|
// hue, saturation, and brightness all inherited.
|
|
2672
|
+
|
|
2673
|
+
|
|
2674
|
+
|
|
2255
2675
|
//////////////////////////////////////////////////////////////
|
|
2676
|
+
|
|
2256
2677
|
// COLOR DATATYPE INTERPOLATION
|
|
2678
|
+
|
|
2257
2679
|
// both lerpColor variants inherited.
|
|
2680
|
+
|
|
2681
|
+
|
|
2682
|
+
|
|
2258
2683
|
//////////////////////////////////////////////////////////////
|
|
2684
|
+
|
|
2259
2685
|
// BEGIN/END RAW
|
|
2686
|
+
|
|
2687
|
+
|
|
2260
2688
|
@Override
|
|
2261
2689
|
public void beginRaw(PGraphics recorderRaw) {
|
|
2262
2690
|
showMethodWarning("beginRaw");
|
|
2263
2691
|
}
|
|
2264
2692
|
|
|
2693
|
+
|
|
2265
2694
|
@Override
|
|
2266
2695
|
public void endRaw() {
|
|
2267
2696
|
showMethodWarning("endRaw");
|
|
2268
2697
|
}
|
|
2269
2698
|
|
|
2699
|
+
|
|
2700
|
+
|
|
2270
2701
|
//////////////////////////////////////////////////////////////
|
|
2702
|
+
|
|
2271
2703
|
// WARNINGS and EXCEPTIONS
|
|
2704
|
+
|
|
2272
2705
|
// showWarning and showException inherited.
|
|
2706
|
+
|
|
2707
|
+
|
|
2708
|
+
|
|
2273
2709
|
//////////////////////////////////////////////////////////////
|
|
2710
|
+
|
|
2274
2711
|
// RENDERER SUPPORT QUERIES
|
|
2712
|
+
|
|
2713
|
+
|
|
2275
2714
|
//public boolean displayable() // true
|
|
2715
|
+
|
|
2716
|
+
|
|
2276
2717
|
//public boolean is2D() // true
|
|
2718
|
+
|
|
2719
|
+
|
|
2277
2720
|
//public boolean is3D() // false
|
|
2721
|
+
|
|
2722
|
+
|
|
2723
|
+
|
|
2278
2724
|
//////////////////////////////////////////////////////////////
|
|
2725
|
+
|
|
2279
2726
|
// PIMAGE METHODS
|
|
2727
|
+
|
|
2728
|
+
|
|
2280
2729
|
// getImage, setCache, getCache, removeCache, isModified, setModified
|
|
2730
|
+
|
|
2731
|
+
|
|
2281
2732
|
protected WritableRaster getRaster() {
|
|
2282
2733
|
WritableRaster raster = null;
|
|
2283
2734
|
if (primaryGraphics) {
|
|
@@ -2308,9 +2759,10 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2308
2759
|
return raster;
|
|
2309
2760
|
}
|
|
2310
2761
|
|
|
2762
|
+
|
|
2311
2763
|
@Override
|
|
2312
2764
|
public void loadPixels() {
|
|
2313
|
-
if (pixels == null || (pixels.length != pixelWidth
|
|
2765
|
+
if (pixels == null || (pixels.length != pixelWidth*pixelHeight)) {
|
|
2314
2766
|
pixels = new int[pixelWidth * pixelHeight];
|
|
2315
2767
|
}
|
|
2316
2768
|
|
|
@@ -2323,11 +2775,12 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2323
2775
|
pixels[i] = 0xff000000 | pixels[i];
|
|
2324
2776
|
}
|
|
2325
2777
|
}
|
|
2326
|
-
|
|
2778
|
+
//((BufferedImage) image).getRGB(0, 0, width, height, pixels, 0, width);
|
|
2327
2779
|
// WritableRaster raster = ((BufferedImage) (useOffscreen && primarySurface ? offscreen : image)).getRaster();
|
|
2328
2780
|
// WritableRaster raster = image.getRaster();
|
|
2329
2781
|
}
|
|
2330
2782
|
|
|
2783
|
+
|
|
2331
2784
|
// /**
|
|
2332
2785
|
// * Update the pixels[] buffer to the PGraphics image.
|
|
2333
2786
|
// * <P>
|
|
@@ -2341,11 +2794,15 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2341
2794
|
//// WritableRaster raster = image.getRaster();
|
|
2342
2795
|
// updatePixels(0, 0, width, height);
|
|
2343
2796
|
// }
|
|
2797
|
+
|
|
2798
|
+
|
|
2344
2799
|
/**
|
|
2345
2800
|
* Update the pixels[] buffer to the PGraphics image.
|
|
2346
2801
|
* <P>
|
|
2347
|
-
* Unlike in PImage, where updatePixels() only requests that the
|
|
2348
|
-
* happens, in PGraphicsJava2D, this will happen immediately.
|
|
2802
|
+
* Unlike in PImage, where updatePixels() only requests that the
|
|
2803
|
+
* update happens, in PGraphicsJava2D, this will happen immediately.
|
|
2804
|
+
* @param c
|
|
2805
|
+
* @param d
|
|
2349
2806
|
*/
|
|
2350
2807
|
@Override
|
|
2351
2808
|
public void updatePixels(int x, int y, int c, int d) {
|
|
@@ -2363,6 +2820,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2363
2820
|
modified = true;
|
|
2364
2821
|
}
|
|
2365
2822
|
|
|
2823
|
+
|
|
2366
2824
|
// @Override
|
|
2367
2825
|
// protected void updatePixelsImpl(int x, int y, int w, int h) {
|
|
2368
2826
|
// super.updatePixelsImpl(x, y, w, h);
|
|
@@ -2373,15 +2831,20 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2373
2831
|
// }
|
|
2374
2832
|
// getRaster().setDataElements(0, 0, width, height, pixels);
|
|
2375
2833
|
// }
|
|
2834
|
+
|
|
2835
|
+
|
|
2836
|
+
|
|
2376
2837
|
//////////////////////////////////////////////////////////////
|
|
2838
|
+
|
|
2377
2839
|
// GET/SET
|
|
2378
|
-
|
|
2840
|
+
|
|
2841
|
+
|
|
2842
|
+
static int[] getset = new int[1];
|
|
2843
|
+
|
|
2379
2844
|
|
|
2380
2845
|
@Override
|
|
2381
2846
|
public int get(int x, int y) {
|
|
2382
|
-
if ((x < 0) || (y < 0) || (x >= width) || (y >= height))
|
|
2383
|
-
return 0;
|
|
2384
|
-
}
|
|
2847
|
+
if ((x < 0) || (y < 0) || (x >= width) || (y >= height)) return 0;
|
|
2385
2848
|
//return ((BufferedImage) image).getRGB(x, y);
|
|
2386
2849
|
// WritableRaster raster = ((BufferedImage) (useOffscreen && primarySurface ? offscreen : image)).getRaster();
|
|
2387
2850
|
WritableRaster raster = getRaster();
|
|
@@ -2393,11 +2856,14 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2393
2856
|
return getset[0];
|
|
2394
2857
|
}
|
|
2395
2858
|
|
|
2859
|
+
|
|
2396
2860
|
//public PImage get(int x, int y, int w, int h)
|
|
2861
|
+
|
|
2862
|
+
|
|
2397
2863
|
@Override
|
|
2398
2864
|
protected void getImpl(int sourceX, int sourceY,
|
|
2399
|
-
|
|
2400
|
-
|
|
2865
|
+
int sourceWidth, int sourceHeight,
|
|
2866
|
+
PImage target, int targetX, int targetY) {
|
|
2401
2867
|
// last parameter to getRGB() is the scan size of the *target* buffer
|
|
2402
2868
|
//((BufferedImage) image).getRGB(x, y, w, h, output.pixels, 0, w);
|
|
2403
2869
|
// WritableRaster raster =
|
|
@@ -2418,7 +2884,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2418
2884
|
|
|
2419
2885
|
// Copy the temporary output pixels over to the outgoing image
|
|
2420
2886
|
int sourceOffset = 0;
|
|
2421
|
-
int targetOffset = targetY
|
|
2887
|
+
int targetOffset = targetY*target.pixelWidth + targetX;
|
|
2422
2888
|
for (int y = 0; y < sourceHeight; y++) {
|
|
2423
2889
|
if (raster.getNumBands() == 3) {
|
|
2424
2890
|
for (int i = 0; i < sourceWidth; i++) {
|
|
@@ -2435,11 +2901,10 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2435
2901
|
}
|
|
2436
2902
|
}
|
|
2437
2903
|
|
|
2904
|
+
|
|
2438
2905
|
@Override
|
|
2439
2906
|
public void set(int x, int y, int argb) {
|
|
2440
|
-
if ((x < 0) || (y < 0) || (x >= pixelWidth) || (y >= pixelHeight))
|
|
2441
|
-
return;
|
|
2442
|
-
}
|
|
2907
|
+
if ((x < 0) || (y < 0) || (x >= pixelWidth) || (y >= pixelHeight)) return;
|
|
2443
2908
|
// ((BufferedImage) image).setRGB(x, y, argb);
|
|
2444
2909
|
getset[0] = argb;
|
|
2445
2910
|
// WritableRaster raster = ((BufferedImage) (useOffscreen && primarySurface ? offscreen : image)).getRaster();
|
|
@@ -2447,24 +2912,27 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2447
2912
|
getRaster().setDataElements(x, y, getset);
|
|
2448
2913
|
}
|
|
2449
2914
|
|
|
2915
|
+
|
|
2450
2916
|
//public void set(int x, int y, PImage img)
|
|
2917
|
+
|
|
2918
|
+
|
|
2451
2919
|
@Override
|
|
2452
2920
|
protected void setImpl(PImage sourceImage,
|
|
2453
|
-
|
|
2454
|
-
|
|
2455
|
-
|
|
2921
|
+
int sourceX, int sourceY,
|
|
2922
|
+
int sourceWidth, int sourceHeight,
|
|
2923
|
+
int targetX, int targetY) {
|
|
2456
2924
|
WritableRaster raster = getRaster();
|
|
2457
2925
|
// ((BufferedImage) (useOffscreen && primarySurface ? offscreen : image)).getRaster();
|
|
2458
2926
|
|
|
2459
|
-
if ((sourceX == 0) && (sourceY == 0)
|
|
2460
|
-
|
|
2461
|
-
|
|
2927
|
+
if ((sourceX == 0) && (sourceY == 0) &&
|
|
2928
|
+
(sourceWidth == sourceImage.pixelWidth) &&
|
|
2929
|
+
(sourceHeight == sourceImage.pixelHeight)) {
|
|
2462
2930
|
// System.out.format("%d %d %dx%d %d%n", targetX, targetY,
|
|
2463
2931
|
// sourceImage.width, sourceImage.height,
|
|
2464
2932
|
// sourceImage.pixels.length);
|
|
2465
2933
|
raster.setDataElements(targetX, targetY,
|
|
2466
|
-
|
|
2467
|
-
|
|
2934
|
+
sourceImage.pixelWidth, sourceImage.pixelHeight,
|
|
2935
|
+
sourceImage.pixels);
|
|
2468
2936
|
} else {
|
|
2469
2937
|
// TODO optimize, incredibly inefficient to reallocate this much memory
|
|
2470
2938
|
PImage temp = sourceImage.get(sourceX, sourceY, sourceWidth, sourceHeight);
|
|
@@ -2472,10 +2940,16 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2472
2940
|
}
|
|
2473
2941
|
}
|
|
2474
2942
|
|
|
2943
|
+
|
|
2944
|
+
|
|
2475
2945
|
//////////////////////////////////////////////////////////////
|
|
2946
|
+
|
|
2476
2947
|
// MASK
|
|
2477
|
-
|
|
2478
|
-
|
|
2948
|
+
|
|
2949
|
+
|
|
2950
|
+
static final String MASK_WARNING =
|
|
2951
|
+
"mask() cannot be used on the main drawing surface";
|
|
2952
|
+
|
|
2479
2953
|
|
|
2480
2954
|
@Override
|
|
2481
2955
|
public void mask(int[] alpha) {
|
|
@@ -2487,6 +2961,7 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2487
2961
|
}
|
|
2488
2962
|
}
|
|
2489
2963
|
|
|
2964
|
+
|
|
2490
2965
|
@Override
|
|
2491
2966
|
public void mask(PImage alpha) {
|
|
2492
2967
|
if (primaryGraphics) {
|
|
@@ -2497,17 +2972,31 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2497
2972
|
}
|
|
2498
2973
|
}
|
|
2499
2974
|
|
|
2975
|
+
|
|
2976
|
+
|
|
2500
2977
|
//////////////////////////////////////////////////////////////
|
|
2978
|
+
|
|
2501
2979
|
// FILTER
|
|
2980
|
+
|
|
2502
2981
|
// Because the PImage versions call loadPixels() and
|
|
2503
2982
|
// updatePixels(), no need to override anything here.
|
|
2983
|
+
|
|
2984
|
+
|
|
2504
2985
|
//public void filter(int kind)
|
|
2986
|
+
|
|
2987
|
+
|
|
2505
2988
|
//public void filter(int kind, float param)
|
|
2989
|
+
|
|
2990
|
+
|
|
2991
|
+
|
|
2506
2992
|
//////////////////////////////////////////////////////////////
|
|
2993
|
+
|
|
2507
2994
|
// COPY
|
|
2995
|
+
|
|
2996
|
+
|
|
2508
2997
|
@Override
|
|
2509
2998
|
public void copy(int sx, int sy, int sw, int sh,
|
|
2510
|
-
|
|
2999
|
+
int dx, int dy, int dw, int dh) {
|
|
2511
3000
|
if ((sw != dw) || (sh != dh)) {
|
|
2512
3001
|
g2.drawImage(image, dx, dy, dx + dw, dy + dh, sx, sy, sx + sw, sy + sh, null);
|
|
2513
3002
|
|
|
@@ -2518,25 +3007,41 @@ public class PGraphicsJava2D extends PGraphics {
|
|
|
2518
3007
|
}
|
|
2519
3008
|
}
|
|
2520
3009
|
|
|
3010
|
+
|
|
2521
3011
|
@Override
|
|
2522
3012
|
public void copy(PImage src,
|
|
2523
|
-
|
|
2524
|
-
|
|
3013
|
+
int sx, int sy, int sw, int sh,
|
|
3014
|
+
int dx, int dy, int dw, int dh) {
|
|
2525
3015
|
g2.drawImage((Image) src.getNative(),
|
|
2526
|
-
|
|
2527
|
-
|
|
3016
|
+
dx, dy, dx + dw, dy + dh,
|
|
3017
|
+
sx, sy, sx + sw, sy + sh, null);
|
|
2528
3018
|
}
|
|
2529
3019
|
|
|
3020
|
+
|
|
3021
|
+
|
|
2530
3022
|
//////////////////////////////////////////////////////////////
|
|
3023
|
+
|
|
2531
3024
|
// BLEND
|
|
3025
|
+
|
|
3026
|
+
|
|
2532
3027
|
// static public int blendColor(int c1, int c2, int mode)
|
|
3028
|
+
|
|
3029
|
+
|
|
2533
3030
|
// public void blend(int sx, int sy, int sw, int sh,
|
|
2534
3031
|
// int dx, int dy, int dw, int dh, int mode)
|
|
3032
|
+
|
|
3033
|
+
|
|
2535
3034
|
// public void blend(PImage src,
|
|
2536
3035
|
// int sx, int sy, int sw, int sh,
|
|
2537
3036
|
// int dx, int dy, int dw, int dh, int mode)
|
|
3037
|
+
|
|
3038
|
+
|
|
3039
|
+
|
|
2538
3040
|
//////////////////////////////////////////////////////////////
|
|
3041
|
+
|
|
2539
3042
|
// SAVE
|
|
3043
|
+
|
|
3044
|
+
|
|
2540
3045
|
// public void save(String filename) {
|
|
2541
3046
|
// loadPixels();
|
|
2542
3047
|
// super.save(filename);
|