Suppose I have smile.pdf; it's a vector graph.
I can Import["smile.pdf"]
like below:
How to put this vector graph into coordinates system? Then I can easy rotate and move it.
Suppose I have smile.pdf; it's a vector graph.
I can Import["smile.pdf"]
like below:
How to put this vector graph into coordinates system? Then I can easy rotate and move it.
Import the *.pdf file:
smiley = First[Import["xx.pdf"]];
Inspecting the result, we find the following:
Shallow[InputForm[smiley], 7]
InputForm[Graphics[{Thickness[0.001634], Style[{FilledCurve[<<2>>]},
FaceForm[RGBColor[<<4>>]]]}, ImageSize -> {612., 792.},
PlotRange -> {{0., 612.}, {0., 792.}}, AspectRatio -> Automatic]]
Particularly important here is the PlotRange
setting, which lets us reckon where the FilledCurve[]
representing the shape is centered. One can then do something like this:
Graphics[{Blue, First[Cases[smiley, _FilledCurve, ∞]] /. {x_, y_} :>
Composition[RotationTransform[60 °],
ScalingTransform[{1, 1}/50]][{x, y} - {306, 396}]},
Background -> Yellow, Frame -> True, FrameStyle -> Gray]
InputForm[Graphics[{Thickness[0.001634], Style[{FilledCurve[<<2>>]}
,I cannot understand why
$\endgroup$
Commented
Mar 7, 2018 at 11:53
For your example file, after importing the file, just grab the first element which you need and reconstruct graphics with the geometric transformation you want.
If you check InputForm[test4]
like J.M. suggested, you can see why you only need to take the first element.
test4 = First[Import["test4.pdf"]];
Shallow[InputForm[test4], 7]
InputForm[ Graphics[{ Thickness[0.0016339869281045752`], Style[{ FilledCurve[ Skeleton[2]]}, FaceForm[ RGBColor[ Skeleton[4]]]], Style[{ JoinedCurve[ Skeleton[3]]}, JoinForm[{ Skeleton[2]}]], Style[{ FilledCurve[ Skeleton[2]]}, Thickness[0.0016339869281045752`]]}, ImageSize -> {612., 792.}, PlotRange -> {{0., 612.}, {0., 792.}}, AspectRatio -> Automatic]]
Graphics[Translate[Rotate[test4[[1]], 30 Degree], {-290, -411}],
Frame -> True]
smile.pdf
somewhere? $\endgroup$