oekaki 0.1.3 → 0.1.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/example/oekaki_sample1.rb +52 -0
- data/example/oekaki_sample10.rb +21 -0
- data/example/oekaki_sample12.rb +69 -0
- data/example/oekaki_sample14.rb +51 -0
- data/example/oekaki_sample2.rb +27 -0
- data/example/oekaki_sample3.rb +33 -0
- data/example/oekaki_sample4.rb +25 -0
- data/example/oekaki_sample5.rb +58 -0
- data/example/oekaki_sample6.rb +20 -0
- data/example/oekaki_sample7.rb +18 -0
- data/example/oekaki_sample8.rb +39 -0
- data/example/oekaki_sample9.rb +39 -0
- metadata +13 -1
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 2c1e71b934906a7cb076791108504709515d4253
         | 
| 4 | 
            +
              data.tar.gz: 07b385f02f2f514bce69049a805a8427443927ba
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 3634834be985b965c7168bfa06d39d79b9b335e871d37921743f6c1ed86fbb35ff12643dbb1094eab69060e2a1b5d439e8785841cc31c464d1d09d9853319104
         | 
| 7 | 
            +
              data.tar.gz: 16f5b93a27f97bbf2d8fb511199e648aeab3b5dbaed3f7e7cc8d6d94a53761fcf813128af4cac4b5e8efa56a095cafbb4b73bfb6a7dc54ac771170027597e91a
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
            include Math
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            W, H = 600, 300
         | 
| 5 | 
            +
            V0, A, G = 10.0, 0.75, 5.0
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            v = lambda {|n| - A ** n * sqrt(2 * G * H)}
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            t = lambda do |n|
         | 
| 10 | 
            +
              if n.zero?
         | 
| 11 | 
            +
                sqrt(2 * H / G)
         | 
| 12 | 
            +
              else
         | 
| 13 | 
            +
                ar = [1]
         | 
| 14 | 
            +
                n.times {|i| ar << 2 * A ** (i + 1)}
         | 
| 15 | 
            +
                sqrt(2 * H / G) * ar.inject(:+)
         | 
| 16 | 
            +
              end
         | 
| 17 | 
            +
            end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
            y = lambda do |n, t1|
         | 
| 20 | 
            +
              if n.zero?
         | 
| 21 | 
            +
                H - G * t1 ** 2 / 2
         | 
| 22 | 
            +
              else
         | 
| 23 | 
            +
                t2 = t1 - t.call(n - 1)
         | 
| 24 | 
            +
                - v.call(n) * t2 - G * t2 ** 2 / 2
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| 27 | 
            +
             | 
| 28 | 
            +
            x = lambda {|t1| V0 * t1}
         | 
| 29 | 
            +
             | 
| 30 | 
            +
            num = lambda do |tm|
         | 
| 31 | 
            +
              1000.times {|i| return i if tm <= t.call(i)}
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
            i = 0
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            Oekaki.app width: W, height: H do
         | 
| 37 | 
            +
              draw do
         | 
| 38 | 
            +
                clear
         | 
| 39 | 
            +
              end
         | 
| 40 | 
            +
              
         | 
| 41 | 
            +
              id = timer(20) do
         | 
| 42 | 
            +
                tm = i / V0
         | 
| 43 | 
            +
                x1 = x.call(tm)
         | 
| 44 | 
            +
                y1 = H - y.call(num[tm], tm)
         | 
| 45 | 
            +
                color(65535, 0, 0)
         | 
| 46 | 
            +
                arc(false, x1, y1, 4, 4, 0, 64 * 360)
         | 
| 47 | 
            +
                timer_stop(id) if i >= W
         | 
| 48 | 
            +
                i += 1
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
            end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
             | 
| @@ -0,0 +1,21 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Width, Height = 500, 500
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Oekaki.app width: Width, height: Height do
         | 
| 6 | 
            +
              draw do
         | 
| 7 | 
            +
                clear
         | 
| 8 | 
            +
                
         | 
| 9 | 
            +
                color(0, 65535, 0)
         | 
| 10 | 
            +
                r = Width / 2
         | 
| 11 | 
            +
                circle(false, 0, r, r)
         | 
| 12 | 
            +
                circle(false, 2 * r, r, r)
         | 
| 13 | 
            +
                
         | 
| 14 | 
            +
                (1..9).to_a.combination(2) do |p, q|
         | 
| 15 | 
            +
                  x = p / q.to_f
         | 
| 16 | 
            +
                  y = 1 / (2 * q ** 2).to_f
         | 
| 17 | 
            +
                  wx, wy = Width * x, Height * y
         | 
| 18 | 
            +
                  circle(false, wx, Height - wy, wy)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
            end
         | 
| @@ -0,0 +1,69 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Width, Height = if ARGV.size == 2
         | 
| 4 | 
            +
              ARGV.map(&:to_i)
         | 
| 5 | 
            +
            else
         | 
| 6 | 
            +
              [1000, 700]
         | 
| 7 | 
            +
            end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Max_r, Min_r = 40, 10
         | 
| 10 | 
            +
            ColorMax = 65535
         | 
| 11 | 
            +
            MaxNum = 60
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
            class Circle
         | 
| 15 | 
            +
              def initialize(ob)
         | 
| 16 | 
            +
                @slot = ob
         | 
| 17 | 
            +
                @width, @height = Width, Height
         | 
| 18 | 
            +
                renewal
         | 
| 19 | 
            +
                @y = rand(@height)
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              attr_reader :height
         | 
| 22 | 
            +
              attr_writer :y
         | 
| 23 | 
            +
              
         | 
| 24 | 
            +
              def renewal
         | 
| 25 | 
            +
                @width, @height = @slot.get_window_size
         | 
| 26 | 
            +
                @max_r = rand(Max_r - Min_r) + Min_r
         | 
| 27 | 
            +
                @x = rand(@width)
         | 
| 28 | 
            +
                @y = -rand(@max_r)
         | 
| 29 | 
            +
                @color = [rand(ColorMax), rand(ColorMax), rand(ColorMax)]
         | 
| 30 | 
            +
                @fall_step = 1 + rand * 3
         | 
| 31 | 
            +
                @r = 1
         | 
| 32 | 
            +
                @r_step = rand * 0.2 + 0.8
         | 
| 33 | 
            +
              end
         | 
| 34 | 
            +
             | 
| 35 | 
            +
              def paint
         | 
| 36 | 
            +
                @slot.color(@color[0], @color[1], @color[2])
         | 
| 37 | 
            +
                @slot.circle(true, @x, @y, @r)
         | 
| 38 | 
            +
                @y += @fall_step
         | 
| 39 | 
            +
                @r += @r_step
         | 
| 40 | 
            +
                @r_step *= -1 if @r > @max_r or @r < 1
         | 
| 41 | 
            +
                renewal if @y > @height + Max_r
         | 
| 42 | 
            +
                true
         | 
| 43 | 
            +
              end
         | 
| 44 | 
            +
            end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
             | 
| 47 | 
            +
            Oekaki.app width: Width, height: Height, resizable: true do
         | 
| 48 | 
            +
              circles = []
         | 
| 49 | 
            +
              MaxNum.times {circles << Circle.new(self)}
         | 
| 50 | 
            +
              black = color(0, 0, 0)
         | 
| 51 | 
            +
              
         | 
| 52 | 
            +
              draw do
         | 
| 53 | 
            +
                clear(black)
         | 
| 54 | 
            +
              end
         | 
| 55 | 
            +
             | 
| 56 | 
            +
              timer(60) do
         | 
| 57 | 
            +
                clear(black)
         | 
| 58 | 
            +
                circles.each(&:paint)
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              window_changed do
         | 
| 62 | 
            +
                clear(black)
         | 
| 63 | 
            +
                circles.each do |c|
         | 
| 64 | 
            +
                  c.renewal
         | 
| 65 | 
            +
                  c.y = rand(c.height)
         | 
| 66 | 
            +
                  c.paint
         | 
| 67 | 
            +
                end
         | 
| 68 | 
            +
              end
         | 
| 69 | 
            +
            end
         | 
| @@ -0,0 +1,51 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Width, Height = 400, 300
         | 
| 4 | 
            +
            CircumcircleR = 0.8
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            def incircle(a, b, c)
         | 
| 7 | 
            +
              l, m, n = (b - a).norm, (c - b).norm, (a - c).norm
         | 
| 8 | 
            +
              q = l + m + n
         | 
| 9 | 
            +
              
         | 
| 10 | 
            +
              po = a * (m / q) + b * (n / q) + c * (l / q)
         | 
| 11 | 
            +
              r  = sqrt((q / 2 - l) * (q / 2 - m) * (q / 2 - n) * 2 / q)
         | 
| 12 | 
            +
              [po, r]
         | 
| 13 | 
            +
            end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            class Vector
         | 
| 16 | 
            +
              def to_w
         | 
| 17 | 
            +
                l = Height / 2
         | 
| 18 | 
            +
                Vector[Width / 2 + self[0] * l, l - self[1] * l]
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            get_po = proc {|θ| Vector[cos(θ), sin(θ)] * CircumcircleR}
         | 
| 23 | 
            +
            rv  = proc {PI * (rand + 1) * 0.005}
         | 
| 24 | 
            +
             | 
| 25 | 
            +
            angle = [0.5 * 2 * PI, 1.17 * 2 * PI, 1.83 * 2 * PI]
         | 
| 26 | 
            +
            step  = [rv.call, rv.call, -rv.call]
         | 
| 27 | 
            +
             | 
| 28 | 
            +
             | 
| 29 | 
            +
            Oekaki.app width: Width, height: Height do
         | 
| 30 | 
            +
              draw {clear}
         | 
| 31 | 
            +
              
         | 
| 32 | 
            +
              timer(30) do
         | 
| 33 | 
            +
                clear
         | 
| 34 | 
            +
                
         | 
| 35 | 
            +
                a, b, c = get_po[angle[0]], get_po[angle[1]], get_po[angle[2]]
         | 
| 36 | 
            +
                
         | 
| 37 | 
            +
                color(0, 65535, 0)
         | 
| 38 | 
            +
                line(a.to_w[0], a.to_w[1], b.to_w[0], b.to_w[1])
         | 
| 39 | 
            +
                line(b.to_w[0], b.to_w[1], c.to_w[0], c.to_w[1])
         | 
| 40 | 
            +
                line(c.to_w[0], c.to_w[1], a.to_w[0], a.to_w[1])
         | 
| 41 | 
            +
                
         | 
| 42 | 
            +
                color(65535, 0, 65535)
         | 
| 43 | 
            +
                circle(false, Width / 2, Height / 2, CircumcircleR * Height / 2)
         | 
| 44 | 
            +
                
         | 
| 45 | 
            +
                color(65535, 65535, 0)
         | 
| 46 | 
            +
                po, r = incircle(a, b, c)
         | 
| 47 | 
            +
                circle(true, po.to_w[0], po.to_w[1], r * Height / 2)
         | 
| 48 | 
            +
                
         | 
| 49 | 
            +
                angle = angle.map.with_index {|θ, i| θ + step[i]}
         | 
| 50 | 
            +
              end
         | 
| 51 | 
            +
            end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            L, R = 500, 25
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            Oekaki.app width: L, height: L do
         | 
| 6 | 
            +
              draw do
         | 
| 7 | 
            +
                clear
         | 
| 8 | 
            +
              end
         | 
| 9 | 
            +
              
         | 
| 10 | 
            +
              quit_window = proc do 
         | 
| 11 | 
            +
                make_window do |w|
         | 
| 12 | 
            +
                  w.title = ""
         | 
| 13 | 
            +
                  b = button do
         | 
| 14 | 
            +
                    set_size_request(120, 40)
         | 
| 15 | 
            +
                    add(Gtk::Label.new.set_markup('<span size="x-large">Quit!</span>'))
         | 
| 16 | 
            +
                    signal_connect("clicked") {Gtk.main_quit}
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                  add(b)
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              mouse_button do |w, e|
         | 
| 23 | 
            +
                quit_window.call if e.button != 1
         | 
| 24 | 
            +
                color(rand(65536), rand(65536), rand(65536))
         | 
| 25 | 
            +
                arc(true, e.x - R, e.y - R, R * 2, R * 2, 0, 64 * 360) 
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         | 
| @@ -0,0 +1,33 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            L = 300; O = L / 2
         | 
| 4 | 
            +
            R = 140
         | 
| 5 | 
            +
            step = 20
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            i = 0
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Oekaki.app width: L, height: L do
         | 
| 10 | 
            +
              draw do
         | 
| 11 | 
            +
                clear
         | 
| 12 | 
            +
                color(0x87 * 256, 0xce * 256, 0xeb * 256)   #skyblue
         | 
| 13 | 
            +
                arc(false, O - R, O - R, R * 2, R * 2, 0, 64 * 360)
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              id = timer(500) do
         | 
| 17 | 
            +
                ar = []
         | 
| 18 | 
            +
                θ = i * step * PI / 180
         | 
| 19 | 
            +
                x = R * cos(θ)
         | 
| 20 | 
            +
                y = R * sin(θ)
         | 
| 21 | 
            +
                ar << [O + x, O - y]
         | 
| 22 | 
            +
                3.times do
         | 
| 23 | 
            +
                  x, y = -y, x
         | 
| 24 | 
            +
                  ar << [O + x, O - y]
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
                color(0x22 * 256, 0x8b * 256, 0x22 * 256)    #forestgreen
         | 
| 27 | 
            +
                polygon(false, ar)
         | 
| 28 | 
            +
                i += 1
         | 
| 29 | 
            +
                timer_stop(id) if i * step > 180
         | 
| 30 | 
            +
                true
         | 
| 31 | 
            +
              end
         | 
| 32 | 
            +
            end
         | 
| 33 | 
            +
             | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            L = 400
         | 
| 4 | 
            +
            R1 = 150
         | 
| 5 | 
            +
            R2 = (L - R1 * 2) / 2 - 5
         | 
| 6 | 
            +
            STP1 = (PI / 180) * 0.5
         | 
| 7 | 
            +
            STP2 = (PI / 180) * 10
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            Oekaki.app width: L, height: L do
         | 
| 10 | 
            +
              draw do
         | 
| 11 | 
            +
                clear(color(5000, 0, 10000))
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              i = 0
         | 
| 15 | 
            +
              
         | 
| 16 | 
            +
              id = timer(20) do
         | 
| 17 | 
            +
                x = L / 2 + (R1 * cos(STP1 * i) + R2 * cos(STP2 * i))
         | 
| 18 | 
            +
                y = L / 2 - (R1 * sin(STP1 * i) + R2 * sin(STP2 * i))
         | 
| 19 | 
            +
                color(0, 65535, 0)
         | 
| 20 | 
            +
                arc(false, x, y, 3, 3, 0, 64 * 360)
         | 
| 21 | 
            +
                i += 1
         | 
| 22 | 
            +
                timer_stop(id) if STP1 * i > PI * 2
         | 
| 23 | 
            +
                true
         | 
| 24 | 
            +
              end
         | 
| 25 | 
            +
            end
         | 
| @@ -0,0 +1,58 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            L = 400
         | 
| 4 | 
            +
            C_MAX = 65536
         | 
| 5 | 
            +
            C_STEP = 1000
         | 
| 6 | 
            +
             | 
| 7 | 
            +
            class Field
         | 
| 8 | 
            +
              def initialize
         | 
| 9 | 
            +
                @x = rand(L); @y = rand(L)
         | 
| 10 | 
            +
                n = Vector[rand, rand]
         | 
| 11 | 
            +
                @n = [n[0] * 2 / n.norm, n[1] * 2 / n.norm]
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
              attr_reader :x, :y
         | 
| 14 | 
            +
              
         | 
| 15 | 
            +
              def next
         | 
| 16 | 
            +
                @x, @y = @x + @n[0], @y + @n[1]
         | 
| 17 | 
            +
                @n[0] = -@n[0] if @x < 2 or @x >= L - 2
         | 
| 18 | 
            +
                @n[1] = -@n[1] if @y < 2 or @y >= L - 2
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            class Color
         | 
| 23 | 
            +
              def initialize
         | 
| 24 | 
            +
                init
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
              attr_reader :x, :y, :z
         | 
| 27 | 
            +
              
         | 
| 28 | 
            +
              def init
         | 
| 29 | 
            +
                @x = rand(C_MAX); @y = rand(C_MAX); @z = rand(C_MAX)
         | 
| 30 | 
            +
                cn = Vector[rand, rand, rand]
         | 
| 31 | 
            +
                @cn = [cn[0] / cn.norm, cn[1] / cn.norm, cn[2]/ cn.norm]
         | 
| 32 | 
            +
              end
         | 
| 33 | 
            +
              
         | 
| 34 | 
            +
              def next
         | 
| 35 | 
            +
                @x, @y, @z = @x + @cn[0] * C_STEP, @y + @cn[1] * C_STEP, @z + @cn[2] * C_STEP
         | 
| 36 | 
            +
                @cn[0] = -@cn[0] if @x < C_STEP or @x >= C_MAX - C_STEP
         | 
| 37 | 
            +
                @cn[1] = -@cn[1] if @y < C_STEP or @y >= C_MAX - C_STEP
         | 
| 38 | 
            +
                @cn[2] = -@cn[2] if @z < C_STEP or @z >= C_MAX - C_STEP
         | 
| 39 | 
            +
                init if rand < 0.001
         | 
| 40 | 
            +
              end
         | 
| 41 | 
            +
            end
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            pos = Field.new
         | 
| 44 | 
            +
            col = Color.new
         | 
| 45 | 
            +
             | 
| 46 | 
            +
            Oekaki.app width: L, height: L do
         | 
| 47 | 
            +
              draw do
         | 
| 48 | 
            +
                clear
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
              
         | 
| 51 | 
            +
              timer(20) do
         | 
| 52 | 
            +
                color(col.x.to_i, col.y.to_i, col.z.to_i)
         | 
| 53 | 
            +
                arc(true, pos.x.to_i + 2, pos.y.to_i + 2, 4, 4, 0, 64 * 360)
         | 
| 54 | 
            +
                pos.next
         | 
| 55 | 
            +
                col.next
         | 
| 56 | 
            +
                true
         | 
| 57 | 
            +
              end
         | 
| 58 | 
            +
            end
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Oekaki.app width: 400, height: 400 do
         | 
| 4 | 
            +
              draw do
         | 
| 5 | 
            +
                clear
         | 
| 6 | 
            +
                
         | 
| 7 | 
            +
                color(0, 65535, 0)
         | 
| 8 | 
            +
                po = Vector[0, 50]
         | 
| 9 | 
            +
                θ = PI / 15
         | 
| 10 | 
            +
                a = Matrix[[cos(θ), -sin(θ)], [sin(θ), cos(θ)]]
         | 
| 11 | 
            +
                for y in 0..3
         | 
| 12 | 
            +
                  for x in 0..3
         | 
| 13 | 
            +
                    x1 = x * 100 + 50
         | 
| 14 | 
            +
                    y1 = y * 100 + 50
         | 
| 15 | 
            +
                    star(false, x1, y1, x1 + po[0], y1 - po[1])
         | 
| 16 | 
            +
                    po = a * po
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
                end
         | 
| 19 | 
            +
              end
         | 
| 20 | 
            +
            end
         | 
| @@ -0,0 +1,18 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Oekaki.app do
         | 
| 4 | 
            +
              draw do
         | 
| 5 | 
            +
                clear
         | 
| 6 | 
            +
              end
         | 
| 7 | 
            +
                
         | 
| 8 | 
            +
              po = Vector[0, 150]
         | 
| 9 | 
            +
              θ = PI / 50
         | 
| 10 | 
            +
              a = Matrix[[cos(θ), -sin(θ)], [sin(θ), cos(θ)]]
         | 
| 11 | 
            +
              
         | 
| 12 | 
            +
              timer(20) do
         | 
| 13 | 
            +
                clear
         | 
| 14 | 
            +
                color(0, 65535, 0)
         | 
| 15 | 
            +
                star(false, 150, 150, 150 + po[0], 150 - po[1])
         | 
| 16 | 
            +
                po = a * po
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            Width, Height = 400, 300
         | 
| 4 | 
            +
            Turn = 20
         | 
| 5 | 
            +
            Length = 40
         | 
| 6 | 
            +
            Ratio = 0.9
         | 
| 7 | 
            +
            Depth = 8
         | 
| 8 | 
            +
             | 
| 9 | 
            +
            θ = PI * Turn / 180
         | 
| 10 | 
            +
            left  = Matrix[[cos(θ),   -sin(θ)], [sin(θ),   cos(θ)]]
         | 
| 11 | 
            +
            right = Matrix[[cos(-θ), -sin(-θ)], [sin(-θ), cos(-θ)]]
         | 
| 12 | 
            +
             | 
| 13 | 
            +
             | 
| 14 | 
            +
            Oekaki.app width: Width, height: Height, title: "tree" do
         | 
| 15 | 
            +
              draw do
         | 
| 16 | 
            +
                clear
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
              
         | 
| 19 | 
            +
              ar = [[Vector[Width / 2, 1], Vector[0, Length]]]
         | 
| 20 | 
            +
              branch_num = 0
         | 
| 21 | 
            +
              
         | 
| 22 | 
            +
              id = timer(80) do
         | 
| 23 | 
            +
                ob = ar.shift
         | 
| 24 | 
            +
                v1 = left  * ob[1]
         | 
| 25 | 
            +
                v2 = right * ob[1]
         | 
| 26 | 
            +
                p1 = ob[0] + v1
         | 
| 27 | 
            +
                p2 = ob[0] + v2
         | 
| 28 | 
            +
                
         | 
| 29 | 
            +
                color(0, 65535, 0)
         | 
| 30 | 
            +
                line(ob[0][0], Height - ob[0][1], p1[0], Height - p1[1])
         | 
| 31 | 
            +
                line(ob[0][0], Height - ob[0][1], p2[0], Height - p2[1])
         | 
| 32 | 
            +
                
         | 
| 33 | 
            +
                ar << [p1, v1 * Ratio]
         | 
| 34 | 
            +
                ar << [p2, v2 * Ratio]
         | 
| 35 | 
            +
                branch_num += 2
         | 
| 36 | 
            +
                timer_stop(id) if branch_num >= 2 ** (Depth + 1) - 2
         | 
| 37 | 
            +
                true
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            require 'oekaki'
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            R = 7
         | 
| 4 | 
            +
            Width, Height = 500, 500
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            Oekaki.app width: Width, height: Height do
         | 
| 7 | 
            +
              draw do
         | 
| 8 | 
            +
                clear
         | 
| 9 | 
            +
              end
         | 
| 10 | 
            +
              
         | 
| 11 | 
            +
              p = Vector[0, 0]
         | 
| 12 | 
            +
              np = p
         | 
| 13 | 
            +
              deg = 90
         | 
| 14 | 
            +
              r = 0
         | 
| 15 | 
            +
              step = 1.5
         | 
| 16 | 
            +
              
         | 
| 17 | 
            +
              b_line = lambda do |p1, p2|
         | 
| 18 | 
            +
                l = (p2 - p1).r
         | 
| 19 | 
            +
                pt = p1
         | 
| 20 | 
            +
                0.upto(l) do
         | 
| 21 | 
            +
                  color(0, 65535, 0)
         | 
| 22 | 
            +
                  arc(true, Width / 2 + pt[0] - R, Height / 2 - pt[1] - R, R * 2, R * 2, 0, 64 * 360)
         | 
| 23 | 
            +
                  pt += (p2 - p1) / l
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
              
         | 
| 27 | 
            +
              id = timer(50) do
         | 
| 28 | 
            +
                b_line.call(p, np)
         | 
| 29 | 
            +
                
         | 
| 30 | 
            +
                p = np
         | 
| 31 | 
            +
                θ = PI * deg / 180
         | 
| 32 | 
            +
                np = Vector[cos(θ), sin(θ)] * r
         | 
| 33 | 
            +
                r += step
         | 
| 34 | 
            +
                step_d = 20 - r / 35
         | 
| 35 | 
            +
                deg -= step_d
         | 
| 36 | 
            +
                timer_stop(id) if r > 220
         | 
| 37 | 
            +
                true
         | 
| 38 | 
            +
              end
         | 
| 39 | 
            +
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: oekaki
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.1. | 
| 4 | 
            +
              version: 0.1.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - obelisk
         | 
| @@ -31,6 +31,18 @@ extensions: [] | |
| 31 31 | 
             
            extra_rdoc_files: []
         | 
| 32 32 | 
             
            files:
         | 
| 33 33 | 
             
            - README
         | 
| 34 | 
            +
            - example/oekaki_sample1.rb
         | 
| 35 | 
            +
            - example/oekaki_sample10.rb
         | 
| 36 | 
            +
            - example/oekaki_sample12.rb
         | 
| 37 | 
            +
            - example/oekaki_sample14.rb
         | 
| 38 | 
            +
            - example/oekaki_sample2.rb
         | 
| 39 | 
            +
            - example/oekaki_sample3.rb
         | 
| 40 | 
            +
            - example/oekaki_sample4.rb
         | 
| 41 | 
            +
            - example/oekaki_sample5.rb
         | 
| 42 | 
            +
            - example/oekaki_sample6.rb
         | 
| 43 | 
            +
            - example/oekaki_sample7.rb
         | 
| 44 | 
            +
            - example/oekaki_sample8.rb
         | 
| 45 | 
            +
            - example/oekaki_sample9.rb
         | 
| 34 46 | 
             
            - lib/oekaki.rb
         | 
| 35 47 | 
             
            homepage: http://obelisk.hatenablog.com/entry/2016/12/15/172026
         | 
| 36 48 | 
             
            licenses:
         |