mirror of
https://github.com/processing/processing4.git
synced 2026-02-04 06:09:17 +01:00
235 lines
3.6 KiB
Plaintext
235 lines
3.6 KiB
Plaintext
...............................................................
|
|
|
|
*** SMOOTHING STRANGE ON SOME EDGES
|
|
|
|
....
|
|
|
|
|
|
// here is the same issue, more concise.
|
|
// one quad is fine, the other has one jagged edge:
|
|
|
|
size(200, 200);
|
|
noStroke();
|
|
|
|
fill(102);
|
|
// bottom line is not smooth
|
|
quad(0, 0, 100, -20, 120, 100, 0, 120);
|
|
|
|
fill(0);
|
|
// quad draws fine
|
|
quad(105, 10, 120, 60, 120, 150, 80, 200);
|
|
|
|
|
|
...............................................................
|
|
|
|
*** EDGES DON'T HIT ONE ANOTHER CORRECTLY
|
|
|
|
....
|
|
|
|
// smoothing changes the way sphere is rendered:
|
|
|
|
size(200, 200);
|
|
lights();
|
|
noStroke();
|
|
//noSmooth();
|
|
translate(100, height/2, -50);
|
|
sphere(100);
|
|
|
|
.....
|
|
|
|
i'm not sure how to classify, but look at 'typography00'. i think is the
|
|
same issue as when drawing the cubes above. tangent polygons have
|
|
lines between them.
|
|
|
|
....
|
|
|
|
|
|
// edges in cube rendering have gap when smooth is on:
|
|
|
|
void setup()
|
|
{
|
|
size(200, 200);
|
|
lights();
|
|
noStroke();
|
|
}
|
|
|
|
float angle;
|
|
void loop()
|
|
{
|
|
angle+=0.01;
|
|
translate(100, 100, 0);
|
|
rotateX(HALF_PI/2);
|
|
rotateY(angle);
|
|
box(80);
|
|
}
|
|
|
|
|
|
....
|
|
|
|
|
|
ellipses are no longer begin stroked:
|
|
|
|
size(200, 200);
|
|
stroke(255);
|
|
fill(0);
|
|
ellipse(50, 50, 100, 100);
|
|
rect(60, 60, 80, 80);
|
|
|
|
|
|
....
|
|
|
|
|
|
// smoothing around ellipse is inconsistent.
|
|
// in this example, a foreign circulating line is introduced
|
|
|
|
void setup()
|
|
{
|
|
size(200, 200);
|
|
background(102, 0, 0);
|
|
}
|
|
|
|
float a;
|
|
|
|
void loop()
|
|
{
|
|
a += 0.01;
|
|
translate(100, 100);
|
|
rotate(a);
|
|
ellipse(-50, -50, 100, 200);
|
|
//ellipse(-50, -50, 100, 100);
|
|
}
|
|
|
|
|
|
/ / / / / / / / / / / /
|
|
|
|
|
|
also that pesky pmouseX, pmouseY seems to be behaving oddly again.
|
|
it's skipping beats. try this:
|
|
|
|
void setup() {
|
|
size(200, 200);
|
|
noBackground();
|
|
refresh();
|
|
}
|
|
|
|
void loop() {
|
|
stroke(255);
|
|
if(mousePressed && pmouseX != 0 && pmouseY != 0) {
|
|
line(mouseX, mouseY, pmouseX, pmouseY);
|
|
}
|
|
}
|
|
|
|
// the kludge with pmouseX != 0 etc. has to do with their default to 0.
|
|
// would it be possible to automatically have P5 set the pmouseX and
|
|
// pmouseY to mouseX and mouseY on the first frame?
|
|
// comment that line out to see what i'm talking about
|
|
|
|
|
|
....................................................
|
|
|
|
Gizmo[][] life = new Gizmo[30][30];
|
|
|
|
void setup()
|
|
{
|
|
size(300, 300);
|
|
background(255, 255, 255);
|
|
stroke(0, 0, 0);
|
|
|
|
for (int a = 0; a < 30; a++)
|
|
for (int b = 0; b < 30; b++)
|
|
{
|
|
life[a][b] = new Gizmo(a, b);
|
|
life[a][b].init();
|
|
}
|
|
}
|
|
|
|
void loop()
|
|
{
|
|
if (mouseX >= 0 && mouseX <= 300 && mouseY >= 0 && mouseY <= 300)
|
|
{
|
|
int ex = (mouseX - (mouseX % 10)) / 10;
|
|
int why = (mouseY - (mouseY % 10)) / 10;
|
|
}
|
|
else
|
|
{
|
|
ex = 0;
|
|
why = 0;
|
|
}
|
|
|
|
if (life[ex][why].alive == false && mousePressed)
|
|
life[ex][why].make();
|
|
else if (life[ex][why].alive == true && mousePressed)
|
|
life[ex][why].kill();
|
|
|
|
drawbg();
|
|
}
|
|
|
|
void drawbg()
|
|
{
|
|
for (int why = 0; why < 30; why++)
|
|
for (int ex = 0; ex < 30; ex++)
|
|
{
|
|
if (life[ex][why].alive == true)
|
|
{
|
|
fill(150, 20, 20);
|
|
rect(ex * 10, why * 10, 10, 10);
|
|
}
|
|
else
|
|
{
|
|
fill(0, 0, 0);
|
|
rect(ex * 10, why * 10, 10, 10);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
class Gizmo
|
|
{
|
|
int x;
|
|
int y;
|
|
boolean alive;
|
|
Point[] neighbours = new Point[8];
|
|
|
|
Gizmo (int ex, int why)
|
|
{
|
|
x = ex;
|
|
y = why;
|
|
}
|
|
|
|
void init();
|
|
{
|
|
for (int i = 0; i < 8; i++)
|
|
neighbours[i] = new Point(0,0);
|
|
}
|
|
|
|
void make()
|
|
{
|
|
alive == true;
|
|
}
|
|
|
|
void kill()
|
|
{
|
|
alive == false;
|
|
}
|
|
}
|
|
|
|
class Point
|
|
{
|
|
int x;
|
|
int y;
|
|
|
|
Point (int ex, int why)
|
|
{
|
|
x = ex;
|
|
y = why;
|
|
}
|
|
|
|
void set(int ex, int why)
|
|
{
|
|
x = ex;
|
|
y = why;
|
|
}
|
|
}
|
|
|
|
|