rubysketch 0.3.21 → 0.5.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acfaff485263c8e6557c8610df2a4643e53d1046e55cf813c79b648492e84d52
4
- data.tar.gz: d7beb5170988d554771d50d5a726b1f51c961cded8a3cf3370dc55ccc91059fb
3
+ metadata.gz: f9cecc3561d81fdd14730fcdbec957edaac4f5366a9777dc24666a529e539b8f
4
+ data.tar.gz: 588f15db62ccb22206347295c352786470c7d0fee1f3ad169763b6779742b94e
5
5
  SHA512:
6
- metadata.gz: 95ce0e61b8db2f0046bfd43070dd9d10f24b48f7838b267509b98e9a4b6930aa8958c065ae7af253c3877c754a5187ce970b80722421c32e6fbb9de4d1ebc05a
7
- data.tar.gz: a810edf5f210a8a505fc3830697a46a76a743860a90118d1de38e99192d0cf43639dd5410409baf040c4b6feb0275a90d2cb330230b7457890d8555b9f257d5e
6
+ metadata.gz: 379b68cba8c0d8323107092cadccf4cd9ccecb4608036ecac5cb34bf57f531f6e23a18d75aaf9f2dcb2da2da2018d04c182737d919455556204f784b906e9af1
7
+ data.tar.gz: f6427af7756e26b3394458c1701c59ff398dc31fac0faaf03b6f9aa7a4da1eb4c4b9db11121f4d000a7089aad63bffb38f004661e6c723402ab9ad1b52dfce3e
@@ -1,4 +1,4 @@
1
- name: Release
1
+ name: Release Gem
2
2
 
3
3
  on:
4
4
  push:
@@ -9,46 +9,46 @@ jobs:
9
9
  runs-on: macos-latest
10
10
 
11
11
  steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
12
17
  - name: checkout
13
18
  uses: actions/checkout@v2
14
19
 
15
- - name: ruby 3.0
16
- uses: actions/setup-ruby@v1
17
- with:
18
- ruby-version: 3.0.x
20
+ - name: setup dependencies
21
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
19
22
 
20
23
  - name: install gems
21
- run: |
22
- gem install bundler
23
- bundle install --jobs 4 --retry 3
24
+ run: gem install yard
24
25
 
25
- - name: version
26
- id: version
27
- run: |
28
- echo ::set-output name=value::$(ruby -e 'print "${{ github.ref }}"[/\/v([\w\.\-]+)/, 1]')
26
+ - name: test
27
+ run: rake test
29
28
 
30
29
  - name: create gem
31
- run: rake clean gem
30
+ id: gem
31
+ run: |
32
+ rake gem
33
+ echo path=$(ruby -e 'print Dir.glob("*.gem").first') >> $GITHUB_OUTPUT
32
34
 
33
- - name: create release
34
- id: create_release
35
+ - name: create github release
36
+ id: release
35
37
  uses: actions/create-release@v1
36
38
  env:
37
39
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38
40
  with:
39
41
  tag_name: ${{ github.ref }}
40
42
  release_name: ${{ github.ref }}
41
- draft: false
42
- prerelease: false
43
43
 
44
- - name: upload to releases
44
+ - name: upload to github release
45
45
  uses: actions/upload-release-asset@v1
46
46
  env:
47
47
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48
48
  with:
49
- upload_url: ${{ steps.create_release.outputs.upload_url }}
50
- asset_path: ./rubysketch-${{ steps.version.outputs.value }}.gem
51
- asset_name: rubysketch-${{ steps.version.outputs.value }}.gem
49
+ upload_url: ${{ steps.release.outputs.upload_url }}
50
+ asset_path: ./${{ steps.gem.outputs.path }}
51
+ asset_name: ${{ steps.gem.outputs.path }}
52
52
  asset_content_type: application/zip
53
53
 
54
54
  - name: upload to rubygems
@@ -0,0 +1,35 @@
1
+ name: Tag
2
+
3
+ on:
4
+ push:
5
+ branches: [master]
6
+
7
+ jobs:
8
+ tag:
9
+ runs-on: ubuntu-latest
10
+
11
+ steps:
12
+ - name: ruby 3.2
13
+ uses: ruby/setup-ruby@v1
14
+ with:
15
+ ruby-version: 3.2
16
+
17
+ - name: checkout
18
+ uses: actions/checkout@v2
19
+ with:
20
+ fetch-depth: 0
21
+ token: ${{ secrets.PAT }}
22
+
23
+ - name: setup dependencies
24
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies only: :xot'"
25
+
26
+ - name: setup user name and email
27
+ run: |
28
+ git config --global user.email "xordog@gmail.com"
29
+ git config --global user.name "xord"
30
+
31
+ - name: tag versions
32
+ run: "ruby -I.github/workflows -rutils -e 'tag_versions'"
33
+
34
+ - name: push tags
35
+ run: git push origin --tags
@@ -11,17 +11,16 @@ jobs:
11
11
  runs-on: macos-latest
12
12
 
13
13
  steps:
14
- - uses: actions/checkout@v2
15
-
16
- - name: ruby 3.0
17
- uses: actions/setup-ruby@v1
14
+ - name: ruby 3.2
15
+ uses: ruby/setup-ruby@v1
18
16
  with:
19
- ruby-version: 3.0.x
17
+ ruby-version: 3.2
18
+
19
+ - name: checkout
20
+ uses: actions/checkout@v2
20
21
 
21
- - name: install gems
22
- run: |
23
- gem install bundler
24
- bundle install --jobs 4 --retry 3
22
+ - name: setup dependencies
23
+ run: "ruby -I.github/workflows -rutils -e 'setup_dependencies'"
25
24
 
26
25
  - name: test
27
26
  run: rake test
@@ -0,0 +1,55 @@
1
+ RENAMES = {reflex: 'reflexion'}
2
+
3
+ def sh(cmd)
4
+ puts cmd
5
+ system cmd
6
+ end
7
+
8
+ def setup_dependencies(build: true, only: nil)
9
+ gemspec_path = `git ls-files`.lines(chomp: true).find {|l| l =~ /\.gemspec$/}
10
+ return unless gemspec_path
11
+
12
+ gemspec = File.read gemspec_path
13
+ name = File.basename gemspec_path, '.gemspec'
14
+
15
+ exts = File.readlines('Rakefile')
16
+ .map {|l| l[%r|^\s*require\W+(\w+)/extension\W+$|, 1]}
17
+ .compact
18
+ .reject {|ext| ext == name}
19
+ exts = exts & [only].flatten.map(&:to_s) if only
20
+
21
+ exts.each do |ext|
22
+ gem = RENAMES[ext.to_sym].then {|s| s || ext}
23
+ clone = "git clone --depth 1 https://github.com/xord/#{ext}.git ../#{ext}"
24
+ ver = gemspec[/add_runtime_dependency.*['"]#{gem}['"].*['"]\s*~>\s*([\d\.]+)\s*['"]/, 1]
25
+
26
+ # 'rake subtree:push' pushes all subrepos, so cloning by new tag
27
+ # often fails before tagging each new tag
28
+ sh %( #{clone} --branch v#{ver} || #{clone} )
29
+ sh %( cd ../#{ext} && rake ext )
30
+ end
31
+ end
32
+
33
+ def tag_versions()
34
+ tags = `git tag`.lines chomp: true
35
+ vers = `git log --oneline ./VERSION`
36
+ .lines(chomp: true)
37
+ .map {|line| line.split.first[/^\w+$/]}
38
+ .map {|hash| [`git cat-file -p #{hash}:./VERSION 2>/dev/null`[/[\d\.]+/], hash]}
39
+ .select {|ver, hash| ver && hash}
40
+ .reverse
41
+ .to_h
42
+
43
+ changes = File.read('ChangeLog.md')
44
+ .split(/^\s*##\s*\[\s*v([\d\.]+)\s*\].*$/)
45
+ .slice(1..-1)
46
+ .each_slice(2)
47
+ .to_h
48
+ .transform_values(&:strip!)
49
+
50
+ vers.to_a.reverse.each do |ver, hash|
51
+ tag = "v#{ver}"
52
+ break if tags.include?(tag)
53
+ sh %( git tag -a -m \"#{changes[ver]&.gsub '"', '\\"'}\" #{tag} #{hash} )
54
+ end
55
+ end
data/ChangeLog.md CHANGED
@@ -1,159 +1,16 @@
1
- # RubySketch ChangeLog
1
+ # rubysketch ChangeLog
2
2
 
3
3
 
4
- ## [0.3.21] - 2022-x-x
4
+ ## [v0.5.1] - 2023-03-01
5
5
 
6
- - add rubysketch-glsl.rb
7
- - add blend(), createImage(), setTitle(), tint() and noTint()
8
- - add save() that saves screen image to file
9
- - circle() function is affected by ellipseMode()
10
- - point() draws by line(x, y, x, y)
11
- - change initial values for strokeCap and strokeJoin to ROUND and MITER
6
+ - fix bugs
12
7
 
13
8
 
14
- ## [0.3.20] - 2022-07-24
9
+ ## [v0.5.0] - 2023-02-09
15
10
 
16
- - add mouseClicked()
17
- - add blendMode()
18
- - add clip() and noClip()
19
- - translate() can take 'z' parameter
20
- - fix that resizing canvas consumes too much memory
11
+ - add Sprite class
21
12
 
22
13
 
23
- ## [0.3.19] - 2021-12-5
14
+ ## [v0.4.0] - 2023-02-08
24
15
 
25
- - fix runtime error
26
-
27
-
28
- ## [0.3.18] - 2021-12-5
29
-
30
- - add 'mouseButton'
31
- - pointer cancel event calls pointer_up block
32
-
33
-
34
- ## [0.3.17] - 2021-12-5
35
-
36
- - add Touch#id
37
-
38
-
39
- ## [0.3.16] - 2021-2-14
40
-
41
- - add key, keyCode and keyPressed system values
42
- - add keyPressed(), keyReleased() and keyTyped() functions
43
- - add motionGravity value and motion() function
44
-
45
-
46
- ## [0.3.15] - 2020-12-12
47
-
48
- - delete temporary directory on launch
49
-
50
-
51
- ## [0.3.14] - 2020-12-12
52
-
53
- - fix loadImage() fails when Encoding.default_internal is not nil
54
-
55
-
56
- ## [0.3.13] - 2020-12-12
57
-
58
- - size(), createCanvas(): default pixelDensity is same as current value
59
-
60
-
61
- ## [0.3.12] - 2020-12-10
62
-
63
- - size() and createCanvas() take 'pixelDensity' parameter and default value is 1
64
-
65
-
66
- ## [0.3.11] - 2020-12-9
67
-
68
- - add size(), createCanvas() and pixelDensity()
69
-
70
-
71
- ## [0.3.10] - 2020-12-1
72
-
73
- - invert angle parameter value for arc() to fix compatibility to processing API
74
-
75
-
76
- ## [0.3.9] - 2020-11-30
77
-
78
- - Graphics#beginDraw() can take block to call endDraw automatically
79
- - Capture#start() always returns nil
80
- - add delay_camera.rb
81
-
82
-
83
- ## [0.3.8] - 2020-11-27
84
-
85
- - Capture#initialize() can take requestWidth, requestHeight and cameraName
86
- - add Capture#width and Capture#height
87
-
88
-
89
- ## [0.3.7] - 2020-11-18
90
-
91
- - add Capture class
92
- - add log(), exp(), sqrt() and PI
93
- - add examples/camera.rb
94
- - add examples/breakout.rb
95
- - fix error on calling image()
96
-
97
-
98
- ## [0.3.6] - 2020-08-02
99
-
100
- - random() can take array or nothing
101
- - use github actions to release gem package
102
-
103
-
104
- ## [0.3.5] - 2020-08-02
105
-
106
- - add random()
107
- - add sin(), cos(), tan(), asin(), acos(), atan() and atan2()
108
- - make Vector class accessible from user script context
109
- - fix error on calling rotate()
110
-
111
-
112
- ## [0.3.4] - 2020-08-02
113
-
114
- - delete Utility module
115
-
116
-
117
- ## [0.3.3] - 2020-08-01
118
-
119
- - add Vector class
120
-
121
-
122
- ## [0.3.2] - 2020-07-22
123
-
124
- - text() draws to the baseline by default
125
- - add textWidth(), textAscent(), textDescent() and textAlign()
126
- - change initial color for fill() and stroke()
127
- - change initial background color to grayscale 0.8
128
-
129
-
130
- ## [0.3.1] - 2020-07-17
131
-
132
- - add touchStarted(), touchEnded(), touchMoved() and touches()
133
- - make all event handler drawable
134
- - limit font max size to 256
135
-
136
-
137
- ## [0.3.0] - 2020-05-21
138
-
139
- - add createGraphics()
140
-
141
-
142
- ## [0.2.7] - 2020-04-17
143
-
144
- - add strokeCap() and strokeJoin()
145
-
146
-
147
- ## [0.2.6] - 2020-04-17
148
-
149
- - push(), pushMatrix() and pushStyle() take block to automatic pop
150
- - refine startup process
151
- - add curve() and bezier()
152
- - add imageMode(), Image#resize(), Image#copy() and copy()
153
- - add loop(), noLoop() and redraw()
154
-
155
-
156
- ## [0.2.5] - 2020-03-29
157
-
158
- - delete debug prints
159
- - show unsupported image type
16
+ - first version
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2019 xord.org
3
+ Copyright (c) 2023 xord.org
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # RubySketch - Processing compatible Creative Coding Framework
1
+ # RubySketch - A game engine based on the Processing API
2
2
 
3
3
  by xordog@gmail.com
4
4
 
data/Rakefile CHANGED
@@ -1,50 +1,26 @@
1
1
  # -*- mode: ruby -*-
2
2
 
3
3
 
4
- %w[../xot ../rucy ../rays ../reflex .]
4
+ %w[../xot ../rucy ../beeps ../rays ../reflex ../processing .]
5
5
  .map {|s| File.expand_path "#{s}/lib", __dir__}
6
6
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
7
7
 
8
8
  require 'rucy/rake'
9
9
 
10
- require 'xot/module'
11
- require 'rucy/module'
12
- require 'rays/module'
13
- require 'reflex/module'
14
- require 'rubysketch/module'
10
+ require 'xot/extension'
11
+ require 'rucy/extension'
12
+ require 'beeps/extension'
13
+ require 'rays/extension'
14
+ require 'reflex/extension'
15
+ require 'processing/extension'
16
+ require 'rubysketch/extension'
15
17
 
16
18
 
17
- MODULES = [Xot, Rucy, Rays, Reflex, RubySketch]
19
+ EXTENSIONS = [Xot, Rucy, Beeps, Rays, Reflex, Processing, RubySketch]
18
20
 
19
21
  ENV['RDOC'] = 'yardoc --no-private'
20
22
 
23
+ default_tasks
21
24
  test_ruby_extension
22
25
  generate_documents
23
26
  build_ruby_gem
24
-
25
- task :default
26
-
27
-
28
- namespace :version do
29
-
30
- namespace :bump do
31
-
32
- task :major do
33
- update_and_tag_version 0
34
- end
35
-
36
- task :minor do
37
- update_and_tag_version 1
38
- end
39
-
40
- task :patch do
41
- update_and_tag_version 2
42
- end
43
-
44
- task :build do
45
- update_and_tag_version 3
46
- end
47
-
48
- end# bump
49
-
50
- end# version
data/RubySketch.podspec CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  Pod::Spec.new do |s|
5
5
  s.name = "RubySketch"
6
- s.version = File.readlines(File.expand_path 'VERSION', __dir__)[0].chomp
7
- s.summary = "Yet Another Processing implementation for Ruby"
8
- s.description = "Yet Another Processing implementation for Ruby"
6
+ s.version = File.read(File.expand_path 'VERSION', __dir__)[/[\d\.]+/]
7
+ s.summary = "A game engine based on the Processing API"
8
+ s.description = "A game engine based on the Processing API"
9
9
  s.license = "MIT"
10
10
  s.source = {:git => "https://github.com/xord/rubysketch.git"}
11
11
  s.author = {"xordog" => "xordog@gmail.com"}
@@ -18,6 +18,7 @@ Pod::Spec.new do |s|
18
18
  #{s.name}/src
19
19
  CRuby/CRuby/include
20
20
  Reflexion/reflex/include
21
+ RubyProcessing/src
21
22
  ].map {|s| "${PODS_ROOT}/#{s}"}
22
23
 
23
24
  s.preserve_paths = "src"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.21
1
+ 0.5.1
data/examples/hello.rb CHANGED
@@ -1,12 +1,12 @@
1
- %w[xot rays reflex rubysketch]
1
+ %w[xot rays reflex processing rubysketch]
2
2
  .map {|s| File.expand_path "../../#{s}/lib", __dir__}
3
3
  .each {|s| $:.unshift s if !$:.include?(s) && File.directory?(s)}
4
4
 
5
- require 'rubysketch-processing'
6
-
5
+ require 'rubysketch'
6
+ using RubySketch
7
7
 
8
8
  draw do
9
- background 0, 10
10
- textSize 50
11
- text 'hello, world!', mouseX, mouseY
9
+ background 0
10
+ textSize 30
11
+ text "hello, rubysketch!", 10, 100
12
12
  end
@@ -0,0 +1,9 @@
1
+ require 'forwardable'
2
+ require 'processing/all'
3
+
4
+ require 'rubysketch/extension'
5
+ require 'rubysketch/helper'
6
+
7
+ require 'rubysketch/sprite'
8
+ require 'rubysketch/graphics_context'
9
+ require 'rubysketch/context'
@@ -0,0 +1,47 @@
1
+ module RubySketch
2
+
3
+
4
+ class Context < Processing::Context
5
+
6
+ include GraphicsContext
7
+
8
+ def initialize(window)
9
+ super
10
+ @sprites__ = window.add SpritesView.new
11
+ end
12
+
13
+ def createSprite(*args, **kwargs)
14
+ addSprite Sprite.new(*args, **kwargs)
15
+ end
16
+
17
+ def addSprite(sprite)
18
+ @sprites__.add sprite.getInternal__ if sprite
19
+ sprite
20
+ end
21
+
22
+ def removeSprite(sprite)
23
+ @sprites__.remove sprite.getInternal__ if sprite
24
+ sprite
25
+ end
26
+
27
+ def gravity(*args)
28
+ x, y =
29
+ case args
30
+ when Processing::Vector then args.array
31
+ else args
32
+ end
33
+ @sprites__.then do |v|
34
+ v.gravity x * v.meter, y * v.meter
35
+ end
36
+ end
37
+
38
+ class SpritesView < Reflex::View
39
+ def on_draw(e)
40
+ e.block
41
+ end
42
+ end
43
+
44
+ end# Context
45
+
46
+
47
+ end# RubySketch
@@ -1,7 +1,7 @@
1
1
  module RubySketch
2
2
 
3
3
 
4
- module Module
4
+ module Extension
5
5
 
6
6
  module_function
7
7
 
@@ -10,14 +10,14 @@ module RubySketch
10
10
  end
11
11
 
12
12
  def version()
13
- open(root_dir 'VERSION') {|f| f.readline.chomp}
13
+ File.read(root_dir 'VERSION')[/[\d\.]+/]
14
14
  end
15
15
 
16
16
  def root_dir(path = '')
17
17
  File.expand_path "../../#{path}", __dir__
18
18
  end
19
19
 
20
- end# Module
20
+ end# Extension
21
21
 
22
22
 
23
23
  end# RubySketch
@@ -0,0 +1,37 @@
1
+ module RubySketch
2
+
3
+
4
+ module GraphicsContext
5
+
6
+ def sprite(*sprites)
7
+ sprites.flatten! if sprites.first&.is_a? Array
8
+ sprites.each do |sp|
9
+ v = sp.getInternal__
10
+ f, angle, img, offset = v.frame, v.angle, sp.image, sp.offset
11
+ if angle == 0
12
+ drawSprite__ f.x, f.y, f.w, f.h, img, offset
13
+ else
14
+ pushMatrix do
15
+ translate f.x, f.y
16
+ rotate radians(angle)
17
+ drawSprite__ 0, 0, f.w, f.h, img, offset
18
+ end
19
+ end
20
+ end
21
+ end
22
+
23
+ def drawSprite__(x, y, w, h, img, offset)
24
+ if img && offset
25
+ ox, oy = offset
26
+ copy img, ox, oy, w, h, x, y, w, h
27
+ elsif img
28
+ image img, x, y
29
+ else
30
+ rect x, y, w, h
31
+ end
32
+ end
33
+
34
+ end# GraphicsContext
35
+
36
+
37
+ end# RubySketch
@@ -0,0 +1,5 @@
1
+ class Rays::Point
2
+ def toVector()
3
+ Processing::Vector.new x, y, z
4
+ end
5
+ end