Tikz: Method to color regions
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
(I would think that this question has already been asked in many other forms. I just do not how to search for it.)
MWE:
begindocument
begintikzpicture
draw (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw (0, 8) -- (8, 4);
draw (0, 0) -- (8, 8);
endtikzpicture
enddocument
Apart from calculating the intersection point and manually drawing each shape, etc., what other options do I have to color any one of the four regions?
tikz-pgf
add a comment |Â
up vote
2
down vote
favorite
(I would think that this question has already been asked in many other forms. I just do not how to search for it.)
MWE:
begindocument
begintikzpicture
draw (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw (0, 8) -- (8, 4);
draw (0, 0) -- (8, 8);
endtikzpicture
enddocument
Apart from calculating the intersection point and manually drawing each shape, etc., what other options do I have to color any one of the four regions?
tikz-pgf
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
(I would think that this question has already been asked in many other forms. I just do not how to search for it.)
MWE:
begindocument
begintikzpicture
draw (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw (0, 8) -- (8, 4);
draw (0, 0) -- (8, 8);
endtikzpicture
enddocument
Apart from calculating the intersection point and manually drawing each shape, etc., what other options do I have to color any one of the four regions?
tikz-pgf
(I would think that this question has already been asked in many other forms. I just do not how to search for it.)
MWE:
begindocument
begintikzpicture
draw (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw (0, 8) -- (8, 4);
draw (0, 0) -- (8, 8);
endtikzpicture
enddocument
Apart from calculating the intersection point and manually drawing each shape, etc., what other options do I have to color any one of the four regions?
tikz-pgf
tikz-pgf
asked 33 mins ago


blackened
1,215710
1,215710
add a comment |Â
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
3
down vote
A perhaps less know possibility is to employ the pgfplots library fillbetween
. To show that I do not overwrite different parts, I fill each of them separately in an animation.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibraryfillbetween
begindocument
foreach X in 0,...,3
begintikzpicture
draw[name path=box] (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw[name path=d1] (0, 8) -- (8, 4);
draw[name path=d2] (0, 0) -- (8, 8);
ifcaseX
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B0[reverse]];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B1];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B1];
or
path [name path=aux,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B0[reverse]];
fill [blue,intersection segments=of=aux and box,
sequence=A1 -- B2[reverse]];
fi
endtikzpicture
enddocument
add a comment |Â
up vote
1
down vote
One possibility is to calculate the coordinates of the intersection point of the two segments drawn in the square with TikZ; then to color the desired part.
For this purpose, there is an operation that is no longer documented in manual 3.0.1a but is fully functional.
Its documentation can be found in the manual 1.18
which is still available (until when?) here TikZ manual 1.18 (p 87, section 10.2.4 Intersection Coordinate Systems).
documentclass[border=5pt]standalone
usepackagetikz
begindocument
begintikzpicture
draw (0, 0) coordinate(A)node[below left]A-- (0, 8)coordinate(B)node[above left]B -- (8, 8)coordinate(C)node[above right]C -- (8, 0)coordinate(D)node[below right]D --cycle;
draw (B) -- (8, 4)coordinate(E)node[right]E;
draw (A) -- (C);
coordinate (I) at (intersection of 0,8--E and A--C);
fill[green](A)--(B)--(I)--cycle;
fill[blue](B)--(C)--(I)--cycle;
fill[red](C)--(E)--(I)--cycle;
fill[violet](A)--(D)--(E)--(I)--cycle;
endtikzpicture
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
A perhaps less know possibility is to employ the pgfplots library fillbetween
. To show that I do not overwrite different parts, I fill each of them separately in an animation.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibraryfillbetween
begindocument
foreach X in 0,...,3
begintikzpicture
draw[name path=box] (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw[name path=d1] (0, 8) -- (8, 4);
draw[name path=d2] (0, 0) -- (8, 8);
ifcaseX
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B0[reverse]];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B1];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B1];
or
path [name path=aux,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B0[reverse]];
fill [blue,intersection segments=of=aux and box,
sequence=A1 -- B2[reverse]];
fi
endtikzpicture
enddocument
add a comment |Â
up vote
3
down vote
A perhaps less know possibility is to employ the pgfplots library fillbetween
. To show that I do not overwrite different parts, I fill each of them separately in an animation.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibraryfillbetween
begindocument
foreach X in 0,...,3
begintikzpicture
draw[name path=box] (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw[name path=d1] (0, 8) -- (8, 4);
draw[name path=d2] (0, 0) -- (8, 8);
ifcaseX
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B0[reverse]];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B1];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B1];
or
path [name path=aux,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B0[reverse]];
fill [blue,intersection segments=of=aux and box,
sequence=A1 -- B2[reverse]];
fi
endtikzpicture
enddocument
add a comment |Â
up vote
3
down vote
up vote
3
down vote
A perhaps less know possibility is to employ the pgfplots library fillbetween
. To show that I do not overwrite different parts, I fill each of them separately in an animation.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibraryfillbetween
begindocument
foreach X in 0,...,3
begintikzpicture
draw[name path=box] (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw[name path=d1] (0, 8) -- (8, 4);
draw[name path=d2] (0, 0) -- (8, 8);
ifcaseX
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B0[reverse]];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B1];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B1];
or
path [name path=aux,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B0[reverse]];
fill [blue,intersection segments=of=aux and box,
sequence=A1 -- B2[reverse]];
fi
endtikzpicture
enddocument
A perhaps less know possibility is to employ the pgfplots library fillbetween
. To show that I do not overwrite different parts, I fill each of them separately in an animation.
documentclass[tikz,border=3.14mm]standalone
usepackagepgfplots
pgfplotssetcompat=1.16
usepgfplotslibraryfillbetween
begindocument
foreach X in 0,...,3
begintikzpicture
draw[name path=box] (0, 0) -- (0, 8) -- (8, 8) -- (8, 0) --cycle;
draw[name path=d1] (0, 8) -- (8, 4);
draw[name path=d2] (0, 0) -- (8, 8);
ifcaseX
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B0[reverse]];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A0 -- B1];
or
fill [blue,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B1];
or
path [name path=aux,intersection segments=of=d1 and d2,
sequence=A1[reverse] -- B0[reverse]];
fill [blue,intersection segments=of=aux and box,
sequence=A1 -- B2[reverse]];
fi
endtikzpicture
enddocument
answered 7 mins ago


marmot
65.2k471139
65.2k471139
add a comment |Â
add a comment |Â
up vote
1
down vote
One possibility is to calculate the coordinates of the intersection point of the two segments drawn in the square with TikZ; then to color the desired part.
For this purpose, there is an operation that is no longer documented in manual 3.0.1a but is fully functional.
Its documentation can be found in the manual 1.18
which is still available (until when?) here TikZ manual 1.18 (p 87, section 10.2.4 Intersection Coordinate Systems).
documentclass[border=5pt]standalone
usepackagetikz
begindocument
begintikzpicture
draw (0, 0) coordinate(A)node[below left]A-- (0, 8)coordinate(B)node[above left]B -- (8, 8)coordinate(C)node[above right]C -- (8, 0)coordinate(D)node[below right]D --cycle;
draw (B) -- (8, 4)coordinate(E)node[right]E;
draw (A) -- (C);
coordinate (I) at (intersection of 0,8--E and A--C);
fill[green](A)--(B)--(I)--cycle;
fill[blue](B)--(C)--(I)--cycle;
fill[red](C)--(E)--(I)--cycle;
fill[violet](A)--(D)--(E)--(I)--cycle;
endtikzpicture
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
up vote
1
down vote
One possibility is to calculate the coordinates of the intersection point of the two segments drawn in the square with TikZ; then to color the desired part.
For this purpose, there is an operation that is no longer documented in manual 3.0.1a but is fully functional.
Its documentation can be found in the manual 1.18
which is still available (until when?) here TikZ manual 1.18 (p 87, section 10.2.4 Intersection Coordinate Systems).
documentclass[border=5pt]standalone
usepackagetikz
begindocument
begintikzpicture
draw (0, 0) coordinate(A)node[below left]A-- (0, 8)coordinate(B)node[above left]B -- (8, 8)coordinate(C)node[above right]C -- (8, 0)coordinate(D)node[below right]D --cycle;
draw (B) -- (8, 4)coordinate(E)node[right]E;
draw (A) -- (C);
coordinate (I) at (intersection of 0,8--E and A--C);
fill[green](A)--(B)--(I)--cycle;
fill[blue](B)--(C)--(I)--cycle;
fill[red](C)--(E)--(I)--cycle;
fill[violet](A)--(D)--(E)--(I)--cycle;
endtikzpicture
enddocument
Translated with www.DeepL.com/Translator
add a comment |Â
up vote
1
down vote
up vote
1
down vote
One possibility is to calculate the coordinates of the intersection point of the two segments drawn in the square with TikZ; then to color the desired part.
For this purpose, there is an operation that is no longer documented in manual 3.0.1a but is fully functional.
Its documentation can be found in the manual 1.18
which is still available (until when?) here TikZ manual 1.18 (p 87, section 10.2.4 Intersection Coordinate Systems).
documentclass[border=5pt]standalone
usepackagetikz
begindocument
begintikzpicture
draw (0, 0) coordinate(A)node[below left]A-- (0, 8)coordinate(B)node[above left]B -- (8, 8)coordinate(C)node[above right]C -- (8, 0)coordinate(D)node[below right]D --cycle;
draw (B) -- (8, 4)coordinate(E)node[right]E;
draw (A) -- (C);
coordinate (I) at (intersection of 0,8--E and A--C);
fill[green](A)--(B)--(I)--cycle;
fill[blue](B)--(C)--(I)--cycle;
fill[red](C)--(E)--(I)--cycle;
fill[violet](A)--(D)--(E)--(I)--cycle;
endtikzpicture
enddocument
Translated with www.DeepL.com/Translator
One possibility is to calculate the coordinates of the intersection point of the two segments drawn in the square with TikZ; then to color the desired part.
For this purpose, there is an operation that is no longer documented in manual 3.0.1a but is fully functional.
Its documentation can be found in the manual 1.18
which is still available (until when?) here TikZ manual 1.18 (p 87, section 10.2.4 Intersection Coordinate Systems).
documentclass[border=5pt]standalone
usepackagetikz
begindocument
begintikzpicture
draw (0, 0) coordinate(A)node[below left]A-- (0, 8)coordinate(B)node[above left]B -- (8, 8)coordinate(C)node[above right]C -- (8, 0)coordinate(D)node[below right]D --cycle;
draw (B) -- (8, 4)coordinate(E)node[right]E;
draw (A) -- (C);
coordinate (I) at (intersection of 0,8--E and A--C);
fill[green](A)--(B)--(I)--cycle;
fill[blue](B)--(C)--(I)--cycle;
fill[red](C)--(E)--(I)--cycle;
fill[violet](A)--(D)--(E)--(I)--cycle;
endtikzpicture
enddocument
Translated with www.DeepL.com/Translator
answered 14 mins ago
AndréC
3,700729
3,700729
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f455112%2ftikz-method-to-color-regions%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password