diff options
author | Karl Berry <karl@freefriends.org> | 2023-10-06 20:32:01 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2023-10-06 20:32:01 +0000 |
commit | 16c976bc10db55420784d85afed1ad3fc3b384b2 (patch) | |
tree | 8f6bc0767a81826e9ae039caaa2c1c76e7b8c069 /Master/texmf-dist | |
parent | e3cf3292412a763e0ded1b23a65dde53dfc051f3 (diff) |
tikz-osci (6oct23)
git-svn-id: svn://tug.org/texlive/trunk@68464 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist')
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-osci/README.md | 5 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-osci/doc.pdf | bin | 0 -> 83881 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-osci/doc.tex | 161 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/tikz-osci/example.tex | 29 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/tikz-osci/tikz-osci.sty | 204 |
5 files changed, 399 insertions, 0 deletions
diff --git a/Master/texmf-dist/doc/latex/tikz-osci/README.md b/Master/texmf-dist/doc/latex/tikz-osci/README.md new file mode 100644 index 00000000000..f997f44e1e7 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-osci/README.md @@ -0,0 +1,5 @@ +tikz-osci is a package which provides some macros to draw oscilloscope screen captures from math functions provided by the user. +----------------------------------------------------------- +Author : Thibault Giauffret +email : contact at ensciences dot fr +Licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txt diff --git a/Master/texmf-dist/doc/latex/tikz-osci/doc.pdf b/Master/texmf-dist/doc/latex/tikz-osci/doc.pdf Binary files differnew file mode 100644 index 00000000000..064db93334c --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-osci/doc.pdf diff --git a/Master/texmf-dist/doc/latex/tikz-osci/doc.tex b/Master/texmf-dist/doc/latex/tikz-osci/doc.tex new file mode 100644 index 00000000000..cee5c63fb54 --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-osci/doc.tex @@ -0,0 +1,161 @@ +\documentclass[11pt,a4paper,usenames,dvipsnames]{article} + + + +\usepackage{tikz-osci} +\usepackage[left=2cm,right=2cm,top=2cm,bottom=2cm]{geometry} +\usepackage[most]{tcolorbox} +\usepackage{hyperref} +\title{TikZ Oscilloscope Package} +\author{Thibault Giauffret} +\def\version{0.1.0} + +\begin{document} + +\begin{tcolorbox} + \begin{center} + \vspace{0.3cm} + {\huge \textbf{TikZ Oscilloscope Package}}\\[0.3cm] + {\Large Thibault Giauffret}\\[0.3cm] + \textit{Version \version\ of \today} + \vspace{0.3cm} + \end{center} +\end{tcolorbox} + +% Remove paragraph indentation +\setlength{\parindent}{0pt} + +% Listings +\newtcblisting{listing}{ + listing only, + hbox, + listing options={ + basicstyle=\small\ttfamily, + breaklines=true, + columns=fullflexible + }, +} + + +\section{Introduction} + +\begin{center} + \osci[% + scale=0.8 + ] +\end{center} + + + +This package is modest alternative to the \texttt{pst-osci} package, not maintained anymore. + +Some features are not implemented yet, but the package is already usable with the basic options. I'm doing this for fun and to learn how to make a \LaTeX{} package. Therefore, I'm open to any suggestion or contribution : + +\begin{center} + \texttt{ + contact at ensciences dot fr + } +\end{center} + + + +\section{Usage} + +The package is loaded with the command \verb|\usepackage{tikz-osci}|. It defines a single command, \verb|\osci|, which takes a list of options as argument. The options allow you to configure and customize the oscilloscope screen view : + +\begin{tcolorbox}[enhanced,breakable,colback=white,colframe=black,width=\textwidth] + \begin{tabular}{lp{7cm}p{3cm}} + \texttt{scale} & Scale of the oscilloscope (with \texttt{scalebox}). & Default: \texttt{1}. \\ + \texttt{second channel} & 1 if the second channel is enabled, 0 otherwise. & Default: \texttt{0}. \\ + \texttt{screen offset one} & Vertical screen offset of the first channel. & Default: \texttt{0}. \\ + \texttt{screen offset two} & Vertical screen offset of the second channel. & Default: \texttt{0}. \\ + \texttt{time div} & Time division (in ms). & Default: \texttt{20}. \\ + \texttt{voltage div one} & Voltage division of the first channel (in V). & Default: \texttt{1}. \\ + \texttt{voltage div two} & Voltage division of the second channel (in V). & Default: \texttt{1}. \\ + \texttt{sample rate} & Sample rate (in Hz). & Default: \texttt{200}. \\ + \texttt{xy mode} & 1 if the oscilloscope is in XY mode, 0 otherwise. \textbf{\color{red}Not working yet !} & Default: 0. \\ + \texttt{expr one} & Expression of the first channel (pgf maths format). & Default: \texttt{2*sin(2*180/0.020*x)}. \\ + \texttt{expr two} & Expression of the second channel (pgf maths format). & Default: \texttt{1*sin(2*180/0.020*x) + 0.2*sin(2*180/0.040*x)}. \\ + \texttt{color one} & Color of the first channel (in hexadecimal). & Default: \texttt{D62626}. \\ + \texttt{color two} & Color of the second channel (in hexadecimal). & Default: \texttt{1053AF}. \\ + \texttt{color xy} & Color of the XY mode (in hexadecimal). & Default: \texttt{2E8B73}. \\ + \texttt{graph back color} & Background color of the graph (in hexadecimal). & Default: \texttt{FFFFFF}. \\ + \texttt{info back color} & Background color of the information box (in hexadecimal). & Default: \texttt{D6D6D6}. \\ + \texttt{info text color} & Text color of the information box (in hexadecimal). & Default: \texttt{000000}. \\ + \texttt{main axis color} & Color of the main axis (in hexadecimal). & Default: \texttt{000000}. \\ + \texttt{sub axis color} & Color of the sub axis (in hexadecimal). & Default: \texttt{CCCCCC}. \\ + \end{tabular} +\end{tcolorbox} + + +\section{Examples} + +\begin{tcblisting}{enhanced,breakable,colback=white,colframe=black,width=\textwidth} + \osci[% + scale=0.8, + second channel=1, + screen offset one=2, + screen offset two=-2, + time div=20, + voltage div one=4, + voltage div two=1, + sample rate=200, + xy mode=0, + expr one=2*sin(2*180/0.020*x), + expr two=1*sin(2*180/0.020*x)+0.2*sin(2*180/0.040*x), + color one=D62626, + color two=1053AF, + color xy=2E8B73, + graph back color=669966, + info back color=D6D6D6, + info text color=000000, + main axis color=000000, + sub axis color=CCCCCC + ] + \end{tcblisting} + +% \begin{center} +% \osci[% +% scale=0.8, +% second channel=1, +% screen offset one=2, +% screen offset two=-2, +% time div=20, +% voltage div one=4, +% voltage div two=1, +% sample rate=200, +% xy mode=0, +% expr one=2*sin(2*180/0.020*x), +% expr two=1*sin(2*180/0.020*x)+0.2*sin(2*180/0.040*x), +% color one=D62626, +% color two=1053AF, +% color xy=2E8B73, +% graph back color=669966, +% info back color=D6D6D6, +% info text color=000000, +% main axis color=000000, +% sub axis color=CCCCCC +% ] +% \end{center} + +\section{License} + +This package is distributed under the terms of the \textbf{LaTeX Project Public License} (LPPL), version 1.3c or later. The latest version of this license is available at \url{http://www.latex-project.org/lppl.txt}. + +\section{Credits} + +This package requires the following packages : +\begin{itemize} + \item \texttt{xcolor} maintained by the \textit{LaTeX3 Project} (license LPPL 1.3c) ; + \item tikz maintained by the \textit{TikZ and PGF Project} (license LPPL 1.3c) ; + \item pgfkeys maintained by the \textit{Till Tantau} (license LPPL) ; + \item pgfplots maintained by the \textit{Christian Feuersänger} (license LPPL). +\end{itemize} + +\section{Changelog} + +\begin{itemize} + \item \textbf{0.1.0} : Initial release. XY mode not implemented yet. +\end{itemize} + +\end{document} diff --git a/Master/texmf-dist/doc/latex/tikz-osci/example.tex b/Master/texmf-dist/doc/latex/tikz-osci/example.tex new file mode 100644 index 00000000000..f70a760c94d --- /dev/null +++ b/Master/texmf-dist/doc/latex/tikz-osci/example.tex @@ -0,0 +1,29 @@ +\documentclass[11pt,a4paper,usenames,dvipsnames]{article} + +\usepackage{tikz-osci} + +\begin{document} + +\osci[% + scale=0.8, + second channel=1, + screen offset one=2, + screen offset two=-2, + time div=20, + voltage div one=4, + voltage div two=1, + sample rate=200, + xy mode=0, + expr one=2*sin(2*180/0.020*x), + expr two=1*sin(2*180/0.020*x)+0.2*sin(2*180/0.040*x), + color one=D62626, + color two=1053AF, + color xy=2E8B73, + graph back color=668866, + info back color=D6D6D6, + info text color=000000, + main axis color=000000, + sub axis color=CCCCCC, +] + +\end{document}
\ No newline at end of file diff --git a/Master/texmf-dist/tex/latex/tikz-osci/tikz-osci.sty b/Master/texmf-dist/tex/latex/tikz-osci/tikz-osci.sty new file mode 100644 index 00000000000..d2d59cd5255 --- /dev/null +++ b/Master/texmf-dist/tex/latex/tikz-osci/tikz-osci.sty @@ -0,0 +1,204 @@ +% ----------------------------------------------------------- +% This is TikZ Osci package +% +% It provides some macros to draw oscilloscope screen captures +% from math functions provided by the user. +% +% It is based on TikZ and pgfplots and is a replacement can- +% didate to the pstricks pst-osci package which is not main- +% tained anymore. +% +% Author: Thibault Giauffret +% Date: 2013/10/06 +% Version: 0.1.0 +% Licence : Released under the LaTeX Project Public License v1.3c or later, see http://www.latex-project.org/lppl.txtf +% Not an expert... Just doing it for fun. +% ----------------------------------------------------------- + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{tikz-osci}[2023/09/30 0.1.0 Tikz Osci package] + +% Required packages +\RequirePackage[dvipsnames]{xcolor} +\RequirePackage{pgfkeys} +\RequirePackage{pgfplots} +\RequirePackage{tikz} +\usetikzlibrary{arrows,shapes,positioning} +\usetikzlibrary{decorations.markings,decorations.pathmorphing, + decorations.pathreplacing} +\usetikzlibrary{calc,patterns,shapes.geometric} + + +% Init the keys and get the values +\pgfkeys{ + /osci/.cd, + scale/.store in=\scale, + scale=1, + second channel/.store in=\secondChannel, + second channel=0, + screen offset one/.store in=\screenOffsetOne, + screen offset one=0, + screen offset two/.store in=\screenOffsetTwo, + screen offset two=-0, + time div/.store in=\timeDiv, + time div=20, + voltage div one/.store in=\voltageDivOne, + voltage div one=1, + voltage div two/.store in=\voltageDivTwo, + voltage div two=1, + sample rate/.store in=\sampleRate, + sample rate=200, + xy mode/.store in=\xyMode, + xy mode=0, + expr one/.store in=\exprOne, + expr one=2*sin(2*180/0.020*x), + expr two/.store in=\exprTwo, + expr two=0.6*sin(2*180/0.020*x)+0.2*sin(2*180/0.040*x), + color one/.store in=\colorOne, + color one=D62626, + color two/.store in=\colorTwo, + color two=1053AF, + color xy/.store in=\colorXY, + color xy=2E8B73, + graph back color/.store in=\graphBackColor, + graph back color=FFFFFF, + info back color/.store in=\infoBackColor, + info back color=D6D6D6, + info text color/.store in=\infoTextColor, + info text color=000000, + main axis color/.store in=\mainAxisColor, + main axis color=000000, + sub axis color/.store in=\subAxisColor, + sub axis color=AAAAAA, +} + +% The main command +\newcommand\osci[1][]{ + + % Get the values + \pgfkeys{ + /osci/.cd, + #1, + } + + \scalebox{\scale}{ + % Begin the picture + \begin{tikzpicture} + + % Set the colors + \definecolor{firstcolor}{HTML}{\colorOne} + \definecolor{secondcolor}{HTML}{\colorTwo} + \definecolor{thirdcolor}{HTML}{\colorXY} + \definecolor{graphbackcolor}{HTML}{\graphBackColor} + \definecolor{infoBackColor}{HTML}{\infoBackColor} + \definecolor{infoTextColor}{HTML}{\infoTextColor} + \definecolor{mainAxisColor}{HTML}{\mainAxisColor} + \definecolor{subAxisColor}{HTML}{\subAxisColor} + + % Draw the info box + \draw[black,thick, fill= infoBackColor] + (0,0) -- + ++(10,0) {[rounded corners=10] -- + ++(0,-1.5) -- + ++(-10,0)} -- + cycle + {}; + + % Add time/div label + \draw (5,-0.15) node[anchor=north, color= infoTextColor] {\timeDiv\ ms/div}; + + % Add voltage/div label for the first channel + \draw[firstcolor,fill=firstcolor] (0.5,-0.15) rectangle (1.5,-0.6); + \draw (1,-0.1) node[anchor=north, color=white] {CH1}; + \draw (1,-0.75) node[anchor=north, color= infoTextColor] {\voltageDivOne\ V/div}; + + % Add voltage/div label for the second channel + \ifnum\secondChannel=1 + \draw[secondcolor,fill=secondcolor] (8.5,-0.15) rectangle (9.5,-0.6); + \draw (9,-0.1) node[anchor=north, color=white] {CH2}; + \draw (9,-0.75) node[anchor=north, color= infoTextColor] {\voltageDivTwo\ V/div}; + \fi + + % Add the XY mode label + \ifnum\xyMode=1 + % \draw (5,-0.75) node[anchor=north, color=thirdcolor] {XY mode}; + % Coming soon... + \fi + + % Draw the oscilloscope screen border + \draw[black,thick, fill= graphbackcolor] + (0,0) -- + ++(10,0) {[rounded corners=10] -- + ++(0,8) -- + ++(-10,0)} -- + cycle + {}; + + % Draw the oscilloscope screen graduations + \begin{scope} + + % Remove the border + \clip (0.05,0.05) rectangle (9.95,7.95); + + \begin{axis}[xmin=-5*(\timeDiv/1000), xmax=5*(\timeDiv/1000), ymin=-4, ymax=4, xtick distance = \timeDiv/1000, + axis x line=middle, axis y line=middle, + axis line style={-}, + % Draw major grid + grid=both, + xticklabels={,,}, + yticklabels={,,}, + % Add sub ticks for the x axis + minor tick num=4, + % Remove minor grid + minor grid style={line width=0pt, draw=white, draw opacity=0}, + major grid style={thick,dashed,draw=subAxisColor}, + every major tick/.append style={very thick, major tick length=6pt, color=mainAxisColor}, + every minor tick/.append style={thick, minor tick length=4pt, color=mainAxisColor}, + ] + + % Change plot width + \pgfplotsset{width=11.58cm, height=9.58cm} + % Change tick label style + \pgfplotsset{ every non boxed x axis/.append style={x axis line style=-}, + every non boxed y axis/.append style={y axis line style=-}} + + \ifnum\xyMode=1 + + % Coming soon... + + \else + + % Draw each channel separately + % First channel plot + \addplot[color=firstcolor,very thick,domain=-5*(\timeDiv/1000):5*(\timeDiv/1000), + smooth, samples=\sampleRate]{(\exprOne)/\voltageDivOne+\screenOffsetOne}; + + % If the second channel is enabled, draw it + \ifnum\secondChannel=1 + % Draw the second channel + \addplot[color=secondcolor,very thick,domain=-5*(\timeDiv/1000):5*(\timeDiv/1000), smooth, samples=\sampleRate]{(\exprTwo)/\voltageDivTwo+\screenOffsetTwo}; + \fi + \fi + + \end{axis} + + \ifnum\xyMode=0 + % Draw the first channel's screen marker + \draw[firstcolor,fill=firstcolor] (0.4, \screenOffsetOne+4) -- (0, \screenOffsetOne+4+0.3) -- (0, \screenOffsetOne+4-0.3) -- cycle; + \draw (-0.04, \screenOffsetOne+4) node[anchor=west, color=white,font=\fontsize{8}{10}\selectfont] {1}; + + % Draw the second channel's screen marker + \ifnum\secondChannel=1 + \draw[secondcolor,fill=secondcolor] (0.4, \screenOffsetTwo+4) -- (0, \screenOffsetTwo+4+0.3) -- (0, \screenOffsetTwo+4-0.3) -- cycle; + \draw (-0.04, \screenOffsetTwo+4) node[anchor=west, color=white,font=\fontsize{8}{10}\selectfont] {2}; + \fi + \fi + + \end{scope} + + \end{tikzpicture} + } +} + + + |