Quantcast
Channel: TikZ: Match up diagonal shading with adjacent horizontal and vertical three-colour shadings - TeX - LaTeX Stack Exchange
Viewing all articles
Browse latest Browse all 2

TikZ: Match up diagonal shading with adjacent horizontal and vertical three-colour shadings

$
0
0

I apologize for the convoluted title, but I like my titles to describe my questions and couldn't think of a more condensed version.

Quite a few questions already exist on custom shadings and fadings for rectangles as well as other shapes, but I couldn't find the answer to my question in those. So here it is. I have two shaded rectangles that share a corner; the drawing is for a physics problem: the rectangles represent a floor and a wall. They have the same colour gradient except one is vertically oriented and the other horizontally. Now I want to join these two rectangles by means of a third rectangle with a similar diagonal gradient, but this has not worked.

I know the essence of why it doesn't work the way I currently have it implemented (if I'm not mistaken it has to do with the way TikZ obtains rotated shadings), but I'm unable to implement a working version. Below is a rendering of the following MWE:

\documentclass[tikz,border=5mm]{standalone}\usepackage{tikz}\usetikzlibrary{calc,shadings}\begin{document}\begin{tikzpicture}[x=2em,y=2em]% Dimensions of the stuff\pgfmathsetmacro\floorL{7}\pgfmathsetmacro\boxL{\floorL/2}\pgfmathsetmacro\boxH{\boxL/3.5}\pgfmathsetmacro\wallH{2*\boxH}\pgfmathsetmacro\floorD{\floorL/14}\pgfmathsetmacro\wallD{\floorL/14}% Define the stuff% origin\coordinate (O) at (0,0);% floor\coordinate (floorTL) at (O);\coordinate (floorTR) at ($(floorTL)+(\floorL,0)$);\coordinate (floorBL) at ($(floorTL)+(0,-\floorD)$);\coordinate (floorBR) at ($(floorBL)+(\floorL,0)$);% wall\coordinate (wallBL) at (floorTR);\coordinate (wallBR) at ($(wallBL)+(\wallD,0)$);\coordinate (wallTL) at ($(wallBL)+(0,\wallH)$);\coordinate (wallTR) at ($(wallTL)+(\wallD,0)$);% Draw the stuff% floor\fill[bottom color=white,top color=brown!60!black,middle color=brown!80] (floorBL) rectangle (floorTR);% wall\fill[left color=brown!60!black,right color=white,middle color=brown!80] (wallBL) rectangle (wallTR);% connect wall and floor\shade[left color=brown!60!black,right color=white,middle color=brown!80,shading angle=45] (floorBR) rectangle (wallBR);\end{tikzpicture}\end{document}

enter image description here

I would obviously like the colours to match up, so is this possible in some reasonably simple/elegant way?


Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images