sandoz 0.1.0
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 +7 -0
- data/CODE_OF_CONDUCT.md +49 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +49 -0
- data/Rakefile +2 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/p5.js +28547 -0
- data/lib/sandoz.rb +142 -0
- data/lib/sandoz/version.rb +3 -0
- data/sandoz.gemspec +32 -0
- metadata +85 -0
data/lib/sandoz.rb
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
require "sandoz/version"
|
|
2
|
+
require "p5"
|
|
3
|
+
|
|
4
|
+
module Sandoz
|
|
5
|
+
#https://github.com/processing/p5.js/wiki/p5.js-overview#instantiation--namespace
|
|
6
|
+
#todo Add html element argument
|
|
7
|
+
def defsketch(id, &block)
|
|
8
|
+
sketch = Proc.new do |p|
|
|
9
|
+
init(p)
|
|
10
|
+
block.call
|
|
11
|
+
end
|
|
12
|
+
@p5 = `new p5(#{sketch}, #{id})`
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def view_p
|
|
16
|
+
`return #{@p5}`
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def init(p)
|
|
20
|
+
@@p = p
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def size(w, h)
|
|
24
|
+
`#{@@p}.createCanvas(#{w}, #{h})`
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def background(r, g=nil, b=nil)
|
|
28
|
+
if g == nil && b == nil
|
|
29
|
+
`#{@@p}.background(#{r})`
|
|
30
|
+
else
|
|
31
|
+
`#{@@p}.background(#{r}, #{g}, #{b})`
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def fill(r, g=nil, b=nil, a=nil)
|
|
36
|
+
if g==nil && b ==nil
|
|
37
|
+
`#{@@p}.fill(#{r})`
|
|
38
|
+
elsif a == nil
|
|
39
|
+
`#{@@p}.fill(#{r}, #{g}, #{b})`
|
|
40
|
+
else
|
|
41
|
+
`#{@@p}.fill(#{r}, #{g}, #{b}, #{a})`
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def rect(x, y, w, h)
|
|
46
|
+
`#{@@p}.rect(#{x}, #{y}, #{w}, #{h})`
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def ellipse(x, y, w, h)
|
|
50
|
+
`#{@@p}.ellipse(#{x}, #{y}, #{w}, #{h})`
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def width
|
|
54
|
+
`#{@@p}.width`
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def height
|
|
58
|
+
`#{@@p}.height`
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def line(x1, y1, x2, y2)
|
|
62
|
+
`#{@@p}.line(#{x1}, #{y1}, #{x2}, #{y2})`
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def point(x, y)
|
|
66
|
+
`#{@@p}.point(#{x}, #{y})`
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def stroke(r, g=nil, b=nil, a=nil)
|
|
70
|
+
if g==nil && b ==nil
|
|
71
|
+
`#{@@p}.stroke(#{r})`
|
|
72
|
+
elsif a == nil
|
|
73
|
+
`#{@@p}.stroke(#{r}, #{g}, #{b})`
|
|
74
|
+
else
|
|
75
|
+
`#{@@p}.stroke(#{r}, #{g}, #{b}, #{a})`
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def no_stroke
|
|
80
|
+
`#{@@p}.noStroke()`
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
def stroke_weight(weight)
|
|
84
|
+
`#{@@p}.strokeWeight(#{weight})`
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
def setup(&block)
|
|
88
|
+
`#{@@p}.setup = #{block}`
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def draw(&block)
|
|
92
|
+
`#{@@p}.draw = #{block}`
|
|
93
|
+
end
|
|
94
|
+
|
|
95
|
+
def dist(x1, y1, x2, y2)
|
|
96
|
+
`return #{@@p}.dist(x1, y1, x2, y2)`
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
def random(min, max=nil)
|
|
100
|
+
if max
|
|
101
|
+
`return #{@@p}.random(#{min}, #{max})`
|
|
102
|
+
else
|
|
103
|
+
`return #{@@p}.random(#{min})`
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
def color(r, g=nil, b=nil, a=nil)
|
|
108
|
+
if g==nil && b ==nil
|
|
109
|
+
`return #{@@p}.color(#{r})`
|
|
110
|
+
elsif a == nil
|
|
111
|
+
`return #{@@p}.color(#{r}, #{g}, #{b})`
|
|
112
|
+
else
|
|
113
|
+
`return #{@@p}.color(#{r}, #{g}, #{b}, #{a})`
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
def map(value, start1, stop1, start2, stop2)
|
|
118
|
+
`return #{@@p}.map(#{value}, #{start1}, #{stop1}, #{start2}, #{stop2})`
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
def millis
|
|
122
|
+
`return #{@@p}.millis();`
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def no_fill
|
|
126
|
+
`#{@@p}.noFill()`
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
def noise(x, y=nil, z=nil)
|
|
130
|
+
if y == nil && z == nil
|
|
131
|
+
`return #{@@p}.noise(#{x})`
|
|
132
|
+
elsif z == nil
|
|
133
|
+
`return #{@@p}.noise(#{x}, #{y})`
|
|
134
|
+
else
|
|
135
|
+
`return #{@@p}.noise(#{x}, #{y}, #{z})`
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
def text(text, x, y)
|
|
140
|
+
`#{@@p}.text(#{text}, #{x}, #{y})`
|
|
141
|
+
end
|
|
142
|
+
end
|
data/sandoz.gemspec
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'sandoz/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "sandoz"
|
|
8
|
+
spec.version = Sandoz::VERSION
|
|
9
|
+
spec.authors = ["hswick"]
|
|
10
|
+
spec.email = ["hswick@smu.edu"]
|
|
11
|
+
|
|
12
|
+
spec.summary = %q{A Gem Named Sandoz}
|
|
13
|
+
spec.description = %q{Ruby P5 Wrapper to make trippy visuals}
|
|
14
|
+
spec.homepage = "https://github.com/hswick/sandoz"
|
|
15
|
+
spec.license = "MIT"
|
|
16
|
+
|
|
17
|
+
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
|
18
|
+
# delete this section to allow pushing this gem to any host.
|
|
19
|
+
if spec.respond_to?(:metadata)
|
|
20
|
+
spec.metadata['allowed_push_host'] = "https://rubygems.org/"
|
|
21
|
+
else
|
|
22
|
+
raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
26
|
+
spec.bindir = "exe"
|
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
28
|
+
spec.require_paths = ["lib"]
|
|
29
|
+
|
|
30
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
|
31
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
|
32
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: sandoz
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- hswick
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: exe
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: bundler
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: '1.11'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.11'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '10.0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '10.0'
|
|
41
|
+
description: Ruby P5 Wrapper to make trippy visuals
|
|
42
|
+
email:
|
|
43
|
+
- hswick@smu.edu
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- CODE_OF_CONDUCT.md
|
|
49
|
+
- Gemfile
|
|
50
|
+
- Gemfile.lock
|
|
51
|
+
- LICENSE.txt
|
|
52
|
+
- README.md
|
|
53
|
+
- Rakefile
|
|
54
|
+
- bin/console
|
|
55
|
+
- bin/setup
|
|
56
|
+
- lib/p5.js
|
|
57
|
+
- lib/sandoz.rb
|
|
58
|
+
- lib/sandoz/version.rb
|
|
59
|
+
- sandoz.gemspec
|
|
60
|
+
homepage: https://github.com/hswick/sandoz
|
|
61
|
+
licenses:
|
|
62
|
+
- MIT
|
|
63
|
+
metadata:
|
|
64
|
+
allowed_push_host: https://rubygems.org/
|
|
65
|
+
post_install_message:
|
|
66
|
+
rdoc_options: []
|
|
67
|
+
require_paths:
|
|
68
|
+
- lib
|
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - ">="
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0'
|
|
74
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
|
+
requirements:
|
|
76
|
+
- - ">="
|
|
77
|
+
- !ruby/object:Gem::Version
|
|
78
|
+
version: '0'
|
|
79
|
+
requirements: []
|
|
80
|
+
rubyforge_project:
|
|
81
|
+
rubygems_version: 2.4.5.1
|
|
82
|
+
signing_key:
|
|
83
|
+
specification_version: 4
|
|
84
|
+
summary: A Gem Named Sandoz
|
|
85
|
+
test_files: []
|