worldgen 0.0.3 → 0.0.4
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/README.md +15 -1
- data/generate.rb +3 -2
- data/lib/worldgen/platemap.rb +5 -0
- data/lib/worldgen/render.rb +10 -7
- data/lib/worldgen/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 497b921a38eeaca1ee9a84de648391c8fe597ba0
|
4
|
+
data.tar.gz: 8bb73f3b81df01d943ce3aeb384a0b47df3c21c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 907343460f6e85437f1f12dda95bc37114c2f4ffddfaedbfcd662cbb89dc004ec575ed8abd86abbba810a87c20716776529c4b71eee7c9159151f8ac93f85a31
|
7
|
+
data.tar.gz: 11e764c48da27846c86c3114e50a15934d31f4623fb82e1bce94939bd1622967ae10b17387ae346310af1510e907311ff877d7fd232c7199deb7dd7193d67187
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Usage
|
22
22
|
|
23
|
-
|
23
|
+
### Heightmaps
|
24
24
|
|
25
25
|
```ruby
|
26
26
|
# Create a 50x50 heightmap - this will be flat
|
@@ -39,6 +39,20 @@ Then dump it to an image file:
|
|
39
39
|
Worldgen::Render.heightmap heightmap, "output.png"
|
40
40
|
```
|
41
41
|
|
42
|
+
### Plate Maps
|
43
|
+
|
44
|
+
A plate map is a random construction of plates within a world (as in plate
|
45
|
+
tectonics). Example:
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
# create a 256x256 plate map
|
49
|
+
platemap = Worldgen::PlateMap.new 256
|
50
|
+
# generate 10 plates
|
51
|
+
platemap.generate_plates! 10
|
52
|
+
# Output to a PNG - this will show each plate in a different colour
|
53
|
+
Worldgen::Render.platemap platemap, "plates.png"
|
54
|
+
```
|
55
|
+
|
42
56
|
## Contributing
|
43
57
|
|
44
58
|
1. Fork it ( https://github.com/robbrit/worldgen/fork )
|
data/generate.rb
CHANGED
@@ -49,8 +49,9 @@ if options[:platemap]
|
|
49
49
|
platemap = Worldgen::PlateMap.new(options[:size])
|
50
50
|
platemap.generate_plates!(options[:num_plates], options[:verbose])
|
51
51
|
puts "Converting to height map..."
|
52
|
-
heightmap = platemap.to_height_map(0.5)
|
53
|
-
Worldgen::Render.heightmap heightmap, options[:platemap]
|
52
|
+
#heightmap = platemap.to_height_map(0.5)
|
53
|
+
#Worldgen::Render.heightmap heightmap, options[:platemap]
|
54
|
+
Worldgen::Render.platemap platemap, options[:platemap]
|
54
55
|
end
|
55
56
|
|
56
57
|
puts "Done."
|
data/lib/worldgen/platemap.rb
CHANGED
@@ -184,6 +184,8 @@ module Worldgen
|
|
184
184
|
valid_plates.delete_at idx
|
185
185
|
break if valid_plates.length == 0
|
186
186
|
else
|
187
|
+
# Did we just consume the last point of this plate?
|
188
|
+
valid_plates.delete_at(idx) if not plate.has_frontier?
|
187
189
|
break
|
188
190
|
end
|
189
191
|
end
|
@@ -204,6 +206,9 @@ module Worldgen
|
|
204
206
|
# TODO: could probably pull weighted randoms into a different module
|
205
207
|
total = plates.map(&:frontier_length).inject(&:+)
|
206
208
|
|
209
|
+
# There is the possibility of
|
210
|
+
#return 0 if total == 0
|
211
|
+
|
207
212
|
# TODO: using a uniform random generator here gives plates that are all
|
208
213
|
# roughly the same size - kinda boring, maybe try using a non-uniform
|
209
214
|
# distribution here
|
data/lib/worldgen/render.rb
CHANGED
@@ -14,11 +14,15 @@ module Worldgen::Render
|
|
14
14
|
image.pixel_color x, y, "##{grey}"
|
15
15
|
end
|
16
16
|
|
17
|
-
#image.display
|
18
17
|
image.write filename
|
19
18
|
end
|
20
19
|
|
21
|
-
|
20
|
+
# Render a platemap to a file. Each plate has a separate colour - this will
|
21
|
+
# only work for up to 16 plates, after that everything will be black.
|
22
|
+
#
|
23
|
+
# Arguments:
|
24
|
+
# * map - the plate map to render
|
25
|
+
# * filename - the filename to output to
|
22
26
|
def self.platemap map, filename
|
23
27
|
image = Magick::Image.new(map.size, map.size) { self.background_color = "black" }
|
24
28
|
|
@@ -26,19 +30,18 @@ module Worldgen::Render
|
|
26
30
|
colours = [
|
27
31
|
"#FF0000", "#0000FF", "#FFFF00", "#00FF00",
|
28
32
|
"#FF6600", "#FF00FF", "#00FFFF", "#CCCCCC",
|
29
|
-
"#006600", "#000066", "#660066", "#666600"
|
33
|
+
"#006600", "#000066", "#660066", "#666600",
|
34
|
+
"#CCCCCC", "#FFFFFF", "#000000", "#CCCCFF"
|
30
35
|
]
|
31
36
|
map.each_plate_point do |x, y, plate|
|
32
37
|
begin
|
33
|
-
image.pixel_color x, y, colours[plate]
|
38
|
+
image.pixel_color x, y, (colours[plate] or "#000000")
|
34
39
|
rescue
|
35
40
|
puts "colour fail"
|
36
|
-
puts [x, y, plate,
|
41
|
+
puts [x, y, plate, colours[plate]].inspect
|
37
42
|
end
|
38
43
|
end
|
39
44
|
|
40
|
-
#image.display
|
41
45
|
image.write filename
|
42
46
|
end
|
43
|
-
=end
|
44
47
|
end
|
data/lib/worldgen/version.rb
CHANGED