strokeCap(ROUND) failure

edited October 2016 in Programming Questions

This P3D sketch (code below) asks for stroke cap ROUND as per

http://web.archive.org/web/20161026101020/https://processing.org/reference/strokeCap_.html

but gets strokecap SQUARE:

Processing 3.2.1 on Windows 7

Any idea why?

PS Apologies for this forum's messup of the code formatting. EDIT: Now fixed, thanks to koogs.

void setup() {
  size(480, 480, P3D);
  hint(ENABLE_DEPTH_SORT);
  colorMode(HSB, 6.0, 1.0, 1.0, 1.0);
  stroke(color(0, 0.4, 1.0), 0.3);
  strokeCap(ROUND);
  strokeWeight(width/90*4);
}

void draw()
{
  background(0); 
  translate(width/2, height/2);  
  rotateY(millis()/2700.0);rotateZ(millis()/7657.0);
  beginShape();
  vertex(-100, -100, -100);
  vertex( 100, -100, -100);
  vertex(   0,    0,  100);

  vertex( 100, -100, -100);
  vertex( 100,  100, -100);
  vertex(   0,    0,  100);

  vertex( 100, 100, -100);
  vertex(-100, 100, -100);
  vertex(   0,   0,  100);

  vertex(-100,  100, -100);
  vertex(-100, -100, -100);
  vertex(   0,    0,  100);
  endShape();
}
Tagged:

Answers

  • edit post, highlight code, press ctrl-o to format it for the forum.

    the example is 2d, your code is 3d. all bets are off.

  • edited October 2016

    edit post, highlight code, press ctrl-o to format it for the forum.

    Thanks for the workaround. Now applied.

    the example is 2d, your code is 3d. all bets are off.

    What makes you think round caps are not supposed to work on 3D lines?

  • what makes you think they should? 8)

    the 3d lines are done via a shader, iirc, the lines are actually polygons, to allow them to have a width. implementing round corners with this would be difficult.

    what would rounded corners mean in 3d, given that 'rounded' is a 2d concept? (think lolly stick) would the rounded bit point towards the camera or would it be edge on, and thus invisible. or something in between? or would they have spherical ends?

  • what makes you think they should? 8)

    The docs: "strokeCap() Sets the style for rendering line endings."

    Nothing about this not working in P3D. Yet it doesn't work in P3D.

    Compare and contrast "strokeWeight() Sets the width of the stroke used for line"

    Nothing about this not working in P3D. And it does work in P3D.

    the lines are actually polygons, to allow them to have a width. implementing round corners with this would be difficult.

    Can't see why. Polygons can do curves just fine.

    what would rounded corners mean in 3d, given that 'rounded' is a 2d concept?

    Rounded is not only a 2D concept. If it were, a sphere would not be rounded.

  • i'm not explaining that well. there was a long, involved discussion about how to implement line in 3d somewhere but i can't find it.

    anyway, i'm pretty sure it's not implemented. you can see in the processing source that there's a thing called LineStroker that handles the rounded caps (line 641) BUT it's excluded in the suggestions.txt file, which makes me think it's not yet currently included (LineStroker is called by nothing else but LinePath, which is only called by LineStroker, no other code)

    https://github.com/processing/processing/search?utf8=✓&q=LineStroker&type=Code

    raise a bug on github.

  • edited October 2016

    raise a bug on github.

    Thanks for the suggestion.

  • (LineStroker and LinePath classes aren't in the documentation and haven't been updated since 2013)

  • chrisjj: Rounded is not only a 2D concept. If it were, a sphere would not be rounded.

    Is 3D rounding the issue here, or just implementing 2D rounding in the 3D renderer?

    3D implies that a P3D line (vertex-vertex) with strokeWeight would be a pole (circular cross section) or a beam (square cross section) -- and thus would be expected to have a strokeCap that is a half-sphere (for a pole) or pyramidal (for a beam).

    But is that how strokes work in P3D? Or is a line with strokeWeight in P3D just a flat projection - a ribbon? In that case, I think implementing 2D expectations about strokeCaps make more sense -- although they still may not be very satisfying. For example, does strokeCap(PROJECT) work in P3D?

Sign In or Register to comment.