Skip to content
This repository has been archived by the owner on Oct 25, 2023. It is now read-only.

Commit

Permalink
Make cheatsheet more complete.
Browse files Browse the repository at this point in the history
  • Loading branch information
samaaron committed Mar 4, 2012
1 parent be52303 commit 5825789
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 11 deletions.
Binary file modified docs/cheatsheet/cheat-sheet.pdf
Binary file not shown.
52 changes: 41 additions & 11 deletions docs/cheatsheet/cheat-sheet.tex
Expand Up @@ -77,7 +77,7 @@
{\Large{\textbf{Processing-core Cheat Sheet 1.0.0}}}


\colouredbox{pink}{
\colouredbox{blue2}{
\section{Color}
\begin{tabularx}{\hsize}{lX}
Creating \& Reading & \cmd{alpha blend-color blue brightness color color-mode green hue lerp-color red saturation } \\
Expand All @@ -86,19 +86,19 @@
Setting & \cmd{background background-float background-image background-int fill fill-float fill-int no-fill no-stroke stroke stroke-float stroke-int } \\
\end{tabularx}
}
\colouredbox{blue2}{
\colouredbox{yellow}{
\section{Data}
\begin{tabularx}{\hsize}{lX}
Conversion & \cmd{binary hex unbinary unhex } \\
\end{tabularx}
}
\colouredbox{yellow}{
\colouredbox{purple}{
\section{Environment}
\begin{tabularx}{\hsize}{lX}
& \cmd{current-frame-rate cursor cursor-image focused frame-count frame-rate height no-cursor screen-height screen-width width } \\
\end{tabularx}
}
\colouredbox{purple}{
\colouredbox{green}{
\section{Image}
\begin{tabularx}{\hsize}{lX}
& \cmd{create-image } \\
Expand All @@ -115,7 +115,7 @@
Time \& Date & \cmd{day hour millis minute month seconds year } \\
\end{tabularx}
}
\colouredbox{green}{
\colouredbox{pink}{
\section{Lights, Camera}
\begin{tabularx}{\hsize}{lX}
Camera & \cmd{begin-camera camera end-camera frustum ortho perspective print-camera print-projection } \\
Expand All @@ -124,15 +124,15 @@
Material Properties & \cmd{ambient ambient-float ambient-int emissive emissive-float emissive-int shininess specular } \\
\end{tabularx}
}
\colouredbox{red}{
\colouredbox{blue}{
\section{Math}
\begin{tabularx}{\hsize}{lX}
Calculation & \cmd{abs abs-float abs-int ceil constrain constrain-float constrain-int dist exp lerp log mag map-range norm pow round sq sqrt } \\
Random & \cmd{noise noise-detail noise-seed random random-seed } \\
Trigonometry & \cmd{acos asin atan atan2 cos degrees radians sin tan } \\
\end{tabularx}
}
\colouredbox{blue}{
\colouredbox{yellow}{
\section{Output}
\begin{tabularx}{\hsize}{lX}
Files & \cmd{begin-raw begin-record create-output end-raw end-record } \\
Expand All @@ -145,7 +145,7 @@
& \cmd{create-graphics hint } \\
\end{tabularx}
}
\colouredbox{pink}{
\colouredbox{red}{
\section{Shape}
\begin{tabularx}{\hsize}{lX}
2D Primitives & \cmd{arc ellipse line point quad rect triangle } \\
Expand All @@ -156,20 +156,26 @@
Vertex & \cmd{begin-shape bezier-vertex curve-vertex end-shape texture texture-mode vertex } \\
\end{tabularx}
}
\colouredbox{blue2}{
\colouredbox{green}{
\section{State}
\begin{tabularx}{\hsize}{lX}
& \cmd{set-state! state } \\
\end{tabularx}
}
\colouredbox{blue}{
\section{Structure}
\begin{tabularx}{\hsize}{lX}
& \cmd{delay-frame exit no-loop pop-style push-style redraw start-loop } \\
\end{tabularx}
}
\colouredbox{yellow}{
\colouredbox{pink}{
\section{Transform}
\begin{tabularx}{\hsize}{lX}
& \cmd{apply-matrix pop-matrix print-matrix push-matrix reset-matrix rotate rotate-x rotate-y rotate-z scale shear-x shear-y translate } \\
Utility Macros & \cmd{with-rotation with-translation } \\
\end{tabularx}
}
\colouredbox{purple}{
\colouredbox{yellow}{
\section{Typography}
\begin{tabularx}{\hsize}{lX}
Attributes & \cmd{text-align text-leading text-mode text-size text-width } \\
Expand All @@ -178,6 +184,30 @@
\end{tabularx}
}

\colouredbox{blue2}{
\section{Applet}
\begin{tabularx}{\hsize}{lX}
Creation & \cmd{applet defapplet} \\
Control & \cmd{applet-stop applet-start applet-exit applet-close} \\
Config Keywords & \cmd{:title :size} \\
Draw Callback Keywords & \cmd{:setup :draw} \\
Mouse Callback Keywords & \cmd{:mouse-pressed :mouse-released :mouse-moved :mouse-dragged :mouse-entered :mouse-exited :mouse-clicked} \\
Keyboard Callback Keywords & \cmd{:key-pressed :key-released :key-typed } \\
Window Callback Keywords & \cmd{:focus-gained :focus-lost} \\
\end{tabularx}
}


\colouredbox{grey}{
\section{Reflection}
\begin{tabularx}{\hsize}{lX}
API Exploration & \cmd{doc-cats doc-fns doc-meths} \\
Version & \cmd{processing-version} \\
\end{tabularx}
}



\begin{flushright}
\footnotesize
\rule{0.7\linewidth}{0.25pt}
Expand Down
161 changes: 161 additions & 0 deletions docs/cheatsheet/cheat_sheet_gen.clj
@@ -0,0 +1,161 @@
(ns docs.cheat-sheet-gen
(:require [processing.core]))

(def cheat-sheet-start
"
\\documentclass[footexclude,twocolumn,DIV40,fontsize=8.7pt]{scrreprt}
% Author: Sam Aaron
% Comments, errors, suggestions: sam.aaron(at)gmail.com
% Based on Steve Tayon's excellent Clojure Cheat Sheet
% License
% Eclipse Public License v1.0
% http://opensource.org/licenses/eclipse-1.0.php
% Packages
\\usepackage[utf8]{inputenc}
\\usepackage[T1]{fontenc}
\\usepackage{textcomp}
\\usepackage[english]{babel}
\\usepackage{tabularx}
\\usepackage{lmodern}
\\renewcommand*\\familydefault{\\sfdefault}
\\usepackage[table]{xcolor}
% Set column space
\\setlength{\\columnsep}{0.25em}
% Define colours
\\definecolorset{hsb}{}{}{red,0,.4,0.95;orange,.1,.4,0.95;green,.25,.4,0.95;grey,0.0,0.0,0.1;yellow,.15,.4,0.95}
\\definecolorset{hsb}{}{}{blue,.55,.4,0.95;purple,.7,.4,0.95;pink,.8,.4,0.95;blue2,.58,.4,0.95}
\\definecolorset{hsb}{}{}{magenta,.9,.4,0.95;green2,.29,.4,0.95}
% Redefine sections
\\makeatletter
\\renewcommand{\\section}{\\@startsection{section}{1}{0mm}
{-1.7ex}{0.7ex}{\\normalfont\\large\\bfseries}}
\\renewcommand{\\subsection}{\\@startsection{subsection}{2}{0mm}
{-1.7ex}{0.5ex}{\\normalfont\\normalsize\\bfseries}}
\\makeatother
% No section numbers
\\setcounter{secnumdepth}{0}
% No indentation
\\setlength{\\parindent}{0em}
% No header and footer
\\pagestyle{empty}
% A few shortcuts
\\newcommand{\\cmd}[1] {\\frenchspacing\\texttt{\\textbf{{#1}}}}
\\newcommand{\\cmdline}[1] {
\\begin{tabularx}{\\hsize}{X}
\\texttt{\\textbf{{#1}}}
\\end{tabularx}
}
\\newcommand{\\colouredbox}[2] {
\\colorbox{#1!40}{
\\begin{minipage}{0.95\\linewidth}
{
\\rowcolors[]{1}{#1!20}{#1!10}
#2
}
\\end{minipage}
}
}
%%%%%%%% BEGIN DOC %%%%%%%%%%%%
\\begin{document}
{\\Large{\\textbf{Processing-core Cheat Sheet 1.0.0}}}
")

(def cheat-sheet-end
"
\\begin{flushright}
\\footnotesize
\\rule{0.7\\linewidth}{0.25pt}
\\verb!$Revision: 1.0.0.0, $Date: 4th March, 2012!\\\\
\\verb!Sam Aaron (sam.aaron gmail com)!
\\end{flushright}
\\end{document}
")

(def cheat-sheet-applet
"
\\colouredbox{blue1}{
\\section{Applet}
\\begin{tabularx}{\\hsize}{lX}
Creation & \\cmd{applet defapplet} \\\\
Control & \\cmd{applet-stop applet-start applet-exit applet-close} \\\\
Config Keywords & \\cmd{:title :size} \\\\
Draw Callback Keywords & \\cmd{:setup :draw} \\\\
Mouse Callback Keywords & \\cmd{:mouse-pressed :mouse-released :mouse-moved :mouse-dragged :mouse-entered :mouse-exited :mouse-clicked} \\\\
Keyboard Callback Keywords & \\cmd{:key-pressed :key-released :key-typed } \\\\
Window Callback Keywords & \\cmd{:focus-gained :focus-lost} \\\\
\\end{tabularx}
}
")

(def cheat-sheet-docs
"
\\colouredbox{grey}{
\\section{Reflection}
\\begin{tabularx}{\\hsize}{lX}
API Exploration & \\cmd{doc-cats doc-fns doc-meths} \\\\
Version & \\cmd{processing-version} \\\\
\\end{tabularx}
}
")

(defn cheat-sheet-dynamic
[]
(let [colours (cycle ["blue2" "yellow" "purple" "green" "orange" "pink" "blue" "yellow" "grey" "red" "green" "blue" "pink" "yellow"])
info (#'processing.core/sorted-category-map)
clean (fn [s] (.replaceAll s "&" "\\\\&"))]
(dorun
(map (fn [[cat-idx cat-info] colour]
(println (str "\\colouredbox{" colour "}{"))
(println (str " \\section{"(clean (:name cat-info)) "}"))
(println " \\begin{tabularx}{\\hsize}{lX}")
(when (> (count (:fns cat-info)) 0)
(print (str " & \\cmd{" ))
(dorun (map (fn [f] (print f " ")) (:fns cat-info)))
(println "} \\\\"))
(dorun
(map (fn [[subcat-idx {:keys [name fns]}]]
(when (> (count fns) 0)
(print (str " " (clean name) " & \\cmd{" ))
(dorun (map (fn [f] (print f " ")) fns))
(println "} \\\\")))
(:subcategories cat-info)))
(println " \\end{tabularx}")
(println "}"))
info colours))))



(defn mk-cheat-sheet
[]
(println cheat-sheet-start)
(cheat-sheet-dynamic)
(println cheat-sheet-applet)
(println cheat-sheet-docs)
(println cheat-sheet-end)
)
4 changes: 4 additions & 0 deletions src/processing/core.clj
Expand Up @@ -22,6 +22,8 @@

(defn
^{:requires-bindings true
:category "State"
:subcategory nil
:added "1.0"}
state
"Retrieve canvas-specific state by key. Must initially call
Expand All @@ -40,6 +42,8 @@

(defn
^{:requires-bindings true
:category "State"
:subcategory nil
:added "1.0"}
set-state!
"Set canvas-specific state. May only be called once (ideally in the
Expand Down

0 comments on commit 5825789

Please sign in to comment.