ruby2d 0.6.0 → 0.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bbdaa086d718eacee3d9af77fd86b464ebf8cbb4db4bfbf796663c6fbbbd491c
4
- data.tar.gz: 6167710b57e59b5635b3818687ca94175b98ab7d05c94bbd55d9fbf6744f299b
3
+ metadata.gz: aba47e3b04390bdf27cf2480419d09173683eca948a494790c5bc5c617b9ffbf
4
+ data.tar.gz: 8dff61a42195fdcb9d87bbfa35981c80a91ad4b4e0a61d72b9821fac479dc913
5
5
  SHA512:
6
- metadata.gz: 2a8e81e3f9313feaeda6e45e24b06c8bcf7c4e1436635dc06ea8504448a6f8734174c3c2c55fc6678ff2e48522aebe1bd8e6d9ab8aa670da683373473f7f8270
7
- data.tar.gz: 4f31cf8d067c851de3a043a7716803e42c37bb4144a55087fce61b2270e53dc94130a3e87b6943b7e07625b4024c7640a9c357bbc5d15253cda8adacd1e95d74
6
+ metadata.gz: 87e61972f9877759df9623c3e5cd4d5141ccb8fd743f59de30359be9c4be37fbf4158a72e8b641f17847af135d5df4d523f28607341ea694a695e5566adb9906
7
+ data.tar.gz: 301dae8cf14f3b85eb5c9fe0bf6925d058330cbaa9d1ee33dd6b4272cf948b2cf4ecc845c188b0e95e342bd253bea02a07afcc265656ef9657992a8d47dbab35
data/bin/ruby2d CHANGED
@@ -6,6 +6,7 @@ require 'fileutils'
6
6
  class String
7
7
  def colorize(c); "\e[#{c}m#{self}\e[0m" end
8
8
  def bold; colorize('1') end
9
+ def warn; colorize('1;33') end
9
10
  def error; colorize('1;31') end
10
11
  end
11
12
 
@@ -27,6 +28,7 @@ end
27
28
  'triangle',
28
29
  'image',
29
30
  'sprite',
31
+ 'font',
30
32
  'text',
31
33
  'sound',
32
34
  'music'
@@ -119,6 +121,9 @@ end
119
121
 
120
122
  # Build a web-based version of the provided Ruby application
121
123
  def build_web(rb_file)
124
+ puts "Warning: ".warn + "This feature is currently disabled while it's being upgraded."
125
+ return
126
+
122
127
  check_build_src_file(rb_file)
123
128
 
124
129
  # Assemble the Ruby 2D library in one `.rb` file and compile to JS
@@ -290,6 +295,7 @@ To compile and create a native executable, use:
290
295
 
291
296
  To build for the web, creating a JavaScript and HTML package, use:
292
297
  build --web <ruby_file>
298
+ #{"Warning:".warn} #{"This feature is currently disabled while it's being upgraded.".bold}
293
299
 
294
300
  To build an iOS or tvOS app, use the following:
295
301
  build --ios <ruby_file>
@@ -74,7 +74,10 @@ end
74
74
  check_s2d_version
75
75
 
76
76
  # Add flags
77
- $CFLAGS << ' -std=c11 -I/usr/local/include'
77
+ $CFLAGS << ' -std=c11 -I/usr/local/include'
78
+ if `cat /etc/os-release` =~ /raspbian/ # Raspberry Pi
79
+ $CFLAGS << ' -I/opt/vc/include'
80
+ end
78
81
  $LDFLAGS << ' ' << `bash simple2d --libs`
79
82
  $LDFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they cause problems
80
83
 
data/lib/ruby2d.rb CHANGED
@@ -13,6 +13,7 @@ require 'ruby2d/square'
13
13
  require 'ruby2d/triangle'
14
14
  require 'ruby2d/image'
15
15
  require 'ruby2d/sprite'
16
+ require 'ruby2d/font'
16
17
  require 'ruby2d/text'
17
18
  require 'ruby2d/sound'
18
19
  require 'ruby2d/music'
@@ -0,0 +1,54 @@
1
+ # Ruby2D::Font
2
+
3
+ module Ruby2D
4
+ class Font
5
+
6
+ class << self
7
+
8
+ # List all fonts, names only
9
+ def all
10
+ all_paths.map { |path| path.split('/').last.chomp('.ttf').downcase }.uniq.sort
11
+ end
12
+
13
+ # Find a font file path from its name
14
+ def path(font_name)
15
+ all_paths.find { |path| path.downcase.include?(font_name) }
16
+ end
17
+
18
+ # Get all fonts with full file paths
19
+ def all_paths
20
+ fonts = `find #{directory} -name *.ttf`.split("\n")
21
+ fonts = fonts.reject do |f|
22
+ f.downcase.include?('bold') ||
23
+ f.downcase.include?('italic') ||
24
+ f.downcase.include?('oblique') ||
25
+ f.downcase.include?('narrow') ||
26
+ f.downcase.include?('black')
27
+ end
28
+ fonts.sort_by { |f| f.downcase.chomp '.ttf' }
29
+ end
30
+
31
+ # Get the default font
32
+ def default
33
+ if all.include? 'arial'
34
+ path 'arial'
35
+ else
36
+ all_paths.first
37
+ end
38
+ end
39
+
40
+ # Get the fonts directory for the current platform
41
+ def directory
42
+ if `uname`.include? 'Darwin' # macOS
43
+ "/Library/Fonts"
44
+ elsif `uname`.include? 'Linux'
45
+ "/usr/share/fonts/truetype"
46
+ elsif `uname`.include? 'MINGW'
47
+ "C:/Windows/Fonts"
48
+ end
49
+ end
50
+
51
+ end
52
+
53
+ end
54
+ end
data/lib/ruby2d/text.rb CHANGED
@@ -14,7 +14,7 @@ module Ruby2D
14
14
  @text = (opts[:text] || "Hello Ruby!").to_s
15
15
  @size = opts[:size] || 20
16
16
  @rotate = opts[:rotate] || 0
17
- @font = opts[:font]
17
+ @font = opts[:font] || Font.default
18
18
 
19
19
  unless RUBY_ENGINE == 'opal'
20
20
  unless File.exists? @font
@@ -1,5 +1,5 @@
1
1
  # Ruby2D::VERSION
2
2
 
3
3
  module Ruby2D
4
- VERSION = '0.6.0'
4
+ VERSION = '0.6.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2d
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Black
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-28 00:00:00.000000000 Z
11
+ date: 2018-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: opal
@@ -155,6 +155,7 @@ files:
155
155
  - lib/ruby2d/color.rb
156
156
  - lib/ruby2d/dsl.rb
157
157
  - lib/ruby2d/exceptions.rb
158
+ - lib/ruby2d/font.rb
158
159
  - lib/ruby2d/image.rb
159
160
  - lib/ruby2d/line.rb
160
161
  - lib/ruby2d/music.rb