How can I sketch a right-angled triangle?
tri = AASTriangle[Pi/2, Pi/4, 1];
srd = SignedRegionDistance[tri];
We can use SignedRegionDistance
with ContourPlot
or with RegionPlot
(this would be very slow):
ContourPlot[srd[{x, y}], {x, -.2, 1}, {y, -.2, 1},
Contours -> {.1, .02},
ContourShading -> {None, Yellow},
ImagePadding -> 10, Frame -> False, ImageSize -> Large]
RegionPlot[.02 <= srd[{x, y}] <= .1, {x, -.2, 1}, {y, -.2, 1},
PlotStyle -> Yellow, PlotPoints -> 80, ImagePadding -> 10,
Frame -> False, ImageSize -> Large]
We can also use the function explode
from this answer to rescale the contour lines while preserving rounded corners:
ClearAll[explode, bsf]
explode[f_] := f[#] + #2 Cross @ Normalize[f'[#]] &;
cp0 = ContourPlot[srd[{x, y}], {x, -.1, .8}, {y, -.1, .8},
Contours -> {.05}, ContourShading -> None];
mc = MeshCoordinates@DiscretizeGraphics[cp0];
bsf = BSplineFunction[mc, SplineClosed -> True];
Graphics[{Thick, BSplineCurve[mc, SplineClosed -> True],
Blue, Line[explode[bsf][#, .1] & /@ Subdivide[200]]}]
Graphics[{Black, Thick, BSplineCurve[mc, SplineClosed -> True],
Line[explode[bsf][#, .1] & /@ Subdivide[200]],
Red, FilledCurve[{BSplineCurve[mc, SplineClosed -> True],
Line[explode[bsf][#, .1] & /@ Subdivide[200]]}]}]
Updated
pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts = Mean[{#, in}] & /@ pts;
Graphics[{Orange, EdgeForm[{JoinForm["Round"], Thickness[0.035]}],
FilledCurve[{{Line[pts]}, {Line[smallpts]}}]}]
Original
pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts = Mean[{#, in}] & /@ pts;
Graphics[{Red, Point[in], Green, Polygon[pts -> {smallpts}]}]
Or
pts = {{0, 0}, {2, 0}, {0, 4}};
in = {.7, 1};
smallpts =
Mean[{#, in}] & /@ pts;
Graphics[{Orange,
FilledCurve[{{Line[pts]}, {Line[smallpts]}}]}]
For a hand-drawn sketch look:
Graphics[{AbsoluteThickness[30], ColorData[97]@1, CapForm["Round"],
JoinForm["Round"], Line[{{0, 0}, {1/Sqrt[2], 0}, {0, 1/Sqrt[2]}, {0, 0}}]},
ImagePadding -> 30] // ImageEffect[#, {"Jitter", 5}] &