Howto:Build graduate dials with LaTeX: Difference between revisions

Jump to navigation Jump to search
Line 218: Line 218:
===The complete code===
===The complete code===
<syntaxhighlight lang="latex">
<syntaxhighlight lang="latex">
% Adriano Bassignana nov 2017
% Program for creating a linear index useful for the construction of a compass on a conical support
% The program can be modified and adapted for the construction of other types of numeric indexes.
% The font used is OCR-B which allows to have alphabetic and numeric symbols very similar
% to those used in analogue flight gauges in the 50s and 80s
% You must have installed OCR-B in OTF format that has a GPL-2 and later compatible license.
% The font is present in the texlive-fonts-extra package
%
% Explanation:
%
% \documentclass{standalone} is particular class that non have a size, but the size is define from
% \documentclass{standalone} is particular class that non have a size, but the size is define from
% the document itself
% the document itself
\documentclass[tikz,margin=0pt]{standalone}
%%\documentclass[tikz,margin=0pt]{standalone}
% This command permit the direct file conversion from PDF to png or svg
% {outfile=test.png} the conversion is from pdf to png with background transparent layer
% {outfile=test.svg} the conversion is from pdf to svg but as only raster format
\documentclass[tikz,margin=0pt, convert={outfile=test.png}]{standalone}
% \usepackage{tikz} is the package that contain the graphics command as \draw etc ...
% \usepackage{tikz} is the package that contain the graphics command as \draw etc ...
% The package is describe in this document: https://www.sharelatex.com/learn/TikZ_package
% The package is describe in this document: https://www.sharelatex.com/learn/TikZ_package
% If the "tikz" package is define as option on \documentclass is not necessary define this option
\usepackage{tikz}
\usepackage{tikz}
% A TiKz library to extend math functions
\usetikzlibrary{calc}
% If the graduate dials is for analogical gauges period 50-70 years, this font is ok
% If the graduate dials is for analogical gauges period 50-70 years, this font is ok
% OCR is open-source package deposited in the CTAN repository: https://www.ctan.org/pkg/ocr-b
% OCR is open-source package deposited in the CTAN repository: https://www.ctan.org/pkg/ocr-b
Line 234: Line 251:
% Wind Rose position pram
% Wind Rose position pram
\newcommand\posWindRose{2.8}
\newcommand\posWindRose{2.8}
\newcommand\externalDiameter{3.55}
\newcommand\externalRadius{3.55}
\newcommand\graduateThick{0.3}
\newcommand\graduateThick{0.3}
\newcommand\arcRadius{\externalDiameter-\graduateThick/2}
\newcommand\graduateInternaThick{0.45}
\newcommand\arcRadius{\externalRadius}
% Defines the font size to use, the first number defines the font size,
% Defines the font size to use, the first number defines the font size,
% the second number the dimensional family from which the font is taken.
% the second number the dimensional family from which the font is taken.
% It can be assumed that there are differences between a dimensional family 10 and a 12 dimensional font.
% It can be assumed that there are differences between a dimensional family 10 and a 12 dimensional font.
\begin{document}
\begin{document}
% The link OCR package documentation is this: http://ctan.mirror.garr.it/mirrors/CTAN/macros/latex/contrib/ocr-latex/ocr.pdf
% The link OCR package documentation is this:
% http://ctan.mirror.garr.it/mirrors/CTAN/macros/latex/contrib/ocr-latex/ocr.pdf
% \ocrfamily - Normal font family
% \ocrfamily - Normal font family
% \ocrnegfamily - Family negative fonts
% \ocrnegfamily - Family negative fonts
{\ocrfamily
{\ocrfamily
\begin{tikzpicture}
\begin{tikzpicture}
%\draw[line width=3mm] (0,0) circle (3.55-0.15);
% Arc application as example:
\draw[draw=cyan, line width=\graduateThick cm] (130:\arcRadius) arc (130:130+60:\arcRadius);
% https://tex.stackexchange.com/questions/66216/draw-arc-in-tikz-when-center-of-circle-is-specified
\coordinate (c1) at (0,0mm);
\draw[fill=yellow, draw=none]
% radius=\arcRadius, initial=270, final=300
($(c1) + (270:\arcRadius-\graduateInternaThick)$)
arc (270:300:\arcRadius-\graduateInternaThick) --
($(c1) + (300:\arcRadius)$)
arc (300:270:\arcRadius) -- cycle;
\draw[fill=red, draw=none]
% radius=\arcRadius, initial=45, final=270
($(c1) + (45:\arcRadius-\graduateThick)$) arc (45:270:\arcRadius-\graduateThick) --
($(c1) + (270:\arcRadius)$) arc (270:45:\arcRadius) -- cycle;
%2° Rays
%2° Rays
\foreach \a in {0, 2,...,358}
\foreach \a in {0, 2,...,358}
\draw[line width=0.3mm, cap=round] (\a:\externalDiameter-\graduateThick) -- (\a:\externalDiameter);     
\draw[line width=0.3mm, cap=round]
(\a:\externalRadius-\graduateThick) -- (\a:\externalRadius);     
%10° Rays
%10° Rays
\foreach \a in {0, 10,...,350}
\foreach \a in {0, 10,...,350}
\draw[line width=0.6mm, cap=round] (\a:\externalDiameter-\graduateThick-\graduateThick*0.5) -- (\a:\externalDiameter);
\draw[line width=0.6mm, cap=round]
(\a:\externalRadius-\graduateThick-\graduateThick*0.5) -- (\a:\externalRadius);
%Angle labels  
%Angle labels  
\foreach \a in {30, 60, 120, 150, 210, 240, 300, 330}
\foreach \a in {30, 60, 120, 150, 210, 240, 300, 330}
\pgfmathtruncatemacro\result{(360 - \a)/10}
\pgfmathtruncatemacro\result{(360 - \a)/10}
\draw (\a + 90: \externalDiameter-\graduateThick-0.5) node {\result};
\draw (\a + 90: \externalRadius-\graduateThick-0.5) node {\result};
% Wind rose labels
% Wind rose labels
\draw (90: \externalDiameter-\graduateThick-0.5) node{\large{N}};
\draw (90: \externalRadius-\graduateThick-0.5) node{\large{N}};
\draw (360:\externalDiameter-\graduateThick-0.5) node{\large{E}};
\draw (360:\externalRadius-\graduateThick-0.5) node{\large{E}};
\draw (270:\externalDiameter-\graduateThick-0.5) node{\large{S}};
\draw (270:\externalRadius-\graduateThick-0.5) node{\large{S}};
\draw (180:\externalDiameter-\graduateThick-0.5) node{\large{W}};
\draw (180:\externalRadius-\graduateThick-0.5) node{\large{W}};
% Insert the label
% Insert the label
\draw (90: 0.8) node{WIND UNIT};
\draw (90: 0.8) node{WIND UNIT};
412

edits

Navigation menu