How can I draw a random thickness curve?

As we know that add weight factors to Tube, we can get variety thickness tube. I want to know how to do the same thing directly in 2D graph instead of only a 3D graph with top viewpoint, for example, make a Bezier Curve variety thickness.

SeedRandom[1];
pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {5, 2}, {6, -1}, {7, 3}};
tube = Graphics3D[{Red,
RandomReal[{0.1, .5}, Length@pts]]}, ViewPoint -> Top,
ViewProjection -> "Orthographic", Boxed -> False];
GraphicsRow[{tube, ImageMesh[ColorNegate[tube], Frame -> True]}]


Edit

I want a Random thickness and BezierCurve instead of normal function. For example, an arbitrary BezierCurve.

pts1 = {{5, -2}, {0, 0}, {1, 2}, {5, 1}, {2, 2}, {4, 3}, {5, 4}};
pts2 = {{0, 0}, {1, 1}, {1.2, 2}, {.6, 1.8}, {0, 1.3}, {-.6,
1.8}, {-1.2, 2}, {-1, 1}, {0, 0}};
{Graphics[BezierCurve[pts1]], Graphics[BezierCurve[pts2]]}


• For a review of potentially helpful techniques, see 28202.
– Syed
Commented Mar 2 at 4:03

Clear["Global*"];
pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {5, 2}, {6, -1}, {7, 3}};
n = 100;
plot0 = ListLinePlot[
MeshCoordinates[DiscretizeGraphics@BezierCurve@pts],
MeshFunctions -> {"ArcLength"}, Mesh -> {n}];
p = Cases[plot0[[1]], GraphicsComplex[{pts__}, __] :> pts, -1];
meshindexs = First@Cases[plot0[[1]], Point[i_] :> i, -1];
meshPoints = Join[{pts[[1]]}, p[[meshindexs]], {pts[[-1]]}];
right = #1 +
RandomReal[{0.1, .5}]*
Normalize[RotationTransform[-(π/2), #1][#2] - #1] &;
left = #1 +
RandomReal[{0.1, .5}]*
Normalize[RotationTransform[π/2, #1][#2] - #1] &;
pts1 := right @@@ Partition[meshPoints, 2, 1];
corner1[base_, end_] :=
Table[base +
RandomReal[{.1, .5}]*
Normalize[RotationTransform[t, base][end] - base], {t,
Subdivide[-(π/2), π/2, 4]}];
pts2 := left @@@ Partition[meshPoints, 2, 1];
g := Graphics[{Orange,
FilledCurve[{BSplineCurve[pts1[[{1, Sequence @@ Range[2, n, 5]}]],
SplineDegree -> 6],
BSplineCurve[corner1[meshPoints[[-2]], meshPoints[[-1]]],
SplineDegree -> 6],
BSplineCurve[Reverse@pts2[[{1, Sequence @@ Range[2, n, 5]}]],
SplineDegree -> 4], Line[{pts2[[1]], pts[[1]], pts1[[1]]}]}],
Blue, BezierCurve@pts}]

GraphicsGrid[{{g, g}, {g, g}}]


• another attempt
Clear["Global*"];
pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {5, 2}, {6, -1}, {7, 3}};
curve = BezierCurve@pts;
(* RegionQ[curve] *)
reg = DiscretizeGraphics@curve;
{{x1, x2}, {y1, y2}} = RegionBounds[reg];
dist = RegionDistance[reg];
nearest = RegionNearest[reg];
plot = ContourPlot[
dist@{x, y}, {x, x1 - 1, x2 + 1}, {y, y1 - 1, y2 + 1},
Contours -> {.3}, AspectRatio -> Automatic, ContourShading -> None];
data = Cases[Normal@plot, Line[pts_] :> pts, -1];
tran[pts_] := Module[{n, k, data},
n = Length@pts;
k = Floor[0.05 n];
data = pts[[1 ;; -1 ;; k]];
Graphics[{Orange,
FilledCurve@
BSplineCurve[
ReplacePart[data,
Table[i ->
data[[i]] +
RandomReal[{1, 2}]*(data[[i]] - nearest@data[[i]]), {i,
Range[Length@data][[1 ;; -1 ;; k]]}]], SplineDegree -> 4,
SplineClosed -> True]}]]
Show[tran /@ data, Graphics[{Blue, curve}]]


Use Black and Glow[Red] instead of just Red.

Also use Deploy@Graphics3D to disable rotation by mouse so that the output is just like output of Graphics. Or Method -> {"RotationControl" -> None} inside Graphicd3D can be used to disable rotation by mouse.

SeedRandom[1];
pts = {{0, 0}, {1, 1}, {2, -1}, {3, 0}, {5, 2}, {6, -1}, {7, 3}};
Graphics3D[{Black, Glow[Red],

  Plot[{Sin[x], Sin[x] + 0.02 x^2}, {x, 0, 2 Pi},