cryptopunks-gui 0.0.10 → 0.0.14
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 +4 -4
- data/CHANGELOG.md +24 -0
- data/LICENSE.txt +1 -1
- data/README.md +16 -52
- data/VERSION +1 -1
- data/app/cryptopunks_gui.rb +17 -319
- data/app/model/image.rb +187 -0
- data/app/view/help_dialog.rb +31 -0
- data/app/view/image_frame.rb +145 -0
- data/app/view/menu_bar.rb +88 -0
- data/app/view/preferences_dialog.rb +174 -0
- data/app/view/style_options_frame.rb +60 -0
- data/bin/cryptopunks-gui +0 -0
- data/cryptopunks-gui.gemspec +68 -67
- metadata +15 -13
- data/bin/cryptopunks-mac-gui +0 -8
- data/bin/cryptopunks-mac-gui.rb +0 -8
- data/bin/package-mac +0 -8
- data/bin/package-mac-app +0 -5
- data/bin/package-mac-dmg +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11b7dbad37423ad303ed7584a4859b820cf609157b07aebfc69845e155a8e85d
|
|
4
|
+
data.tar.gz: a09d1fe0fe847726c50c25d226d075d258e7cd26039d15e88decfedfc5e8fcb3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 129fc97f012dd2c6a0593ee8a5769bcc23786d87ee35553565ada057c3faac1c61f2e5b910af3ed07413093c6a32019d68564391476e7300f7b54be826f03311
|
|
7
|
+
data.tar.gz: 558d47cfe642d0cc010ece09cb7b93bfa0299e47865fb293e48ff8c166ce2876daa8ea6f6ae45a28575e666c3f3916ff3331cf1f2ce91d6f782b63c480a4b2c4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 0.0.14
|
|
4
|
+
|
|
5
|
+
- Fix PNG signature not found issue on Windows by writing images as binary files (`chunky_png-1.4.0/lib/chunky_png/datastream.rb:107:in verify_signature!': PNG signature not found, found "\\x89PNG\\r\\r\\n\\x1A" instead of "\\x89PNG\\r\\n\\x1A\\n"! (ChunkyPNG::SignatureMismatch)`)
|
|
6
|
+
- Fix regression issue with image index allowed out of bounds when changing to a collection with less images than current collection
|
|
7
|
+
|
|
8
|
+
## 0.0.13
|
|
9
|
+
|
|
10
|
+
- Support older Ruby versions down to 2.7.2 by fixing an issue with not having `#name` method on `Symbol`
|
|
11
|
+
|
|
12
|
+
## 0.0.12
|
|
13
|
+
|
|
14
|
+
- Upgrade to glimmer-dsl-tk 0.0.46
|
|
15
|
+
- File & Help Menus
|
|
16
|
+
- Update COLLECTIONS_YAML_URL to point to cryptopunksnotdead repository (recently moved there)
|
|
17
|
+
- Add 'Mirror', 'Flip', 'Led' and 'Sketch' details (e.g. spacing or line) to output file name (e.g. '...-mirror.png')
|
|
18
|
+
- Fix issue with allowing out of bounds image index when entering index that is equal to count of images in a collection (off by 1 error)
|
|
19
|
+
- Fix written file name for downloaded sprites (was excluding .png before)
|
|
20
|
+
- Fix issue with @punk_directory mistakenly referenced after being removed through refactoring
|
|
21
|
+
|
|
22
|
+
## 0.0.11
|
|
23
|
+
|
|
24
|
+
- Support configuring default collections through a web hosted yaml file at: https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks-gui/master/cryptopunks-collections.yml
|
|
25
|
+
- New Green Punks, Clown Punks, and Bubble Gum Punks collections
|
|
26
|
+
|
|
3
27
|
## 0.0.10
|
|
4
28
|
|
|
5
29
|
- Fix issue with cryptopunks GUI erroring when cancelling selection of a new output location (or getting blocked by OS for security reasons)
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# <img src="https://raw.githubusercontent.com/
|
|
1
|
+
# <img src="https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks-gui/master/icons/cryptopunks-gui.png" height=85 /> CryptoPunks GUI 0.0.14
|
|
2
2
|
## Simplified Minting
|
|
3
3
|
[](http://badge.fury.io/rb/cryptopunks-gui)
|
|
4
4
|
|
|
5
|
-
This is a Graphical User Interface for the
|
|
5
|
+
This is a Graphical User Interface for the [cryptopunks Ruby gem](https://github.com/cryptopunksnotdead/cryptopunks/tree/master/cryptopunks).
|
|
6
6
|
|
|
7
7
|
It automatically downloads image collection sprites on first use (e.g. `punks.png` from https://github.com/larvalabs/cryptopunks).
|
|
8
8
|
|
|
@@ -10,10 +10,6 @@ Minted cryptopunks are stored at `~/cryptopunks/` by default ([output location c
|
|
|
10
10
|
|
|
11
11
|

|
|
12
12
|
|
|
13
|
-
[<img src="https://raw.githubusercontent.com/AndyObtiva/cryptopunks-gui/master/icons/cryptopunks-gui.png" height=40 /> Download DMG installer for Mac (Catalina x64 and older)](https://www.dropbox.com/s/gfh7e9osw30sjiq/CryptoPunks%20GUI.dmg?dl=1)
|
|
14
|
-
|
|
15
|
-
If your machine is incompatible with the downloadable DMG package, you may follow [Packaging](#packaging) instructions to produce your own machine compatible installer.
|
|
16
|
-
|
|
17
13
|
## Prerequities
|
|
18
14
|
|
|
19
15
|
- [Tcl/Tk (ActiveTcl)](https://tkdocs.com/tutorial/install.html)
|
|
@@ -22,14 +18,14 @@ If your machine is incompatible with the downloadable DMG package, you may follo
|
|
|
22
18
|
|
|
23
19
|
## Setup
|
|
24
20
|
|
|
25
|
-
You can use CryptoPunks GUI via gem or via cloning repository.
|
|
21
|
+
You can use CryptoPunks GUI via gem or via cloning repository (if you encounter any issues, please try older versions of the gem and report the issues encountered).
|
|
26
22
|
|
|
27
23
|
### Gem
|
|
28
24
|
|
|
29
25
|
Run:
|
|
30
26
|
|
|
31
27
|
```
|
|
32
|
-
gem install cryptopunks-gui -v0.0.
|
|
28
|
+
gem install cryptopunks-gui -v0.0.14
|
|
33
29
|
```
|
|
34
30
|
|
|
35
31
|
Afterwards, run app via:
|
|
@@ -43,7 +39,7 @@ cryptopunks-gui
|
|
|
43
39
|
Clone repository:
|
|
44
40
|
|
|
45
41
|
```
|
|
46
|
-
git clone https://github.com/
|
|
42
|
+
git clone https://github.com/cryptopunksnotdead/cryptopunks-gui.git
|
|
47
43
|
```
|
|
48
44
|
|
|
49
45
|
Enter directory:
|
|
@@ -77,7 +73,13 @@ ruby app/cryptopunks_gui.rb
|
|
|
77
73
|
|
|
78
74
|
Change collection to pick a different collection of images.
|
|
79
75
|
|
|
80
|
-
|
|
76
|
+

|
|
77
|
+
|
|
78
|
+
Image collections are configured in [cryptopunks-collections.yml](/cryptopunks-collections.yml).
|
|
79
|
+
|
|
80
|
+
If you cloned the project locally, you may edit [cryptopunks-collections.yml](/cryptopunks-collections.yml) to add/remove collections.
|
|
81
|
+
|
|
82
|
+
There are 41 available collections (mostly from https://github.com/cryptopunksnotdead/awesome-24px):
|
|
81
83
|
- [Punks](https://raw.githubusercontent.com/larvalabs/cryptopunks/master/punks.png) 
|
|
82
84
|
- [Mohawks](https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/mohawks.png) 
|
|
83
85
|
- [Blondies](https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/blondies.png) 
|
|
@@ -85,6 +87,9 @@ There are currently 38 available collections (from https://github.com/cryptopunk
|
|
|
85
87
|
- [Apes](https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/apes.png) 
|
|
86
88
|
- [Aliens](https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/aliens.png) 
|
|
87
89
|
- [Golden Punks](https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/goldenpunks.png) 
|
|
90
|
+
- [Green Punks](https://i.redd.it/uwrsn2lrr3o71.png)
|
|
91
|
+
- [Clown Punks](https://i.redd.it/ut0kk25heex71.png)
|
|
92
|
+
- [Bubble Gum Punks](https://i.redd.it/hjddd1s8ydx71.png)
|
|
88
93
|
- [Halloween Punks](https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/halloweenpunks.png) 
|
|
89
94
|
- [Scream Punks](https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/screampunks%402x.png)
|
|
90
95
|
- [Jack 'O' Lantern Punks](https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/jackpunks%402x.png)
|
|
@@ -117,8 +122,6 @@ There are currently 38 available collections (from https://github.com/cryptopunk
|
|
|
117
122
|
- [Punk Rocks](https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/punkrocks.png) 
|
|
118
123
|
- [Tulips](https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/tulips.png) 
|
|
119
124
|
|
|
120
|
-

|
|
121
|
-
|
|
122
125
|

|
|
123
126
|
|
|
124
127
|

|
|
@@ -211,45 +214,6 @@ You may select a new output location by clicking on the `...` button.
|
|
|
211
214
|
|
|
212
215
|

|
|
213
216
|
|
|
214
|
-
## Packaging
|
|
215
|
-
|
|
216
|
-
Assuming you have setup all prerequisites and cloned the project locally, you can package the project files, Ruby, gem dependencies, and ActiveTcl (Tcl/Tk) into fully self-contained native executable bundles for the Mac.
|
|
217
|
-
|
|
218
|
-
### Packaging Prerequisites
|
|
219
|
-
|
|
220
|
-
Packaging is currently supported on Mac only.
|
|
221
|
-
|
|
222
|
-
- [Platypus](https://github.com/sveinbjornt/Platypus): Install Platypus 5.3
|
|
223
|
-
- [Platypus Command Line Tool](https://github.com/sveinbjornt/Platypus/blob/master/Documentation/Documentation.md#show-shell-command): Run Platypus GUI -> Go to Preferences -> Install Command Line Tool.
|
|
224
|
-
|
|
225
|
-
Finally, ensure the `platypus` command is available in the terminal by simply running:
|
|
226
|
-
|
|
227
|
-
```
|
|
228
|
-
platypus --version
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
Output:
|
|
232
|
-
|
|
233
|
-
```
|
|
234
|
-
platypus version 5.3
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
### Packaging Commands
|
|
238
|
-
|
|
239
|
-
To package this app as both a Mac native executable (APP file) and a Mac native installer (DMG file), run this command (produces packages under `~/Applications`):
|
|
240
|
-
|
|
241
|
-
```
|
|
242
|
-
bin/package-mac
|
|
243
|
-
```
|
|
244
|
-
|
|
245
|
-
To package a Mac native executable only (quicker for local APP use without distribution), run:
|
|
246
|
-
|
|
247
|
-
```
|
|
248
|
-
bin/package-mac-app
|
|
249
|
-
```
|
|
250
|
-
|
|
251
|
-

|
|
252
|
-
|
|
253
217
|
## TODO
|
|
254
218
|
|
|
255
219
|
[TODO.md](TODO.md)
|
|
@@ -272,7 +236,7 @@ bin/package-mac-app
|
|
|
272
236
|
|
|
273
237
|
[MIT](LICENSE.txt)
|
|
274
238
|
|
|
275
|
-
Copyright (c) 2021 - Cryptopunks GUI by [
|
|
239
|
+
Copyright (c) 2021 - Cryptopunks GUI by [Crypto Punk's Not Dead](https://github.com/cryptopunksnotdead)
|
|
276
240
|
|
|
277
241
|
--
|
|
278
242
|
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.0.
|
|
1
|
+
0.0.14
|
data/app/cryptopunks_gui.rb
CHANGED
|
@@ -1,344 +1,42 @@
|
|
|
1
1
|
require 'glimmer-dsl-tk'
|
|
2
|
+
require 'glimmer/data_binding/observer'
|
|
2
3
|
require 'cryptopunks'
|
|
3
4
|
require 'facets'
|
|
4
5
|
require 'fileutils'
|
|
5
6
|
require 'net/http'
|
|
6
7
|
require 'uri'
|
|
7
|
-
require 'glimmer/data_binding/observer'
|
|
8
8
|
require 'yaml'
|
|
9
9
|
require 'puts_debuggerer'
|
|
10
10
|
|
|
11
|
+
require_relative 'model/image'
|
|
12
|
+
require_relative 'view/menu_bar'
|
|
13
|
+
require_relative 'view/image_frame'
|
|
14
|
+
require_relative 'view/style_options_frame'
|
|
15
|
+
|
|
11
16
|
class CryptopunksGui
|
|
12
17
|
include Glimmer
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
COLLECTION_URL_MAP = {
|
|
17
|
-
'Punks' => {url: 'https://raw.githubusercontent.com/larvalabs/cryptopunks/master/punks.png', width: 24, height: 24, default_zoom: 12},
|
|
18
|
-
'Mohawks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/mohawks.png', width: 24, height: 24, default_zoom: 12},
|
|
19
|
-
'Blondies' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/blondies.png', width: 24, height: 24, default_zoom: 12},
|
|
20
|
-
'Zombies' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/zombies.png', width: 24, height: 24, default_zoom: 12},
|
|
21
|
-
'Apes' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/apes.png', width: 24, height: 24, default_zoom: 12},
|
|
22
|
-
'Aliens' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/aliens.png', width: 24, height: 24, default_zoom: 12},
|
|
23
|
-
'Golden Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/goldenpunks.png', width: 24, height: 24, default_zoom: 12},
|
|
24
|
-
'Halloween Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/halloweenpunks.png', width: 24, height: 24, default_zoom: 12},
|
|
25
|
-
'Scream Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/screampunks%402x.png', width: 48, height: 48, default_zoom: 6},
|
|
26
|
-
"Jack 'O' Lantern Punks" => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/jackpunks%402x.png', width: 48, height: 48, default_zoom: 6},
|
|
27
|
-
'Joker Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/jokerpunks%402x.png', width: 48, height: 48, default_zoom: 6},
|
|
28
|
-
'Frankenstein Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/cryptopunks/master/halloween/i/frankensteinpunks%402x.png', width: 48, height: 48, default_zoom: 6},
|
|
29
|
-
'Front Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/frontpunks.png', width: 24, height: 24, default_zoom: 12},
|
|
30
|
-
'More Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/morepunks.png', width: 24, height: 24, default_zoom: 12},
|
|
31
|
-
'Expansion Punks' => {url: 'https://expansionpunks.com/provenance/expansionpunks.png', width: 24, height: 24, default_zoom: 12},
|
|
32
|
-
'Avalanche Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/avalanchepunks.png', width: 24, height: 24, default_zoom: 12},
|
|
33
|
-
'International Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/intlpunks.png', width: 24, height: 24, default_zoom: 12},
|
|
34
|
-
'Ape Punks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/apepunks.png', width: 24, height: 24, default_zoom: 12},
|
|
35
|
-
'Alien Clan' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/alienclan.png', width: 24, height: 24, default_zoom: 12},
|
|
36
|
-
'Bored Apes' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes.png', width: 28, height: 28, default_zoom: 10},
|
|
37
|
-
'Bored Apes Blue' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes_blue.png', width: 28, height: 28, default_zoom: 10},
|
|
38
|
-
'Bored Apes Red' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes_red.png', width: 28, height: 28, default_zoom: 10},
|
|
39
|
-
'Bored Apes Neon Glow' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes_neon_glow.png', width: 28, height: 28, default_zoom: 10},
|
|
40
|
-
'Bored Apes Stars and Stripes' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes_stars_and_stripes.png', width: 28, height: 28, default_zoom: 10},
|
|
41
|
-
'Bored Apes Acid' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/boredapes_acid.png', width: 28, height: 28, default_zoom: 10},
|
|
42
|
-
'Cool Cats' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats.png', width: 24, height: 24, default_zoom: 12},
|
|
43
|
-
'Cool Cats Mohawks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_mohawks.png', width: 24, height: 24, default_zoom: 12},
|
|
44
|
-
'Cool Cats Ninjas' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_ninjas.png', width: 24, height: 24, default_zoom: 12},
|
|
45
|
-
'Cool Cats TV Heads' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_tvheads.png', width: 24, height: 24, default_zoom: 12},
|
|
46
|
-
'Cool Cats Pirates' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_pirates.png', width: 24, height: 24, default_zoom: 12},
|
|
47
|
-
'Cool Cats Unicorns' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_unicorns.png', width: 24, height: 24, default_zoom: 12},
|
|
48
|
-
'Cool Cats Dragons' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_dragons.png', width: 24, height: 24, default_zoom: 12},
|
|
49
|
-
'Cool Cats Frogs' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/coolcats_frogs.png', width: 24, height: 24, default_zoom: 12},
|
|
50
|
-
'Pudgy Penguins' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/pudgypenguins.png', width: 24, height: 24, default_zoom: 12},
|
|
51
|
-
'Dodge' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/dodge.png', width: 24, height: 24, default_zoom: 12},
|
|
52
|
-
'Rocks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/rocks.png', width: 24, height: 24, default_zoom: 12},
|
|
53
|
-
'Punk Rocks' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/programming-cryptopunks/master/i/punkrocks.png', width: 24, height: 24, default_zoom: 12},
|
|
54
|
-
'Tulips' => {url: 'https://raw.githubusercontent.com/cryptopunksnotdead/awesome-24px/master/collection/tulips.png', width: 24, height: 24, default_zoom: 12},
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
attr_accessor :collection, :image_index, :zoom, :palette, :style, :led_spacing, :led_round_corner, :sketch_line, :flip, :mirror
|
|
18
|
+
include View::MenuBar
|
|
19
|
+
include View::ImageFrame
|
|
20
|
+
include View::StyleOptionsFrame
|
|
58
21
|
|
|
59
22
|
def initialize
|
|
60
|
-
|
|
61
|
-
initialize_collection
|
|
62
|
-
load_config
|
|
63
|
-
initialize_defaults
|
|
64
|
-
observe_image_attribute_changes
|
|
23
|
+
@image = Model::Image.new
|
|
65
24
|
create_gui
|
|
66
|
-
|
|
67
|
-
@root.open
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
def collection_options
|
|
71
|
-
COLLECTION_URL_MAP.keys
|
|
25
|
+
@image.image_index = 0
|
|
72
26
|
end
|
|
73
27
|
|
|
74
|
-
def
|
|
75
|
-
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def style_options
|
|
79
|
-
STYLES
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
def initialize_punk_directory
|
|
83
|
-
@punk_directory = @punk_config_directory = File.join(Dir.home, 'cryptopunks')
|
|
84
|
-
FileUtils.mkdir_p(@punk_directory)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def initialize_collection
|
|
88
|
-
return if @collection && @collection == @last_collection
|
|
89
|
-
@collection ||= COLLECTION_URL_MAP.keys.first
|
|
90
|
-
url = COLLECTION_URL_MAP[@collection][:url]
|
|
91
|
-
width = COLLECTION_URL_MAP[@collection][:width]
|
|
92
|
-
height = COLLECTION_URL_MAP[@collection][:height]
|
|
93
|
-
@punk_file = File.join(@punk_config_directory, File.basename(url, '.png'))
|
|
94
|
-
File.write(@punk_file, Net::HTTP.get(URI(url))) unless File.exist?(@punk_file)
|
|
95
|
-
@images ||= {}
|
|
96
|
-
@images[@collection] ||= Punks::Image::Composite.read(@punk_file, width: width, height: height)
|
|
97
|
-
@last_collection = @collection
|
|
98
|
-
self.image_index = 0
|
|
99
|
-
@image_index_spinbox.to = @images[@collection].size - 1 if @image_index_spinbox
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def load_config
|
|
103
|
-
@punk_config_file = File.join(@punk_config_directory, 'cryptopunks.yml')
|
|
104
|
-
FileUtils.touch(@punk_config_file)
|
|
105
|
-
@punk_config = YAML.load(File.read(@punk_config_file)) || {punk_directory: @punk_directory}
|
|
106
|
-
@punk_directory = @punk_config[:punk_directory]
|
|
107
|
-
end
|
|
108
|
-
|
|
109
|
-
def save_config
|
|
110
|
-
File.write(@punk_config_file, YAML.dump(@punk_config))
|
|
111
|
-
end
|
|
112
|
-
|
|
113
|
-
def initialize_defaults
|
|
114
|
-
@collection = COLLECTION_URL_MAP.keys.first
|
|
115
|
-
@zoom = 12
|
|
116
|
-
@palette = PALETTES.first
|
|
117
|
-
@style = STYLES.first
|
|
118
|
-
@led_spacing = 2
|
|
119
|
-
@led_round_corner = false
|
|
120
|
-
@sketch_line = 1
|
|
121
|
-
@mirror = false
|
|
122
|
-
@flip = false
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
def observe_image_attribute_changes
|
|
126
|
-
observer = Glimmer::DataBinding::Observer.proc { generate_image }
|
|
127
|
-
observer.observe(self, :collection)
|
|
128
|
-
observer.observe(self, :image_index)
|
|
129
|
-
observer.observe(self, :zoom)
|
|
130
|
-
observer.observe(self, :palette)
|
|
131
|
-
observer.observe(self, :style)
|
|
132
|
-
observer.observe(self, :led_spacing)
|
|
133
|
-
observer.observe(self, :led_round_corner)
|
|
134
|
-
observer.observe(self, :sketch_line)
|
|
135
|
-
observer.observe(self, :mirror)
|
|
136
|
-
observer.observe(self, :flip)
|
|
137
|
-
end
|
|
138
|
-
|
|
139
|
-
def generate_image
|
|
140
|
-
initialize_collection
|
|
141
|
-
return if @image_index.to_i > @images[@collection].size
|
|
142
|
-
image_location = File.join(@punk_directory, "#{@collection.gsub(' ', '').downcase}-#{@image_index}#{"x#{@zoom}" if @zoom.to_i > 1}#{"-#{@palette.underscore}" if @palette != PALETTES.first}#{"-#{@style.underscore}" if @style != STYLES.first}.png")
|
|
143
|
-
puts "Writing punk image to #{image_location}"
|
|
144
|
-
selected_punk = @images[@collection][@image_index.to_i]
|
|
145
|
-
selected_punk = selected_punk.change_palette8bit(Palette8bit.const_get(@palette.gsub(' ', '_').upcase.to_sym)) if @palette != PALETTES.first
|
|
146
|
-
@original_zoom = @zoom
|
|
147
|
-
if @previous_collection && @collection != @previous_collection && COLLECTION_URL_MAP[@collection][:width] != COLLECTION_URL_MAP[@previous_collection][:width]
|
|
148
|
-
@zoom = COLLECTION_URL_MAP[@collection][:default_zoom]
|
|
149
|
-
end
|
|
150
|
-
if @style != STYLES.first
|
|
151
|
-
style_options = {}
|
|
152
|
-
if @style == 'Led'
|
|
153
|
-
style_options[:spacing] = @led_spacing.to_i
|
|
154
|
-
style_options[:round_corner] = @led_round_corner
|
|
155
|
-
end
|
|
156
|
-
if @style == 'Sketch'
|
|
157
|
-
style_options[:line] = @sketch_line.to_i
|
|
158
|
-
end
|
|
159
|
-
selected_punk = selected_punk.send(@style.underscore, @zoom.to_i, **style_options)
|
|
160
|
-
end
|
|
161
|
-
selected_punk = selected_punk.mirror if @mirror
|
|
162
|
-
selected_punk = selected_punk.flip if @flip
|
|
163
|
-
selected_punk = selected_punk.zoom(@zoom.to_i) if @style == STYLES.first
|
|
164
|
-
selected_punk.save(image_location)
|
|
165
|
-
@image_label.image = image_location
|
|
166
|
-
@output_location_entry.text = image_location
|
|
167
|
-
@previous_style = @style
|
|
168
|
-
@previous_collection = @collection
|
|
169
|
-
notify_observers(:zoom) if @zoom != @original_zoom
|
|
28
|
+
def launch
|
|
29
|
+
@root.open
|
|
170
30
|
end
|
|
171
31
|
|
|
172
32
|
def create_gui
|
|
173
|
-
@root = root {
|
|
33
|
+
@root = root { |root_proxy|
|
|
174
34
|
title 'CryptoPunks GUI'
|
|
175
35
|
iconphoto File.expand_path('../icons/cryptopunks-gui.png', __dir__)
|
|
176
36
|
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
}
|
|
181
|
-
combobox {
|
|
182
|
-
readonly true
|
|
183
|
-
text <=> [self, :collection]
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
label {
|
|
187
|
-
text 'Image Index:'
|
|
188
|
-
}
|
|
189
|
-
@image_index_spinbox = spinbox {
|
|
190
|
-
from 0
|
|
191
|
-
to @images[@collection].size - 1
|
|
192
|
-
text <=> [self, :image_index]
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
label {
|
|
196
|
-
text 'Zoom:'
|
|
197
|
-
}
|
|
198
|
-
spinbox {
|
|
199
|
-
from 1
|
|
200
|
-
to 72
|
|
201
|
-
text <=> [self, :zoom]
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
label {
|
|
205
|
-
text 'Palette:'
|
|
206
|
-
}
|
|
207
|
-
combobox {
|
|
208
|
-
readonly true
|
|
209
|
-
text <=> [self, :palette]
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
label {
|
|
213
|
-
text 'Style:'
|
|
214
|
-
}
|
|
215
|
-
combobox {
|
|
216
|
-
readonly true
|
|
217
|
-
text <=> [self, :style, after_write: ->(val) {add_style_options}]
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
@style_options_frame = frame {
|
|
221
|
-
padding 0
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
frame {
|
|
225
|
-
padding 0
|
|
226
|
-
|
|
227
|
-
checkbutton {
|
|
228
|
-
grid row: 0, column: 0, column_weight: 0
|
|
229
|
-
variable <=> [self, :mirror]
|
|
230
|
-
}
|
|
231
|
-
label {
|
|
232
|
-
grid row: 0, column: 1
|
|
233
|
-
text 'Mirror'
|
|
234
|
-
|
|
235
|
-
on('Button-1') do
|
|
236
|
-
self.mirror = !mirror
|
|
237
|
-
end
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
checkbutton {
|
|
241
|
-
grid row: 0, column: 2
|
|
242
|
-
variable <=> [self, :flip]
|
|
243
|
-
}
|
|
244
|
-
label {
|
|
245
|
-
grid row: 0, column: 3
|
|
246
|
-
text 'Flip'
|
|
247
|
-
|
|
248
|
-
on('Button-1') do
|
|
249
|
-
self.flip = !flip
|
|
250
|
-
end
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
label {
|
|
255
|
-
text 'Output Location:'
|
|
256
|
-
}
|
|
257
|
-
frame {
|
|
258
|
-
padding 0
|
|
259
|
-
|
|
260
|
-
@output_location_entry = entry {
|
|
261
|
-
grid row: 0, column: 0
|
|
262
|
-
readonly true
|
|
263
|
-
width 47
|
|
264
|
-
}
|
|
265
|
-
button {
|
|
266
|
-
grid row: 0, column: 1
|
|
267
|
-
text '...'
|
|
268
|
-
width 1.1
|
|
269
|
-
|
|
270
|
-
on('command') do
|
|
271
|
-
new_punk_directory = choose_directory(parent: @root)
|
|
272
|
-
unless new_punk_directory.to_s.empty?
|
|
273
|
-
@punk_directory = new_punk_directory
|
|
274
|
-
@punk_config[:punk_directory] = @punk_directory
|
|
275
|
-
save_config
|
|
276
|
-
generate_image
|
|
277
|
-
end
|
|
278
|
-
end
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
@image_label = label {
|
|
283
|
-
grid row_weight: 1
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
}
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
def add_style_options
|
|
290
|
-
@style_options_frame.content {
|
|
291
|
-
@style_options_frame.children.each(&:destroy)
|
|
292
|
-
if @style == 'Led'
|
|
293
|
-
frame {
|
|
294
|
-
padding 0
|
|
295
|
-
|
|
296
|
-
label {
|
|
297
|
-
grid row: 0, column: 0, column_weight: 0
|
|
298
|
-
text 'Spacing:'
|
|
299
|
-
}
|
|
300
|
-
spinbox {
|
|
301
|
-
grid row: 0, column: 1
|
|
302
|
-
from 1
|
|
303
|
-
to 72
|
|
304
|
-
text <=> [self, :led_spacing]
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
checkbutton {
|
|
308
|
-
grid row: 0, column: 2
|
|
309
|
-
variable <=> [self, :led_round_corner]
|
|
310
|
-
}
|
|
311
|
-
label {
|
|
312
|
-
grid row: 0, column: 3
|
|
313
|
-
text 'Round Corner'
|
|
314
|
-
|
|
315
|
-
on('Button-1') do
|
|
316
|
-
self.led_round_corner = !led_round_corner
|
|
317
|
-
end
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
elsif @style == 'Sketch'
|
|
321
|
-
frame {
|
|
322
|
-
padding 0
|
|
323
|
-
|
|
324
|
-
label {
|
|
325
|
-
grid row: 0, column: 0, column_weight: 0
|
|
326
|
-
text 'Line:'
|
|
327
|
-
}
|
|
328
|
-
spinbox {
|
|
329
|
-
grid row: 0, column: 1
|
|
330
|
-
from 1
|
|
331
|
-
to 72
|
|
332
|
-
text <=> [self, :sketch_line]
|
|
333
|
-
}
|
|
334
|
-
}
|
|
335
|
-
else
|
|
336
|
-
frame { # filler
|
|
337
|
-
padding 0
|
|
338
|
-
height 0
|
|
339
|
-
width 0
|
|
340
|
-
}
|
|
341
|
-
end
|
|
37
|
+
cryptopunks_gui_menu_bar(root: root_proxy, image: @image)
|
|
38
|
+
|
|
39
|
+
image_frame(root: root_proxy, image: @image)
|
|
342
40
|
}
|
|
343
41
|
end
|
|
344
42
|
end
|