Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

GMT_RGBchart.sh 2.5 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
  1. #!/usr/bin/env bash
  2. #
  3. # Plots a page of all 555 unique named colors
  4. # Usage: GMT_RGBchart.sh <size>
  5. # where <size> is the page size. Use either: ledger, a4, or letter
  6. # This produces the file GMT_RGBchart_<size>.ps
  7. SIZE=$1
  8. COL=16
  9. ROW=35
  10. if [ "X"$SIZE"" = "Xletter" ] ; then
  11. WIDTH=10.5
  12. HEIGHT=8.0
  13. ORIENT=landscape
  14. elif [ "X"$SIZE"" = "Xa4" ] ; then
  15. WIDTH=11.2
  16. HEIGHT=7.8
  17. else
  18. SIZE=tabloid
  19. WIDTH=16.5
  20. HEIGHT=10.5
  21. fi
  22. ps=GMT_RGBchart_$SIZE.ps
  23. allinfo=allinfo.tmp
  24. cpt=lookup.cpt
  25. rects=rects.tmp
  26. whitetags=whitetags.tmp
  27. blacktags=blacktags.tmp
  28. labels=labels.tmp
  29. gmt set PS_MEDIA $SIZE PS_PAGE_ORIENTATION landscape
  30. rectheight=0.56
  31. W=$(gmt math -Q $WIDTH $COL DIV 0.95 MUL =)
  32. H=$(gmt math -Q $HEIGHT $ROW DIV $rectheight MUL =)
  33. textheight=$(gmt math -Q 1 $rectheight SUB =)
  34. fontsize=$(gmt math -Q $HEIGHT $ROW DIV $rectheight MUL 0.6 MUL 72 MUL =)
  35. fontsizeL=$(gmt math -Q $HEIGHT $ROW DIV $textheight MUL 0.7 MUL 72 MUL =)
  36. # Produce $allinfo from color and name files
  37. paste ${GMT_SOURCE_DIR}/src/gmt_color_rgb.h ${GMT_SOURCE_DIR}/src/gmt_colornames.h | tr '{,}"\r' ' ' > Colors.txt
  38. egrep -v "^#|grey" Colors.txt | $AWK -v COL=$COL -v ROW=$ROW \
  39. 'BEGIN{col=0;row=0}{if(col==0&&row<2){col++};if ($1 == $2 && $2 == $3) {printf "%s", $1} else {printf "%s/%s/%s", $1, $2,
  40. $3};printf " %g %s %g %g\n",0.299*$1+0.587*$2+0.114*$3,$4,col,row;col++;if(col==COL){col=0;row++}}' > $allinfo
  41. # Produce temp files from $allinfo
  42. $AWK '{printf "%g %s %g %s\n", NR-0.5, $1, NR+0.5, $1}' $allinfo > $cpt
  43. $AWK -v h=$rectheight -v W=$W -v H=$H '{printf "%g %g %g %g %g\n",$4+0.5,$5+1-0.5*h,NR,W,H}' $allinfo > $rects
  44. $AWK -v h=$rectheight -v fs=$fontsize '{if ($2 <= 127) printf "%g %g %gp,1 %s\n",$4+0.5,$5+1-0.5*h,fs,$1}' $allinfo > $whitetags
  45. $AWK -v h=$rectheight -v fs=$fontsize '{if ($2 > 127) printf "%g %g %gp,1 %s\n",$4+0.5,$5+1-0.5*h,fs,$1}' $allinfo > $blacktags
  46. $AWK -v h=$textheight -v fs=$fontsizeL '{printf "%g %g %gp,1 @#%s@#\n",$4+0.5,$5+0.6*h,fs,$3}' $allinfo > $labels
  47. # Plot all tiles and texts
  48. gmt psxy -R0/$COL/0/$ROW -JX$WIDTH/-$HEIGHT -X0.25i -Y0.25i -B0 -C$cpt -Sri -W $rects -K > $ps
  49. gmt pstext -R -J -O -K $labels -F+f --FONT=black >> $ps
  50. gmt pstext -R -J -O -K $blacktags -F+f --FONT=black >> $ps
  51. gmt pstext -R -J -O -K $whitetags -F+f --FONT=white >> $ps
  52. # Put logo in top left corner
  53. gmt logo -R -J -O -K -Dg0.5/1+jMC+w$W >> $ps
  54. height=$(gmt math -Q $HEIGHT $ROW DIV =)
  55. gmt pslegend -O -R -J -DjBR+w$WIDTH >> $ps <<END
  56. L ${fontsizeL}p,Helvetica-Bold R Values are R/G/B. Names are case-insensitive.
  57. L ${fontsizeL}p,Helvetica-Bold R Optionally, use GREY instead of GRAY.
  58. END
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...