cryptopunks-gui 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3c2dbdaae667d1a222c8d3484dce2903b6a7636fe8445287124c3fa9293f6ab3
4
- data.tar.gz: d4066e8e07533ac59630f345cbd7496abffdbbcccee541100716e582bd0a5f03
3
+ metadata.gz: f1f6eb5c90f0fa4a2d0c5abd70d67da17071a8f72cdbcbb9c43eaa3c80962e4d
4
+ data.tar.gz: 1713179be7b0fee8032b3a7b6b8a71482189919464b4d010b23b01e6efcf7efc
5
5
  SHA512:
6
- metadata.gz: 47b5b1513fb6328af05d4adf9bdff57598596b747f3257c05d3fc7f6969cb06e02bf7d311442d71d890535e777e545765a66802773d898ed72bd39beedc1a6d7
7
- data.tar.gz: 6c61ff9deeb391131f9a94da5c217afe6a228763aa7427bac374a99dde1d3af8cf84794166faa5206dad9325a9b274ef54546bedd9b9b89094c5dee6408e236c
6
+ metadata.gz: f1b8fab3f02ae9547c4ce7c5dcae6107c690af5db3d7a9c1f18e837293b086a2e3ee43e8dcd978a1a97b679f14af08f057435e1b4cd5830539877671d2e7317f
7
+ data.tar.gz: 3976e2ef62acb15532a352c9b7a5de4baad23f293b5c0647b0a90d450690ad1f2a04019ef8e73bdecf3dfde89373baa8a642195b2fc4f7df5caedac3c7a090b5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Change Log
2
2
 
3
+ ## 0.0.3
4
+
5
+ - Style support (e.g. mirror, flip, sketch, led)
6
+
3
7
  ## 0.0.2
4
8
 
5
9
  - Palette support (e.g. grayscale or sepia)
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # <img src="https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/icons/cryptopunks-gui.png" height=85 /> CryptoPunks GUI 0.0.2
1
+ # <img src="https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/icons/cryptopunks-gui.png" height=85 /> CryptoPunks GUI 0.0.3
2
2
  ## Simplified Minting
3
3
  [![Gem Version](https://badge.fury.io/rb/cryptopunks-gui.svg)](http://badge.fury.io/rb/cryptopunks-gui)
4
4
 
@@ -25,7 +25,7 @@ You can use CryptoPunks GUI via gem or via cloning repository.
25
25
  Run:
26
26
 
27
27
  ```
28
- gem install cryptopunks-gui -v0.0.2
28
+ gem install cryptopunks-gui -v0.0.3
29
29
  ```
30
30
 
31
31
  Afterwards, run app via:
@@ -85,7 +85,27 @@ Change zoom to enlarge punk to your liking.
85
85
 
86
86
  Change palette to get different punk colors.
87
87
 
88
- ![Screenshot](/screenshots/cryptopunks-gui-screenshot-different-palette.png)
88
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-palette-standard.png)
89
+
90
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-palette-sepia.png)
91
+
92
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-palette-blue.png)
93
+
94
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-palette-false.png)
95
+
96
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-palette-grayscale.png)
97
+
98
+ ### Style
99
+
100
+ Change style to get different punk looks.
101
+
102
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-style-mirror.png)
103
+
104
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-style-flip.png)
105
+
106
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-style-led.png)
107
+
108
+ ![Screenshot](/screenshots/cryptopunks-gui-screenshot-style-sketch.png)
89
109
 
90
110
  ## TODO
91
111
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,5 +1,6 @@
1
1
  require 'glimmer-dsl-tk'
2
2
  require 'cryptopunks'
3
+ require 'facets'
3
4
  require 'fileutils'
4
5
  require 'net/http'
5
6
  require 'uri'
@@ -10,43 +11,69 @@ class CryptopunksGui
10
11
  include Glimmer
11
12
 
12
13
  PALETTES = ['Standard'] + (Palette8bit.constants).map(&:name).map {|palette| palette.split('_').map(&:capitalize).join(' ')}.reject { |palette| palette.include?(' ') }
14
+ STYLES = ['Normal', 'Flip', 'Mirror', 'Led', 'Sketch']
13
15
 
14
- attr_accessor :punk_index, :zoom, :palette
16
+ attr_accessor :punk_index, :zoom, :palette, :style
15
17
 
16
18
  def initialize
19
+ initialize_punks
20
+ initialize_defaults
21
+ observe_image_attribute_changes
22
+ create_gui
23
+ self.punk_index = 0
24
+ @root.open
25
+ end
26
+
27
+ def palette_options
28
+ PALETTES
29
+ end
30
+
31
+ def style_options
32
+ STYLES
33
+ end
34
+
35
+ def initialize_punks
17
36
  @punk_directory = File.join(Dir.home, '.cryptopunks')
18
37
  FileUtils.mkdir_p(@punk_directory)
19
38
  @punk_file = File.join(@punk_directory, 'punks.png')
20
39
  File.write(@punk_file, Net::HTTP.get(URI('https://raw.githubusercontent.com/larvalabs/cryptopunks/master/punks.png'))) unless File.exist?(@punk_file)
21
40
  @punks = Punks::Image::Composite.read(@punk_file)
41
+ end
42
+
43
+ def initialize_defaults
22
44
  @zoom = 12
23
- @palette = 'Standard'
24
-
25
- observer = Glimmer::DataBinding::Observer.proc do
26
- generate_image
27
- end
45
+ @palette = PALETTES.first
46
+ @style = STYLES.first
47
+ end
48
+
49
+ def observe_image_attribute_changes
50
+ observer = Glimmer::DataBinding::Observer.proc { generate_image }
28
51
  observer.observe(self, :punk_index)
29
52
  observer.observe(self, :zoom)
30
53
  observer.observe(self, :palette)
31
-
32
- create_gui
33
- self.punk_index = 0
34
- @root.open
35
- end
36
-
37
- def palette_options
38
- PALETTES
54
+ observer.observe(self, :style)
39
55
  end
40
56
 
41
57
  def generate_image
42
- image_location = File.join(@punk_directory, "punk-#{@punk_index}#{"x#{@zoom}" if @zoom.to_i > 1}#{"-#{@palette.downcase.gsub(' ', '_')}" if @palette != 'Standard'}.png")
58
+ image_location = File.join(@punk_directory, "punk-#{@punk_index}#{"x#{@zoom}" if @zoom.to_i > 1}#{"-#{@palette.underscore}" if @palette != PALETTES.first}#{"-#{@style.underscore}" if @style != STYLES.first}.png")
43
59
  puts "Writing punk image to #{image_location}"
44
60
  selected_punk = @punks[@punk_index.to_i]
45
- selected_punk = selected_punk.change_palette8bit(Palette8bit.const_get(@palette.gsub(' ', '_').upcase.to_sym)) if @palette != 'Standard'
61
+ selected_punk = selected_punk.change_palette8bit(Palette8bit.const_get(@palette.gsub(' ', '_').upcase.to_sym)) if @palette != PALETTES.first
62
+ @original_zoom = @zoom
63
+ if @style != STYLES.first
64
+ selected_punk = selected_punk.send(@style.underscore)
65
+ if @style != @previous_style
66
+ @zoom = 12 if @style == 'Flip' && !['Normal', 'Mirror'].include?(@previous_style)
67
+ @zoom = 12 if @style == 'Mirror' && !['Normal', 'Flip'].include?(@previous_style)
68
+ @zoom = 2 if @style == 'Sketch'
69
+ @zoom = 1 if @style == 'Led'
70
+ end
71
+ end
46
72
  selected_punk = selected_punk.zoom(@zoom.to_i)
47
73
  selected_punk.save(image_location)
48
74
  @image_label.image = image_location
49
75
  @message_entry.text = image_location
76
+ notify_observers(:zoom) if @zoom != @original_zoom
50
77
  end
51
78
 
52
79
  def create_gui
@@ -82,11 +109,18 @@ class CryptopunksGui
82
109
  text 'Palette:'
83
110
  }
84
111
  combobox {
85
- # TODO (mirrored, grayscale, sepia, etc...)
86
- readonly true # this applies to text editing only (item selection still triggers a write to model)
112
+ readonly true
87
113
  text <=> [self, :palette]
88
114
  }
89
115
 
116
+ label {
117
+ text 'Style:'
118
+ }
119
+ combobox {
120
+ readonly true
121
+ text <=> [self, :style, before_write: ->(v) {@previous_style = @style}]
122
+ }
123
+
90
124
  label {
91
125
  text 'Output Location:'
92
126
  }
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Juwelier::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: cryptopunks-gui 0.0.2 ruby app
5
+ # stub: cryptopunks-gui 0.0.3 ruby app
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "cryptopunks-gui".freeze
9
- s.version = "0.0.2"
9
+ s.version = "0.0.3"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["app".freeze]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryptopunks-gui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Maleh