mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 21:59:20 +01:00
implement arc drawing modes (issue #711)
This commit is contained in:
@@ -225,14 +225,6 @@ public interface PConstants {
|
||||
public final static int DODGE = 1 << 12;
|
||||
public final static int BURN = 1 << 13;
|
||||
|
||||
// colour component bitmasks
|
||||
|
||||
public static final int ALPHA_MASK = 0xff000000;
|
||||
public static final int RED_MASK = 0x00ff0000;
|
||||
public static final int GREEN_MASK = 0x0000ff00;
|
||||
public static final int BLUE_MASK = 0x000000ff;
|
||||
|
||||
|
||||
// for messages
|
||||
|
||||
static final int CHATTER = 0;
|
||||
@@ -317,6 +309,13 @@ public interface PConstants {
|
||||
static final int DIAMETER = 3;
|
||||
|
||||
|
||||
// arc drawing modes
|
||||
|
||||
//static final int OPEN = 1; // shared
|
||||
static final int CHORD = 2;
|
||||
static final int PIE = 3;
|
||||
|
||||
|
||||
// vertically alignment modes for text
|
||||
|
||||
/** Default vertical alignment for text placement */
|
||||
|
||||
@@ -2569,6 +2569,12 @@ public class PGraphics extends PImage implements PConstants {
|
||||
*/
|
||||
public void arc(float a, float b, float c, float d,
|
||||
float start, float stop) {
|
||||
arc(a, b, c, d, start, stop, 0);
|
||||
}
|
||||
|
||||
|
||||
public void arc(float a, float b, float c, float d,
|
||||
float start, float stop, int mode) {
|
||||
float x = a;
|
||||
float y = b;
|
||||
float w = c;
|
||||
@@ -2589,26 +2595,31 @@ public class PGraphics extends PImage implements PConstants {
|
||||
y = b - d/2f;
|
||||
}
|
||||
|
||||
// make sure this loop will exit before starting while
|
||||
if (Float.isInfinite(start) || Float.isInfinite(stop)) return;
|
||||
// while (stop < start) stop += TWO_PI;
|
||||
if (stop < start) return; // why bother
|
||||
// make sure the loop will exit before starting while
|
||||
if (!Float.isInfinite(start) && !Float.isInfinite(stop)) {
|
||||
// ignore equal and degenerate cases
|
||||
if (stop > start) {
|
||||
// make sure that we're starting at a useful point
|
||||
while (start < 0) {
|
||||
start += TWO_PI;
|
||||
stop += TWO_PI;
|
||||
}
|
||||
|
||||
// make sure that we're starting at a useful point
|
||||
while (start < 0) {
|
||||
start += TWO_PI;
|
||||
stop += TWO_PI;
|
||||
if (stop - start > TWO_PI) {
|
||||
start = 0;
|
||||
stop = TWO_PI;
|
||||
}
|
||||
arcImpl(x, y, w, h, start, stop, mode);
|
||||
}
|
||||
}
|
||||
|
||||
if (stop - start > TWO_PI) {
|
||||
start = 0;
|
||||
stop = TWO_PI;
|
||||
}
|
||||
|
||||
arcImpl(x, y, w, h, start, stop);
|
||||
}
|
||||
|
||||
|
||||
// protected void arcImpl(float x, float y, float w, float h,
|
||||
// float start, float stop) {
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* Start and stop are in radians, converted by the parent function.
|
||||
* Note that the radians can be greater (or less) than TWO_PI.
|
||||
@@ -2616,11 +2627,11 @@ public class PGraphics extends PImage implements PConstants {
|
||||
* and the user will still collect $200.
|
||||
*/
|
||||
protected void arcImpl(float x, float y, float w, float h,
|
||||
float start, float stop) {
|
||||
float start, float stop, int mode) {
|
||||
showMissingWarning("arc");
|
||||
}
|
||||
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
// BOX
|
||||
|
||||
@@ -782,7 +782,7 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ {
|
||||
|
||||
@Override
|
||||
protected void arcImpl(float x, float y, float w, float h,
|
||||
float start, float stop) {
|
||||
float start, float stop, int mode) {
|
||||
// 0 to 90 in java would be 0 to -90 for p5 renderer
|
||||
// but that won't work, so -90 to 0?
|
||||
|
||||
@@ -801,15 +801,32 @@ public class PGraphicsJava2D extends PGraphics /*PGraphics2D*/ {
|
||||
// }
|
||||
float sweep = stop - start;
|
||||
|
||||
// stroke as Arc2D.OPEN, fill as Arc2D.PIE
|
||||
// The defaults, before 2.0b7, were to stroke as Arc2D.OPEN, and then fill
|
||||
// using Arc2D.PIE. That's a little wonky, but it's here for compatability.
|
||||
int fillMode = Arc2D.PIE;
|
||||
int strokeMode = Arc2D.OPEN;
|
||||
|
||||
if (mode == OPEN) {
|
||||
fillMode = Arc2D.OPEN;
|
||||
//strokeMode = Arc2D.OPEN;
|
||||
|
||||
} else if (mode == PIE) {
|
||||
//fillMode = Arc2D.PIE;
|
||||
strokeMode = Arc2D.PIE;
|
||||
|
||||
} else if (mode == CHORD) {
|
||||
fillMode = Arc2D.CHORD;
|
||||
strokeMode = Arc2D.CHORD;
|
||||
}
|
||||
|
||||
if (fill) {
|
||||
//System.out.println("filla");
|
||||
arc.setArc(x, y, w, h, start, sweep, Arc2D.PIE);
|
||||
arc.setArc(x, y, w, h, start, sweep, fillMode);
|
||||
fillShape(arc);
|
||||
}
|
||||
if (stroke) {
|
||||
//System.out.println("strokey");
|
||||
arc.setArc(x, y, w, h, start, sweep, Arc2D.OPEN);
|
||||
arc.setArc(x, y, w, h, start, sweep, strokeMode);
|
||||
strokeShape(arc);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +160,12 @@ public class PImage implements PConstants, Cloneable {
|
||||
private int[] blurKernel;
|
||||
private int[][] blurMult;
|
||||
|
||||
// colour component bitmasks (moved from PConstants in 2.0b7)
|
||||
public static final int ALPHA_MASK = 0xff000000;
|
||||
public static final int RED_MASK = 0x00ff0000;
|
||||
public static final int GREEN_MASK = 0x0000ff00;
|
||||
public static final int BLUE_MASK = 0x000000ff;
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
@@ -11,6 +11,19 @@ X remove blend(), add blendMode()
|
||||
X http://code.google.com/p/processing/issues/detail?id=1385
|
||||
o implement a more efficient version of blend()
|
||||
o http://code.google.com/p/processing/issues/detail?id=120
|
||||
o Problem with beginShape()/endShape() when using multiple contours
|
||||
X http://code.google.com/p/processing/issues/detail?id=1396
|
||||
X just a documentation issue
|
||||
A PShape and lights results in more lit vertices
|
||||
A http://code.google.com/p/processing/issues/detail?id=1342
|
||||
A Implement anisotropic filtering when using OPENGL
|
||||
A http://code.google.com/p/processing/issues/detail?id=502
|
||||
X move _MASK constants out of PConstants and into PImage
|
||||
|
||||
_ how should stroke work w/ arcs?
|
||||
X decision: we should do pie, you can make the other kind w/o it
|
||||
_ add an additional parameter for the others
|
||||
_ http://code.google.com/p/processing/issues/detail?id=711
|
||||
|
||||
|
||||
cleanup/earlier by Andres
|
||||
@@ -39,11 +52,14 @@ A set() requires updatePixels() with OpenGL
|
||||
A http://code.google.com/p/processing/issues/detail?id=89
|
||||
A chopping out triangles in OpenGL (though it's only 2D drawing)
|
||||
A http://code.google.com/p/processing/issues/detail?id=193
|
||||
A shared interface for 3D view data across desktop/Android
|
||||
A http://code.google.com/p/processing/issues/detail?id=970
|
||||
A Distortion of 2D shapes when sphereDetail() is used
|
||||
A http://code.google.com/p/processing/issues/detail?id=762
|
||||
A OPENGL renderer stops rendering after text is written using textMode(SCREEN)
|
||||
A http://code.google.com/p/processing/issues/detail?id=710
|
||||
|
||||
|
||||
_ Problem with beginShape()/endShape() when using multiple contours
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1396
|
||||
|
||||
_ createShape() not yet implemented for 2.0
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1400
|
||||
|
||||
@@ -350,12 +366,6 @@ _ toColorArray(), toColorArray(float[])...
|
||||
_ load/save methods.. is it save("blah.svg") or saveSVG("blah.svg")
|
||||
X also works that way with tables
|
||||
X decision: useExtension() or something like that
|
||||
_ how should stroke work w/ arcs?
|
||||
_ has an effect elliptical arc
|
||||
_ http://code.google.com/p/processing/issues/detail?id=130
|
||||
X decision: we should do pie, you can make the other kind w/o it
|
||||
_ add an additional parameter for the others
|
||||
_ http://code.google.com/p/processing/issues/detail?id=711
|
||||
_ require people to put things in the data folder
|
||||
_ make sure that loadXxxx() methods are used after init()
|
||||
_ nasty errors when loadImage/Font/createFont/etc used outside
|
||||
@@ -584,6 +594,8 @@ _ for PShape, need to be able to set the origin (flash people)
|
||||
|
||||
CORE / PShapeSVG
|
||||
|
||||
_ implement A and a (elliptical arcs)
|
||||
_ http://code.google.com/p/processing/issues/detail?id=130
|
||||
_ implement support for SVG gradients from Inkscape
|
||||
_ http://code.google.com/p/processing/issues/detail?id=1142
|
||||
_ need to handle <!ENTITY tags in XML for SVG documents
|
||||
@@ -600,8 +612,6 @@ _ add better support for attributes buried in styles (support ai9/10/11)
|
||||
_ test what happens when transparency is used with gradient fill
|
||||
_ look into transformation issues... guessing this is probably wrong
|
||||
_ this may be what's throwing off the radial radius transform
|
||||
_ implement A and a (elliptical arcs)
|
||||
_ http://code.google.com/p/processing/issues/detail?id=130
|
||||
_ check for any other pieces of missing path api
|
||||
_ multiple sets of coordinates after a command not supported
|
||||
_ i.e. M with several coords means moveto followed by many linetos
|
||||
@@ -655,8 +665,6 @@ _ will need to split each based on the other
|
||||
_ sort issues will affect both
|
||||
_ Stroking a rect() leaves off the upper right pixel
|
||||
_ http://code.google.com/p/processing/issues/detail?id=67
|
||||
_ Implement anisotropic filtering when using OPENGL
|
||||
_ http://code.google.com/p/processing/issues/detail?id=502
|
||||
_ Signature issue on contributed libraries affects unrelated opengl sketches
|
||||
_ http://code.google.com/p/processing/issues/detail?id=261
|
||||
_ remove matrixMode(), add a projection() method
|
||||
|
||||
Reference in New Issue
Block a user