Skip to content

Commit

Permalink
Rotated hexagons, removed tri/iso duplication, add ghostly colorset (#19
Browse files Browse the repository at this point in the history
)

Added code to rotate hexagon pattern by an arbitrary angle. Added "hexup" pattern that rotates hexagons 90 degrees relative to default orientation.

Rewrote the triangle code, deleted iso pattern, changed iso option to draw with function triangles[rotate=90]

Added "ghostly" colorset

Converted tabs to spaces

Removed unnecessary lines that were commented out

Update version number
  • Loading branch information
mcnees authored Mar 28, 2021
1 parent 68762a7 commit 1027138
Show file tree
Hide file tree
Showing 3 changed files with 140 additions and 141 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ current valid options are:

* `pattern=<name>`:
Valid pattern names are:
`std,stdeight,majmin,dot,hex,tri,iso,lightcone,ruled,doubleruled`. Default
`std,stdeight,majmin,dot,hex,hexup,tri,iso,lightcone,ruled,doubleruled`. Default
is `std`. Patterns come with default page geometry (size and margins;
see `geometry`), and default 'fullness' (whether they fill the page or
not; see options `fullpage` and `textarea`).
* `colorset=<name>`:
Valid color preset names are:
`std,precocious,brickred,engineer,plumpad`. Default is `std`. A
`std,precocious,ghostly,brickred,engineer,plumpad`. Default is `std`. A
preset determines the `majorcolor`, `minorcolor`, and `bgcolor` all at
once. But, you can start from a preset and then override some colors.
* `majorcolor=<color>`: Override the preset "major" color. This can
Expand Down
145 changes: 74 additions & 71 deletions gridpapers.dtx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
%</driver>
% \fi
%
% \CheckSum{432}
% \CheckSum{405}
%
% \CharacterTable
% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
Expand All @@ -72,6 +72,8 @@
% \changes{v1.0.0}{2021/03/13}{Converted to DTX file}
% \changes{v1.0.1}{2021/03/19}{Hotfix: old installs don't have
% everypage-1x, use everypage}
% \changes{v1.0.2}{2021/03/26}{Replace triangle and hexagon code
% to allow rotated grids, add 'ghostly' colorset}
%
% \DoNotIndex{\newcommand,\newenvironment}
%
Expand Down Expand Up @@ -114,14 +116,14 @@
% \DescribeObject{pattern=\marg{name}}\DescribeDefault{std} Which of
% the predefined patterns to use for the page or textarea background.
% The current list of pattern names is: |std|, |stdeight|, |majmin|,
% |dot|, |hex|, |tri|, |iso|, |lightcone|, |ruled|, |doubleruled|. We
% |dot|, |hex|, |hexup|, |tri|, |iso|, |lightcone|, |ruled|, |doubleruled|. We
% describe each of these patterns in Sec.~\ref{sec:patterns}.
% Patterns come with default page geometry (size and margins; see
% |geometry|), and default `fullness' (whether they fill the page or
% not; see options |fullpage| and |textarea|).
%
% \DescribeObject{colorset=\marg{name}}\DescribeDefault{std} Color
% presets. Valid color preset names are: |std|, |precocious|,
% presets. Valid color preset names are: |std|, |precocious|, |ghostly|,
% |brickred|, |engineer|, |plumpad|. A preset determines the
% |majorcolor|, |minorcolor|, and |bgcolor| all at once. But, you can
% start from a preset and then override some colors.
Expand Down Expand Up @@ -182,6 +184,10 @@
% controls the side length of a hexagon. Default is
% |patternsize=0.1666in|.
%
% \DescribeObject{hexup} Grid of hexagons, rotated 90 degrees from the
% default orientation. The |patternsize| option controls the side
% length of a hexagon. Default is |patternsize=0.1666in|.
%
% \DescribeObject{tri} Triangle grid. The |patternsize| option
% controls the side length of a triangle. Default is
% |patternsize=0.25in|.
Expand Down Expand Up @@ -244,7 +250,7 @@
% \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{gridpapers}
[2021/03/19 v1.0.1 Graph paper backgrounds]
[2021/03/27 v1.0.2 Graph paper backgrounds]

\RequirePackage{xkeyval}
\RequirePackage{kvoptions}
Expand Down Expand Up @@ -353,7 +359,7 @@
%% the list below.
\define@choicekey*{GP}{colorset}[\val\nr]%
%% Allowed values for colorset:
{std,precocious,brickred,engineer,plumpad}[std]{%
{std,precocious,ghostly,brickred,engineer,plumpad}[std]{%
\ifcase\nr\relax
%% std
\colorlet{minorcolor}{cornflower!30}
Expand All @@ -364,6 +370,11 @@
\colorlet{minorcolor}{rosiegrid!50}
\colorlet{majorcolor}{rosiegrid}
\colorlet{bgcolor}{rosiebg}
\or
%% ghostly
\colorlet{minorcolor}{gray!15}
\colorlet{majorcolor}{gray!20}
\colorlet{bgcolor}{white}
\or
%% brickred
\colorlet{minorcolor}{brick!35}
Expand Down Expand Up @@ -418,28 +429,35 @@
%% We have to delay this definition until after \GP@patternsize is
%% redefined (by the pattern selection and/or user override)
\newcommand{\GP@declarehexpat}{
\pgfdeclarepatternformonly
{hexagons}%% name
{\pgfpointorigin}%% lower left
{\pgfpoint{3*\GP@patternsize}{0.866025*2*\GP@patternsize}}
{\pgfpoint{3*\GP@patternsize}{0.866025*2*\GP@patternsize}}
{
\pgfsetlinewidth{0.6pt}
\pgftransformshift{\pgfpoint{0mm}{0.866025*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{0.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{-0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2*\GP@patternsize}{-0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{3*\GP@patternsize}{0mm}}
\pgfpathmoveto{\pgfpoint{0.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2*\GP@patternsize}{0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2.5*\GP@patternsize}{0mm}}
\pgfusepath{stroke}
\tikzdeclarepattern{
name=hexagons,
type=uncolored,
bounding box={(0,0) and (3*\GP@patternsize,0.866025*2*\GP@patternsize)},
tile size={(3*\GP@patternsize,0.866025*2*\GP@patternsize)},
parameters={\tikzhexrotate},
tile transformation={rotate=\tikzhexrotate},
defaults={
rotate/.store in=\tikzhexrotate,rotate=0,
},
code={
\pgfsetlinewidth{0.6pt}
\pgftransformshift{\pgfpoint{0mm}{0.866025*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{0.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{-0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2*\GP@patternsize}{-0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{3*\GP@patternsize}{0mm}}
\pgfpathmoveto{\pgfpoint{0.5*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2*\GP@patternsize}{0.866025*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2.5*\GP@patternsize}{0mm}}
\pgfusepath{stroke}
}
}
}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% This section sets up a routine for filling a shape with
%% triangles.
Expand All @@ -448,50 +466,28 @@
%% We have to delay this definition until after \GP@patternsize is
%% redefined (by the pattern selection and/or user override)
\newcommand{\GP@declaretripat}{
\pgfdeclarepatternformonly
%% Name of the pattern
{triangles}
%% Set the lower left corner of the pattern
{\pgfpointorigin}
%% Set the upper right corner of the pattern
{\pgfpoint{\GP@patternsize}{2*0.8660254*\GP@patternsize}}
%% Declare the size of the pattern blocks
{\pgfpoint{\GP@patternsize}{2*0.8660254*\GP@patternsize}}
%% Draw the pattern
{
\pgfsetlinewidth{0.6pt}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{2*0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{0mm}{2*0.8660254*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0.8660254*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{2*0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{0mm}{0mm}}
\pgfusepath{stroke}
}
}
\newcommand{\GP@declareisopat}{
\pgfdeclarepatternformonly
%% Name of the pattern
{isometric}
%% Set the lower left corner of the pattern
{\pgfpointorigin}
%% Set the upper right corner of the pattern
{\pgfpoint{2*0.8660254*\GP@patternsize}{\GP@patternsize}}
%% Declare the size of the pattern blocks
{\pgfpoint{2*0.8660254*\GP@patternsize}{\GP@patternsize}}
%% Draw the pattern
{
\pgfsetlinewidth{0.6pt}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{2*0.8660254*\GP@patternsize}{\GP@patternsize}}
\pgfpathlineto{\pgfpoint{2*0.8660254*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{0mm}{\GP@patternsize}}
\pgfpathlineto{\pgfpoint{0mm}{0mm}}
\pgfpathmoveto{\pgfpoint{0.8660254*\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{0.8660254*\GP@patternsize}{\GP@patternsize}}
\pgfusepath{stroke}
\tikzdeclarepattern{
name=triangles,
type=uncolored,
bounding box={(0,0) and (\GP@patternsize,2*0.866025*\GP@patternsize)},
tile size={(\GP@patternsize,2*0.866025*\GP@patternsize)},
parameters={\tikztrirotate},
tile transformation={rotate=\tikztrirotate},
defaults={
rotate/.store in=\tikztrirotate,rotate=0,
},
code={
\pgfsetlinewidth{0.6pt}
\pgfpathmoveto{\pgfpoint{0mm}{0mm}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{2*0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{0mm}{2*0.8660254*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0.8660254*\GP@patternsize}}
\pgfpathmoveto{\pgfpoint{0mm}{2*0.8660254*\GP@patternsize}}
\pgfpathlineto{\pgfpoint{\GP@patternsize}{0mm}}
\pgfpathlineto{\pgfpoint{0mm}{0mm}}
\pgfusepath{stroke}
}
}
}

Expand Down Expand Up @@ -613,7 +609,7 @@

\define@choicekey*{GP}{pattern}[\val\nr]%
%% Allowed values for pattern:
{std,stdeight,majmin,dot,hex,tri,iso,lightcone,ruled,doubleruled}{%
{std,stdeight,majmin,dot,hex,hexup,tri,iso,lightcone,ruled,doubleruled}{%
\ifcase\nr\relax
%% std
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand Down Expand Up @@ -671,6 +667,14 @@
\GP@setpattern{true}{}{0.1666in}{%
\fill [pattern=hexagons,pattern color=minorcolor] (a) rectangle (b);
}
\or
%% hexup
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Hex-up grid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\GP@setpattern{true}{}{0.1666in}{%
\fill [pattern={hexagons[rotate=90]},pattern color=minorcolor] (a) rectangle (b);
}
\or
%% tri
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Expand All @@ -685,7 +689,7 @@
%% Isometric grid
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\GP@setpattern{true}{}{0.25in}{%
\fill [pattern=isometric, pattern color=minorcolor] (a) rectangle (b);
\fill [pattern={triangles[rotate=90]}, pattern color=minorcolor] (a) rectangle (b);
}
\or
%% lightcone
Expand Down Expand Up @@ -769,7 +773,6 @@
%% patterns with the correct lengths.
\GP@declarehexpat
\GP@declaretripat
\GP@declareisopat
\GP@declarelightconepat
\GP@declaredotpat

Expand Down
Loading

0 comments on commit 1027138

Please sign in to comment.