Weave
Image based weave pattern
Last updated
Image based weave pattern
Last updated
//Sample Surface
sr = Surface.ByLoft([NurbsCurve.ByPoints(Point.ByCoordinates
(-50,[0,12,1,3],[0,25,50,75])),NurbsCurve.ByPoints
(Point.ByCoordinates(50,[0,-8,1,4],[0,30,62,75]))]);
//Image repetition
n = 7;
//Replicating brightness data
b1 = Math.Floor(Color.Brightness(Image.Pixels(img,8,8)));
b2 = List.Flatten(List.OfRepeatedItem(List.Flatten
(List.OfRepeatedItem(b1<1>,n)<1>,-1),n),1);
// Parameters on surface
c = 0..1..# (8*n);
//Shifting points by brightness normal to surface
p1 = Surface.PointAtParameter(sr,c<1>,c<2>);
v1 = Surface.NormalAtPoint(sr,p1);
v2 = v1.Scale(b2==0?-1:b2);
v3 = List.Transpose(v1).Scale(b2==0?1:-1);
p2 = p1.Add(v2);
p3 = List.Transpose(p1).Add(v3);
//Loft based on curve connecting points
n1 = List.Flatten(NurbsCurve.ByPoints([p2,p3]),-1);
n2 = Circle.ByPlaneRadius(n1<1>.PlaneAtParameter(0..1..#60)<2>,0.25);
n3 = Solid.ByLoft(n2,n1);