Post by chriscrawford on Aug 17, 2015 19:46:22 GMT -8
I now have the routine that draws the face onto the display. However, there is a fascinating bug. Here is some of the code that draws the face:
You will note that only the eyes are drawn. The first two features drawn by the above loop are the eye outline and iris; the remainder of the facial features are not being drawn. Why not? I don't know, but I do know this: if I change the code as follows:
Thus, drawing the first two features prevents successful drawing of the remaining features. If I draw the remaining features, THEN draw the eye outline and iris, it works just fine. Does this make sense to you? It doesn't make sense to me. This is why I hate Java. But it gets worse. By patient trial and error, tracking down exactly what causes the problem, I have reduced it to this line of code:
This single line is the source of all the problems. It creates the polygon that holds the shape of the left eye. Note that the right eye doesn't cause any problems whatever; it's always the left eye. Well, upon further checking, I learned that it's not the left eye, it's the SECOND eye that is drawn. Drawing the first eye causes no problems, but creating the polygon for the second eye blows everything to hell.
I have explored a number of variations in an attempt to figure out the underlying problem, but I do have a working fix: just draw the eye outline and iris last, and all is well. With Java, that is usually the best that can be hoped for.
for (int i=0; (i<FeatureCount); ++i) {
features[i].drawSmall(i);
}
And here is the result:You will note that only the eyes are drawn. The first two features drawn by the above loop are the eye outline and iris; the remainder of the facial features are not being drawn. Why not? I don't know, but I do know this: if I change the code as follows:
for (int i=2; (i<FeatureCount); ++i) {
features[i].drawSmall(i);
}
features[0].drawSmall(0);
features[1].drawSmall(1);
I get the following output:Thus, drawing the first two features prevents successful drawing of the remaining features. If I draw the remaining features, THEN draw the eye outline and iris, it works just fine. Does this make sense to you? It doesn't make sense to me. This is why I hate Java. But it gets worse. By patient trial and error, tracking down exactly what causes the problem, I have reduced it to this line of code:
leftEyeOutline = new Polygon();
This single line is the source of all the problems. It creates the polygon that holds the shape of the left eye. Note that the right eye doesn't cause any problems whatever; it's always the left eye. Well, upon further checking, I learned that it's not the left eye, it's the SECOND eye that is drawn. Drawing the first eye causes no problems, but creating the polygon for the second eye blows everything to hell.
I have explored a number of variations in an attempt to figure out the underlying problem, but I do have a working fix: just draw the eye outline and iris last, and all is well. With Java, that is usually the best that can be hoped for.