Drawing zig zags makes GUI slow?

For me this makes the GUI unusably slow to resize:

(
v = UserView(nil, Rect(0, 0, 1000, 500)).front.drawFunc = { |view|
  var height = view.bounds.height;
  var width = view.bounds.width;
  var n = 200;
  var nratio = width / n;
  Pen.use {
    n.do { |i|
      var y = if (i.even) { 0 } { height };
      Pen.lineTo((i * nratio)@y);
    };
    Pen.stroke;
  };
};
)

also this:

(200.collect{ |i| if (i.even) { 0 } { 1 } }).plot

Using an EnvelopeView is fast but also not accurate, it draws a sawtooth instead of triangle wave:

EnvelopeView().setEnv(Env(200.collect{ |i| if (i.even) { 0 } { 1 } }, 1.dup(199))).thumbSize_(0).front

Is there any better way?

Yes, I can confirm the same behavior on my system - extremely slow. Not that I can offer any solutions…

Yes, they are slow here too. The Pen version is by far the slowest.

Wierdly, the EnvelopeView version seems to work fine if you reduce the number of points to 100. This shows triangles:

EnvelopeView().setEnv(Env(100.collect{ |i| if (i.even) { 0 } { 1 } }, 1.dup(99))).thumbSize_(0).front

However, 150 points looks very wonky - a mix of up/down ramps and triangles:

EnvelopeView().setEnv(Env(150.collect{ |i| if (i.even) { 0 } { 1 } }, 1.dup(149))).thumbSize_(0).front

Interestingly, the performance on my machine (Mac M1) is worse on SC 3.12.2 vs. 3.13/14-dev.
3.12.2: beach ball for 10 seconds
3.13/14-dev: a couple of annoying seconds of pause.