Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 56 lines (46 sloc) 1.313 kb
924f206 added tests
Peter Ohler authored
1 #!/usr/bin/env ruby -wW2
2
3 if $0 == __FILE__
4 $: << '.'
5 $: << '..'
6 $: << '../lib'
7 $: << '../ext'
8 end
9
10 require 'pp'
8f6bf30 object recreation working without caching
Peter Ohler authored
11 require 'sample/doc'
924f206 added tests
Peter Ohler authored
12
8f6bf30 object recreation working without caching
Peter Ohler authored
13
14 def sample_doc(size=3)
924f206 added tests
Peter Ohler authored
15 colors = [ :black, :gray, :white, :red, :blue, :yellow, :green, :purple, :orange ]
8f6bf30 object recreation working without caching
Peter Ohler authored
16
17 d = ::Sample::Doc.new('Sample')
18
19 # add some history
20 (0..size * 10).each do |i|
21 d.add_change("Changed at t+#{i}.")
924f206 added tests
Peter Ohler authored
22 end
23
8f6bf30 object recreation working without caching
Peter Ohler authored
24 # add some layers
25 (1..size).each do |i|
26 layer = ::Sample::Layer.new("Layer-#{i}")
27 (1..size).each do |j|
28 g = ::Sample::Group.new
29 (1..size).each do |k|
30 g2 = ::Sample::Group.new
31 r = ::Sample::Rect.new(j * 40 + 10.0, i * 10.0,
11fd80a Peter Ohler ready for release 2.1.0
authored
32 10.123456 / k, 10.0 / k, colors[(i + j + k) % colors.size])
8f6bf30 object recreation working without caching
Peter Ohler authored
33 r.add_prop(:part_of, layer.name)
34 g2 << r
35 g2 << ::Sample::Text.new("#{k} in #{j}", r.left, r.top, r.width, r.height)
36 g << g2
37 end
38 g2 = ::Sample::Group.new
39 (1..size).each do |k|
40 o = ::Sample::Oval.new(j * 40 + 12.0, i * 10.0 + 2.0,
11fd80a Peter Ohler ready for release 2.1.0
authored
41 6.0 / k, 6.0 / k, colors[(i + j + k) % colors.size])
8f6bf30 object recreation working without caching
Peter Ohler authored
42 o.add_prop(:inside, true)
43 g << o
44 end
45 g << g2
46 layer << g
47 end
48 d.layers[layer.name] = layer
49 end
50
51 # some properties
52 d.add_prop(:purpose, 'an example')
53
54 d
924f206 added tests
Peter Ohler authored
55 end
Something went wrong with that request. Please try again.