안녕하세요 tikz로 피규어를 만들어 보려고 합니다. 나는 패턴을 사용하여 몇 가지 다른 영역을 정의합니다. 구역 0은 회색 구역 1은 북동쪽 선 z2는 북서쪽 선
어떤 이유로 대각선 패턴이 점선으로 나옵니다. 그리고 왜 그런지 잘 모르겠습니다. 이 문제를 해결하는 방법을 아는 사람이 있나요?
아래는 내 코드와 스크린샷입니다.
\documentclass{standalone}
\usepackage{tikz}
\usetikzlibrary{patterns}
\usepackage{tkz-euclide}
\usetikzlibrary{calc}
\begin{document}
\begin{tikzpicture}
\tkzInit[xmax=5,ymax=5]
%\tkzAxeXY
%zone 2 (rectangle, negative)
\fill[pattern=north west lines] (0,5) rectangle (5.5,0);
%circle mask
\fill[white] (4,1.5) circle (1.35);
%zone 1
\node[minimum width=2.7cm,
circle,inner sep=0pt,fill opacity=1,
line width=2.5mm,pattern=north east lines,opacity=1] at (4,1.5){};
%zone 0 (positive)
\node[minimum width=2cm,
circle,inner sep=0pt,fill opacity=1,
line width=2.5mm,draw=gray,opacity=1] at (4,1.5){};
%wall (dashed line)
\node[minimum width=2cm,
circle,inner sep=0pt,fill opacity=0,
line width=.5mm,dashed,draw=black,opacity=1] at (4,1.5){};
\end{tikzpicture}
\end{document}
답변1
나는 이것이 렌더러 측 문제라고 생각합니다. 마지막 코드의 경우 왼쪽이 스크린샷이고 오른쪽이 내보낸 PNG입니다.
다음은 의 일부 코드/주석입니다 pgfcorepatterns.code.tex
.
% Creates a new colored pattern
%
% [#1] = optional list of variables.
% #2 = pattern name
% #3 = lower left of bounding box
% #4 = upper right of bounding box
% #5 = step vector
% #6 = pattern code
%
% Description:
%
% Declares a new colored pattern. Such patterns have a one or more
% fixed inherent colors. See the pdf-manual for more details on
% uncolored patterns.
%
% The parameters have the same effect as for uncolored patterns.
및 의 코드입니다 pgflibrarypatterns.code.tex
.
\pgfdeclarepatternformonly{north east lines}{\pgfqpoint{-1pt}{-1pt}}{\pgfqpoint{4pt}{4pt}}{\pgfqpoint{3pt}{3pt}}%
{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{3.1pt}{3.1pt}}
\pgfusepath{stroke}
}
그래서 이런 일이 일어난 것 같아요
그리고 내가 한 일은
\documentclass[tikz]{standalone}
\usepackage{tikz}\usetikzlibrary{patterns}
\pgfdeclarepatternformonly{south west lines}{\pgfqpoint{-0pt}{-0pt}}{\pgfqpoint{3pt}{3pt}}{\pgfqpoint{3pt}{3pt}}{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{0pt}}
\pgfpathlineto{\pgfqpoint{3pt}{3pt}}
\pgfpathmoveto{\pgfqpoint{2.8pt}{-.2pt}}
\pgfpathlineto{\pgfqpoint{3.2pt}{.2pt}}
\pgfpathmoveto{\pgfqpoint{-.2pt}{2.8pt}}
\pgfpathlineto{\pgfqpoint{.2pt}{3.2pt}}
\pgfusepath{stroke}}
\begin{document}
\begin{tikzpicture}
\fill[pattern=north east lines](0,1)rectangle(1,0);
\fill[pattern=south west lines](0,1)rectangle(-1,0);
\end{tikzpicture}
\begin{tikzpicture}[line width=.4cm]
\begin{scope}[opacity=.25]
\draw[thin](1,2)rectangle(2,1)(1.5,1)node[below]{de facto bounding box};
\draw[thin](0,3)rectangle(3,0)(1.5,0)node[below]{tessellating box};
\draw[thin](-1,4)rectangle(4,-1)(1.5,-1)node[below]{bounding box};
\draw[opacity=0](-1,4)rectangle(4,-1);
\draw(0,0)--(3.1,3.1);
\end{scope}
\clip(1,2)rectangle(2,1);
\draw(0,0)--(3,3);
\end{tikzpicture}
\begin{tikzpicture}[line width=.4cm]
\begin{scope}[opacity=.25]
\draw[thin](0,3)rectangle(3,0)(1.5,0)node[below]{bounding box = tessellating box};
\draw(0,0)--(3,3)(-.2,2.8)--(.2,3.2)(2.8,-.2)--(3.2,.2);
\end{scope}
\clip(0,3)rectangle(3,0);
\draw(0,0)--(3,3)(-.2,2.8)--(.2,3.2)(2.8,-.2)--(3.2,.2);
\end{tikzpicture}
\end{document}
남동쪽 버전
귀하의 편의를 위해 여기에 남동쪽 버전이 있습니다.
\pgfdeclarepatternformonly{south east lines}{\pgfqpoint{-0pt}{-0pt}}{\pgfqpoint{3pt}{3pt}}{\pgfqpoint{3pt}{3pt}}{
\pgfsetlinewidth{0.4pt}
\pgfpathmoveto{\pgfqpoint{0pt}{3pt}}
\pgfpathlineto{\pgfqpoint{3pt}{0pt}}
\pgfpathmoveto{\pgfqpoint{.2pt}{-.2pt}}
\pgfpathlineto{\pgfqpoint{-.2pt}{.2pt}}
\pgfpathmoveto{\pgfqpoint{3.2pt}{2.8pt}}
\pgfpathlineto{\pgfqpoint{2.8pt}{3.2pt}}
\pgfusepath{stroke}}