williamngan / pts

A library for visualization and creative-coding
https://ptsjs.org
Apache License 2.0
5.16k stars 182 forks source link

segment function doesn't return an array of group #177

Open albizures opened 2 years ago

albizures commented 2 years ago

According to the docs segments returns an array of groups, but it doesn't:

const run = Pts.quickStart( "pt", "#003" ); 
run((time, ftime) => { 
  const rect = Rectangle.corners(Rectangle.fromCenter(space.center, 60, 60));
  rect
    .clone()
    .segments(2, 1, true)
    .map((side, index) => {
      side.scale(1.5); // here side is an array of Pt
      form.strokeOnly("#f00", 18).line(side);
    })
});
williamngan commented 2 years ago

Thank you @albizures -- this is a bug. Will fix it in the next patch.

As a quick fix for now, you can try Group.fromPtArray(side).scale(1.5).