Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 56 lines (46 sloc) 1.317 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
#!/usr/bin/env ruby -wW2

if $0 == __FILE__
  $: << '.'
  $: << '..'
  $: << '../lib'
  $: << '../ext'
end

require 'pp'
require 'sample/doc'


def sample_doc(size=3)
  colors = [ :black, :gray, :white, :red, :blue, :yellow, :green, :purple, :orange ]

  d = ::Sample::Doc.new('Sample')

  # add some history
  (0..size * 10).each do |i|
    d.add_change("Changed at t+#{i}.")
  end

  # add some layers
  (1..size).each do |i|
    layer = ::Sample::Layer.new("Layer-#{i}")
    (1..size).each do |j|
      g = ::Sample::Group.new
      (1..size).each do |k|
        g2 = ::Sample::Group.new
        r = ::Sample::Rect.new(j * 40 + 10.0, i * 10.0,
                                 10.123456 / k, 10.0 / k, colors[(i + j + k) % colors.size])
        r.add_prop(:part_of, layer.name)
        g2 << r
        g2 << ::Sample::Text.new("#{k} in #{j}", r.left, r.top, r.width, r.height)
        g << g2
      end
      g2 = ::Sample::Group.new
      (1..size).each do |k|
        o = ::Sample::Oval.new(j * 40 + 12.0, i * 10.0 + 2.0,
                                 6.0 / k, 6.0 / k, colors[(i + j + k) % colors.size])
        o.add_prop(:inside, true)
        g << o
      end
      g << g2
      layer << g
    end
    d.layers[layer.name] = layer
  end

  # some properties
  d.add_prop(:purpose, 'an example')

  d
end
Something went wrong with that request. Please try again.