Browse Source

Add graphics resources

Tanner Bennett 4 years ago
parent
commit
0b914bb7c6
76 changed files with 178 additions and 0 deletions
  1. BIN
      Graphics/FLEX-Icons.sketch
  2. BIN
      Graphics/filetypes/audio.png
  3. BIN
      Graphics/filetypes/audio@2x.png
  4. BIN
      Graphics/filetypes/audio@3x.png
  5. BIN
      Graphics/filetypes/binary.png
  6. BIN
      Graphics/filetypes/binary@2x.png
  7. BIN
      Graphics/filetypes/binary@3x.png
  8. BIN
      Graphics/filetypes/html.png
  9. BIN
      Graphics/filetypes/html@2x.png
  10. BIN
      Graphics/filetypes/html@3x.png
  11. BIN
      Graphics/filetypes/js.png
  12. BIN
      Graphics/filetypes/js@2x.png
  13. BIN
      Graphics/filetypes/js@3x.png
  14. BIN
      Graphics/filetypes/json.png
  15. BIN
      Graphics/filetypes/json@2x.png
  16. BIN
      Graphics/filetypes/json@3x.png
  17. BIN
      Graphics/filetypes/old/audio.pxm
  18. BIN
      Graphics/filetypes/old/binary.pxm
  19. BIN
      Graphics/filetypes/old/html.pxm
  20. BIN
      Graphics/filetypes/old/js.pxm
  21. BIN
      Graphics/filetypes/old/json.pxm
  22. BIN
      Graphics/filetypes/old/plist.pxm
  23. BIN
      Graphics/filetypes/old/text.pxm
  24. BIN
      Graphics/filetypes/old/textplain.pxm
  25. BIN
      Graphics/filetypes/old/video.pxm
  26. BIN
      Graphics/filetypes/plist.png
  27. BIN
      Graphics/filetypes/plist@2x.png
  28. BIN
      Graphics/filetypes/plist@3x.png
  29. BIN
      Graphics/filetypes/text.png
  30. BIN
      Graphics/filetypes/text@2x.png
  31. BIN
      Graphics/filetypes/text@3x.png
  32. BIN
      Graphics/filetypes/textplain.png
  33. BIN
      Graphics/filetypes/textplain@2x.png
  34. BIN
      Graphics/filetypes/textplain@3x.png
  35. BIN
      Graphics/filetypes/video.png
  36. BIN
      Graphics/filetypes/video@2x.png
  37. BIN
      Graphics/filetypes/video@3x.png
  38. BIN
      Graphics/filetypes/xml.png
  39. BIN
      Graphics/filetypes/xml@2x.png
  40. BIN
      Graphics/filetypes/xml@3x.png
  41. 141 0
      Graphics/image_to_code.py
  42. 22 0
      Graphics/images_to_hex.sh
  43. 15 0
      Graphics/iterate_hex_to_pasteboard.sh
  44. BIN
      Graphics/misc/checker.png
  45. BIN
      Graphics/misc/checker@2x.png
  46. BIN
      Graphics/misc/checker@3x.png
  47. BIN
      Graphics/range-slider/fill.png
  48. BIN
      Graphics/range-slider/fill@2x.png
  49. BIN
      Graphics/range-slider/fill@3x.png
  50. BIN
      Graphics/range-slider/left_handle.png
  51. BIN
      Graphics/range-slider/left_handle@2x.png
  52. BIN
      Graphics/range-slider/left_handle@3x.png
  53. BIN
      Graphics/range-slider/right_handle.png
  54. BIN
      Graphics/range-slider/right_handle@2x.png
  55. BIN
      Graphics/range-slider/right_handle@3x.png
  56. BIN
      Graphics/range-slider/track.png
  57. BIN
      Graphics/range-slider/track@2x.png
  58. BIN
      Graphics/range-slider/track@3x.png
  59. BIN
      Graphics/toolbar/close.png
  60. BIN
      Graphics/toolbar/close@2x.png
  61. BIN
      Graphics/toolbar/close@3x.png
  62. BIN
      Graphics/toolbar/dragHandle.png
  63. BIN
      Graphics/toolbar/dragHandle@2x.png
  64. BIN
      Graphics/toolbar/dragHandle@3x.png
  65. BIN
      Graphics/toolbar/globe.png
  66. BIN
      Graphics/toolbar/globe@2x.png
  67. BIN
      Graphics/toolbar/globe@3x.png
  68. BIN
      Graphics/toolbar/move.png
  69. BIN
      Graphics/toolbar/move@2x.png
  70. BIN
      Graphics/toolbar/move@3x.png
  71. BIN
      Graphics/toolbar/select.png
  72. BIN
      Graphics/toolbar/select@2x.png
  73. BIN
      Graphics/toolbar/select@3x.png
  74. BIN
      Graphics/toolbar/views.png
  75. BIN
      Graphics/toolbar/views@2x.png
  76. BIN
      Graphics/toolbar/views@3x.png

BIN
Graphics/FLEX-Icons.sketch


BIN
Graphics/filetypes/audio.png


BIN
Graphics/filetypes/audio@2x.png


BIN
Graphics/filetypes/audio@3x.png


BIN
Graphics/filetypes/binary.png


BIN
Graphics/filetypes/binary@2x.png


BIN
Graphics/filetypes/binary@3x.png


BIN
Graphics/filetypes/html.png


BIN
Graphics/filetypes/html@2x.png


BIN
Graphics/filetypes/html@3x.png


BIN
Graphics/filetypes/js.png


BIN
Graphics/filetypes/js@2x.png


BIN
Graphics/filetypes/js@3x.png


BIN
Graphics/filetypes/json.png


BIN
Graphics/filetypes/json@2x.png


BIN
Graphics/filetypes/json@3x.png


BIN
Graphics/filetypes/old/audio.pxm


BIN
Graphics/filetypes/old/binary.pxm


BIN
Graphics/filetypes/old/html.pxm


BIN
Graphics/filetypes/old/js.pxm


BIN
Graphics/filetypes/old/json.pxm


BIN
Graphics/filetypes/old/plist.pxm


BIN
Graphics/filetypes/old/text.pxm


BIN
Graphics/filetypes/old/textplain.pxm


BIN
Graphics/filetypes/old/video.pxm


BIN
Graphics/filetypes/plist.png


BIN
Graphics/filetypes/plist@2x.png


BIN
Graphics/filetypes/plist@3x.png


BIN
Graphics/filetypes/text.png


BIN
Graphics/filetypes/text@2x.png


BIN
Graphics/filetypes/text@3x.png


BIN
Graphics/filetypes/textplain.png


BIN
Graphics/filetypes/textplain@2x.png


BIN
Graphics/filetypes/textplain@3x.png


BIN
Graphics/filetypes/video.png


BIN
Graphics/filetypes/video@2x.png


BIN
Graphics/filetypes/video@3x.png


BIN
Graphics/filetypes/xml.png


BIN
Graphics/filetypes/xml@2x.png


BIN
Graphics/filetypes/xml@3x.png


+ 141 - 0
Graphics/image_to_code.py

@@ -0,0 +1,141 @@
+#!/usr/bin/python
+
+import os
+import sys
+import getopt
+
+headerTemplate = """/*
+ * Copyright 2010-present Facebook.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/*
+ * This file was built by running
+ *
+ *   ./image_to_code.py %(args)s
+ *
+ * Thanks to the Facebook SDK for providing the base for this script
+ */
+"""
+
+def bytes_from_file(filename, chunksize=8192):
+  with open(filename, "rb") as f:
+    while True:
+      chunk = f.read(chunksize)
+      if chunk:
+        for b in chunk:
+          yield b
+      else:
+        break
+
+def write_header_file(header, className, outputFile):
+  with open(outputFile, "w") as f:
+    f.write(header)
+    f.write("""
+#import <Foundation/Foundation.h>
+#import <UIKit/UIKit.h>
+
+""")
+    f.write("@interface " + className + " : NSObject\n\n")
+    f.write("+ (UIImage *)image;\n\n")
+    f.write("@end")
+
+def write_implementation_file(inputFile, header, className, outputFile):
+  formattedBytes = ["0x{0:02x}".format(ord(x)) for x in bytes_from_file(inputFile)]
+  with open(outputFile, "w") as f:
+    f.write(header)
+    f.write("\n")
+    f.write("#import \"" + className + ".h\"\n")
+    f.write("#import \"FLEXImageLoader.h\"\n\n")
+
+    # Write standard bytes out
+    f.write("const Byte " + className + "_standard[] = {\n")
+    f.write(", ".join(formattedBytes))
+    f.write("\n")
+    f.write("};\n")
+
+    
+    # Write retina if present
+    useRetina = True
+    try:
+      (name, ext) = inputFile.rsplit(".", 1)
+      name = name + "@2x"
+      formattedBytes = ["0x{0:02x}".format(ord(x)) for x in bytes_from_file(name + "." + ext)]
+      f.write("const Byte " + className + "_retina[] = {\n")
+      f.write(", ".join(formattedBytes))
+      f.write("\n")
+      f.write("};\n")
+    except IOError:
+      useRetina = False
+
+    # Enter the bundle path override
+    # strip of the PNG that was added for our class name for the resource name
+    bundlepath = "@\"" + "FacebookSDKImages/" + className[0:-3] + ".png\""
+
+    f.write("\n")
+    f.write("@implementation " + className + "\n\n")
+    f.write("+ (UIImage *)image {\n")
+    f.write("    return [FLEXImageLoader imageFromBytes:" + className + "_standard ")
+    f.write("length:sizeof(" + className + "_standard)/sizeof(" + className + "_standard[0]) ")
+    if useRetina:
+      f.write("fromRetinaBytes:" + className + "_retina ")
+      f.write("retinaLength:sizeof(" + className + "_retina)/sizeof(" + className + "_retina[0])];\n")
+    else:
+      f.write("fromRetinaBytes:NULL ")
+      f.write("retinaLength:0];\n")
+    f.write("}\n")
+    f.write("@end\n")
+
+    print(", ".join(formattedBytes))
+
+def main(argv):
+  inputFile = ''
+  outputClass = 'ImageCode'
+  outputDir = os.getcwd()
+
+  try:
+    opts, args = getopt.getopt(argv,"hi:c:o:")
+  except getopt.GetoptError:
+    print('image_to_code.py -i <inputFile> [-c <class>] [-o <outputDir>]')
+    sys.exit(2)
+  for opt, arg in opts:
+    if opt == '-h':
+      print('image_to_code.py -i <inputFile> [-c <class>] [-o <outputDir>]')
+      sys.exit()
+    elif opt == '-i':
+      inputFile = arg
+    elif opt == '-c':
+      outputClass = arg
+    elif opt in '-o':
+      outputDir = arg
+
+  # Build file headers
+  header = headerTemplate % {"args" : " ".join(argv)}
+
+  # outputClass needs to add PNG as part of it
+  outputClass = outputClass + "PNG"
+
+  # Build the output base filename
+  outputFileBase = outputDir + "/" + outputClass
+
+  # Build .h file
+  outputFile = outputFileBase + ".h"
+  write_header_file(header, outputClass, outputFile)
+
+  # Build .m file
+  outputFile = outputFileBase + ".m"
+  write_implementation_file(inputFile, header, outputClass, outputFile)
+
+if __name__ == "__main__":
+   main(sys.argv[1:])

+ 22 - 0
Graphics/images_to_hex.sh

@@ -0,0 +1,22 @@
+#!/usr/bin/bash
+
+# Converts every image *.png to *.txt as an ASCII hex representation of the image.
+#
+# This script simply runs image_to_code.py on each of the folders containing
+# our images and writes the hex of each image to a text file. Instead of updating
+# the original script, I left it to be generic as it was originally intended
+# in case someone else finds it useful. The original python script outputs
+# header and implementation files, which this script removes after it is run.
+
+allImageFolders="filetypes range-slider toolbar misc"
+for dir in $allImageFolders; do
+    rm $dir/*.txt
+    for image in `ls $dir`; do
+        name=`basename $image .png`
+        outfile=$dir/$name.txt
+        echo "Output file: $outfile"
+        ./image_to_code.py -i $dir/$image -c $name > "$outfile"
+    done
+done
+
+rm -rf *PNG.[hm]

+ 15 - 0
Graphics/iterate_hex_to_pasteboard.sh

@@ -0,0 +1,15 @@
+#!/usr/bin/bash
+
+# I use this script to loop over the contents of each text file
+# produced by images_to_hex.sh and copy it to the clipboard.
+# This makes adding or updating graphics to the project faster.
+#
+# You can edit the $folder variable below to work in a certain
+# subdirectory, and you can edit the wildcard expression below
+# to only work with a certain image size, like "*@3x.txt"
+
+folder=.
+for file in `find $folder -type f -name "*.txt"`; do
+    cat $file | pbcopy
+    read -p "Copied $file, press any key to continue..."
+done

BIN
Graphics/misc/checker.png


BIN
Graphics/misc/checker@2x.png


BIN
Graphics/misc/checker@3x.png


BIN
Graphics/range-slider/fill.png


BIN
Graphics/range-slider/fill@2x.png


BIN
Graphics/range-slider/fill@3x.png


BIN
Graphics/range-slider/left_handle.png


BIN
Graphics/range-slider/left_handle@2x.png


BIN
Graphics/range-slider/left_handle@3x.png


BIN
Graphics/range-slider/right_handle.png


BIN
Graphics/range-slider/right_handle@2x.png


BIN
Graphics/range-slider/right_handle@3x.png


BIN
Graphics/range-slider/track.png


BIN
Graphics/range-slider/track@2x.png


BIN
Graphics/range-slider/track@3x.png


BIN
Graphics/toolbar/close.png


BIN
Graphics/toolbar/close@2x.png


BIN
Graphics/toolbar/close@3x.png


BIN
Graphics/toolbar/dragHandle.png


BIN
Graphics/toolbar/dragHandle@2x.png


BIN
Graphics/toolbar/dragHandle@3x.png


BIN
Graphics/toolbar/globe.png


BIN
Graphics/toolbar/globe@2x.png


BIN
Graphics/toolbar/globe@3x.png


BIN
Graphics/toolbar/move.png


BIN
Graphics/toolbar/move@2x.png


BIN
Graphics/toolbar/move@3x.png


BIN
Graphics/toolbar/select.png


BIN
Graphics/toolbar/select@2x.png


BIN
Graphics/toolbar/select@3x.png


BIN
Graphics/toolbar/views.png


BIN
Graphics/toolbar/views@2x.png


BIN
Graphics/toolbar/views@3x.png