瀏覽代碼

Add graphics resources

Tanner Bennett 6 年之前
父節點
當前提交
0b914bb7c6
共有 76 個文件被更改,包括 178 次插入0 次删除
  1. 二進制
      Graphics/FLEX-Icons.sketch
  2. 二進制
      Graphics/filetypes/audio.png
  3. 二進制
      Graphics/filetypes/audio@2x.png
  4. 二進制
      Graphics/filetypes/audio@3x.png
  5. 二進制
      Graphics/filetypes/binary.png
  6. 二進制
      Graphics/filetypes/binary@2x.png
  7. 二進制
      Graphics/filetypes/binary@3x.png
  8. 二進制
      Graphics/filetypes/html.png
  9. 二進制
      Graphics/filetypes/html@2x.png
  10. 二進制
      Graphics/filetypes/html@3x.png
  11. 二進制
      Graphics/filetypes/js.png
  12. 二進制
      Graphics/filetypes/js@2x.png
  13. 二進制
      Graphics/filetypes/js@3x.png
  14. 二進制
      Graphics/filetypes/json.png
  15. 二進制
      Graphics/filetypes/json@2x.png
  16. 二進制
      Graphics/filetypes/json@3x.png
  17. 二進制
      Graphics/filetypes/old/audio.pxm
  18. 二進制
      Graphics/filetypes/old/binary.pxm
  19. 二進制
      Graphics/filetypes/old/html.pxm
  20. 二進制
      Graphics/filetypes/old/js.pxm
  21. 二進制
      Graphics/filetypes/old/json.pxm
  22. 二進制
      Graphics/filetypes/old/plist.pxm
  23. 二進制
      Graphics/filetypes/old/text.pxm
  24. 二進制
      Graphics/filetypes/old/textplain.pxm
  25. 二進制
      Graphics/filetypes/old/video.pxm
  26. 二進制
      Graphics/filetypes/plist.png
  27. 二進制
      Graphics/filetypes/plist@2x.png
  28. 二進制
      Graphics/filetypes/plist@3x.png
  29. 二進制
      Graphics/filetypes/text.png
  30. 二進制
      Graphics/filetypes/text@2x.png
  31. 二進制
      Graphics/filetypes/text@3x.png
  32. 二進制
      Graphics/filetypes/textplain.png
  33. 二進制
      Graphics/filetypes/textplain@2x.png
  34. 二進制
      Graphics/filetypes/textplain@3x.png
  35. 二進制
      Graphics/filetypes/video.png
  36. 二進制
      Graphics/filetypes/video@2x.png
  37. 二進制
      Graphics/filetypes/video@3x.png
  38. 二進制
      Graphics/filetypes/xml.png
  39. 二進制
      Graphics/filetypes/xml@2x.png
  40. 二進制
      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. 二進制
      Graphics/misc/checker.png
  45. 二進制
      Graphics/misc/checker@2x.png
  46. 二進制
      Graphics/misc/checker@3x.png
  47. 二進制
      Graphics/range-slider/fill.png
  48. 二進制
      Graphics/range-slider/fill@2x.png
  49. 二進制
      Graphics/range-slider/fill@3x.png
  50. 二進制
      Graphics/range-slider/left_handle.png
  51. 二進制
      Graphics/range-slider/left_handle@2x.png
  52. 二進制
      Graphics/range-slider/left_handle@3x.png
  53. 二進制
      Graphics/range-slider/right_handle.png
  54. 二進制
      Graphics/range-slider/right_handle@2x.png
  55. 二進制
      Graphics/range-slider/right_handle@3x.png
  56. 二進制
      Graphics/range-slider/track.png
  57. 二進制
      Graphics/range-slider/track@2x.png
  58. 二進制
      Graphics/range-slider/track@3x.png
  59. 二進制
      Graphics/toolbar/close.png
  60. 二進制
      Graphics/toolbar/close@2x.png
  61. 二進制
      Graphics/toolbar/close@3x.png
  62. 二進制
      Graphics/toolbar/dragHandle.png
  63. 二進制
      Graphics/toolbar/dragHandle@2x.png
  64. 二進制
      Graphics/toolbar/dragHandle@3x.png
  65. 二進制
      Graphics/toolbar/globe.png
  66. 二進制
      Graphics/toolbar/globe@2x.png
  67. 二進制
      Graphics/toolbar/globe@3x.png
  68. 二進制
      Graphics/toolbar/move.png
  69. 二進制
      Graphics/toolbar/move@2x.png
  70. 二進制
      Graphics/toolbar/move@3x.png
  71. 二進制
      Graphics/toolbar/select.png
  72. 二進制
      Graphics/toolbar/select@2x.png
  73. 二進制
      Graphics/toolbar/select@3x.png
  74. 二進制
      Graphics/toolbar/views.png
  75. 二進制
      Graphics/toolbar/views@2x.png
  76. 二進制
      Graphics/toolbar/views@3x.png

二進制
Graphics/FLEX-Icons.sketch


二進制
Graphics/filetypes/audio.png


二進制
Graphics/filetypes/audio@2x.png


二進制
Graphics/filetypes/audio@3x.png


二進制
Graphics/filetypes/binary.png


二進制
Graphics/filetypes/binary@2x.png


二進制
Graphics/filetypes/binary@3x.png


二進制
Graphics/filetypes/html.png


二進制
Graphics/filetypes/html@2x.png


二進制
Graphics/filetypes/html@3x.png


二進制
Graphics/filetypes/js.png


二進制
Graphics/filetypes/js@2x.png


二進制
Graphics/filetypes/js@3x.png


二進制
Graphics/filetypes/json.png


二進制
Graphics/filetypes/json@2x.png


二進制
Graphics/filetypes/json@3x.png


二進制
Graphics/filetypes/old/audio.pxm


二進制
Graphics/filetypes/old/binary.pxm


二進制
Graphics/filetypes/old/html.pxm


二進制
Graphics/filetypes/old/js.pxm


二進制
Graphics/filetypes/old/json.pxm


二進制
Graphics/filetypes/old/plist.pxm


二進制
Graphics/filetypes/old/text.pxm


二進制
Graphics/filetypes/old/textplain.pxm


二進制
Graphics/filetypes/old/video.pxm


二進制
Graphics/filetypes/plist.png


二進制
Graphics/filetypes/plist@2x.png


二進制
Graphics/filetypes/plist@3x.png


二進制
Graphics/filetypes/text.png


二進制
Graphics/filetypes/text@2x.png


二進制
Graphics/filetypes/text@3x.png


二進制
Graphics/filetypes/textplain.png


二進制
Graphics/filetypes/textplain@2x.png


二進制
Graphics/filetypes/textplain@3x.png


二進制
Graphics/filetypes/video.png


二進制
Graphics/filetypes/video@2x.png


二進制
Graphics/filetypes/video@3x.png


二進制
Graphics/filetypes/xml.png


二進制
Graphics/filetypes/xml@2x.png


二進制
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

二進制
Graphics/misc/checker.png


二進制
Graphics/misc/checker@2x.png


二進制
Graphics/misc/checker@3x.png


二進制
Graphics/range-slider/fill.png


二進制
Graphics/range-slider/fill@2x.png


二進制
Graphics/range-slider/fill@3x.png


二進制
Graphics/range-slider/left_handle.png


二進制
Graphics/range-slider/left_handle@2x.png


二進制
Graphics/range-slider/left_handle@3x.png


二進制
Graphics/range-slider/right_handle.png


二進制
Graphics/range-slider/right_handle@2x.png


二進制
Graphics/range-slider/right_handle@3x.png


二進制
Graphics/range-slider/track.png


二進制
Graphics/range-slider/track@2x.png


二進制
Graphics/range-slider/track@3x.png


二進制
Graphics/toolbar/close.png


二進制
Graphics/toolbar/close@2x.png


二進制
Graphics/toolbar/close@3x.png


二進制
Graphics/toolbar/dragHandle.png


二進制
Graphics/toolbar/dragHandle@2x.png


二進制
Graphics/toolbar/dragHandle@3x.png


二進制
Graphics/toolbar/globe.png


二進制
Graphics/toolbar/globe@2x.png


二進制
Graphics/toolbar/globe@3x.png


二進制
Graphics/toolbar/move.png


二進制
Graphics/toolbar/move@2x.png


二進制
Graphics/toolbar/move@3x.png


二進制
Graphics/toolbar/select.png


二進制
Graphics/toolbar/select@2x.png


二進制
Graphics/toolbar/select@3x.png


二進制
Graphics/toolbar/views.png


二進制
Graphics/toolbar/views@2x.png


二進制
Graphics/toolbar/views@3x.png