worldgen 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 75fa665add8ad72d23153e40d262bdd86a553421
4
- data.tar.gz: 4920045ba83ad3d26d0f2c424555ccd91be46d02
3
+ metadata.gz: 497b921a38eeaca1ee9a84de648391c8fe597ba0
4
+ data.tar.gz: 8bb73f3b81df01d943ce3aeb384a0b47df3c21c8
5
5
  SHA512:
6
- metadata.gz: e95a80c4f3043220615ab1a5cae52e3ab0276460d236deb23ddc52bc0bfece292349c14682089a1148a219319c0c5ca7573957f14b23fb0a97ca5ac1a6b955e5
7
- data.tar.gz: 0f6506cf096612852a6bd47d4e0e5ec8f797634bbc5a36ccac51eb116b33627893a923111535fa32fc9e485ebb444f276c6a40dc8375a39770e1b6c7df9a93aa
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
- So far there is not much. You can do square heightmaps:
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 )
@@ -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."
@@ -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
@@ -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
- =begin
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, colour[plate]].inspect
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
@@ -1,3 +1,3 @@
1
1
  module Worldgen
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: worldgen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rob Britton