rubysketch 0.1.5 → 0.2.0

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: 2ab78b7cd8bbbeedb31234160054509bd9c55de56bce0f7a9251f75fbe60d22b
4
- data.tar.gz: 555fff0c98f8d55cc71fcc6923a63ffa521a591a169abd2a8b71901e8dd7401c
3
+ metadata.gz: 8c2d5e6b27dba3d165c946db3fc7cbe09630be01a5dd86238433e6e3b7126138
4
+ data.tar.gz: b0565c883e6821f133d64428507fc7d39eaf06f5a11fb634a1a205b25856d77b
5
5
  SHA512:
6
- metadata.gz: 0a7d3a9f9b3b229eae77484d7a9b59813fee6eb5f8225264e515f5dd131914c642fa9fcf1a3eb28839a65f395b24afe1c7acefc46a36e877fd3babc6fd9c6d6e
7
- data.tar.gz: e7239c1aa04a9ee8ecec79df21efd4c9dbc5004c7814b58a35799abb33ce253f10279a5c899a6442ec3a7553956c13497e452f2da36ad50ad20265f0d1ac7bf5
6
+ metadata.gz: 63553c43e5fd2433e7b395aae2b57415b9cc7091a8cbe07934fddede1569383161e73822f6614daa479dde3ef1606d33c545b067ceefbd66ce0c7133149f0ac1
7
+ data.tar.gz: be2980a7909244174e52f619ec1e80a77a85483501837e59a5ddea84652792b3718402d1ca9a1201058847770dca9a34e315fbdf58ec2033794bd6438100a12e
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.5
1
+ 0.2.0
@@ -2,7 +2,7 @@ module RubySketch
2
2
 
3
3
 
4
4
  # @private
5
- class GLSL1
5
+ class GLSL
6
6
 
7
7
  extend Starter
8
8
 
@@ -27,10 +27,7 @@ module RubySketch
27
27
  end
28
28
  end
29
29
 
30
- end# GLSL1
31
-
32
-
33
- GLSL = GLSL1
30
+ end# GLSL
34
31
 
35
32
 
36
33
  end# RubySketch
@@ -1,9 +1,9 @@
1
1
  module RubySketch
2
2
 
3
3
 
4
- # Processing compatible API v1
4
+ # Processing compatible API
5
5
  #
6
- class Processing1
6
+ class Processing
7
7
 
8
8
  include Math
9
9
 
@@ -43,11 +43,12 @@ module RubySketch
43
43
 
44
44
  # @private
45
45
  def initialize ()
46
+ @matrixStack__ = []
47
+ @styleStack__ = []
46
48
  @frameCount__ = 0
47
49
  @hsbColor__ = false
48
50
  @colorMaxes__ = [1.0] * 4
49
51
  @angleScale__ = 1.0
50
- @styleStack = []
51
52
  @mouseX__ =
52
53
  @mouseY__ =
53
54
  @mousePrevX__ =
@@ -296,9 +297,14 @@ module RubySketch
296
297
  def setupDrawBlock__ ()
297
298
  @window__.draw = proc do |e, painter|
298
299
  @painter__ = painter
299
- pushStyle
300
- @drawBlock__.call e if @drawBlock__
301
- popStyle
300
+ @matrixStack__.clear
301
+ @styleStack__.clear
302
+ begin
303
+ push
304
+ @drawBlock__.call e if @drawBlock__
305
+ ensure
306
+ pop
307
+ end
302
308
  @frameCount__ += 1
303
309
  updateMousePrevPos__
304
310
  end
@@ -919,7 +925,7 @@ module RubySketch
919
925
  # @return [nil] nil
920
926
  #
921
927
  def pushMatrix ()
922
- @painter__.push_matrix
928
+ @matrixStack__.push @painter__.matrix
923
929
  nil
924
930
  end
925
931
 
@@ -928,7 +934,8 @@ module RubySketch
928
934
  # @return [nil] nil
929
935
  #
930
936
  def popMatrix ()
931
- @painter__.pop_matrix
937
+ raise "Matrix stack underflow" if @matrixStack__.empty?
938
+ @painter__.matrix = @matrixStack__.pop
932
939
  nil
933
940
  end
934
941
 
@@ -946,8 +953,11 @@ module RubySketch
946
953
  # @return [nil] nil
947
954
  #
948
955
  def pushStyle ()
949
- @painter__.push_state
950
- @styleStack.push [
956
+ @styleStack__.push [
957
+ @painter__.fill,
958
+ @painter__.stroke,
959
+ @painter__.stroke_width,
960
+ @painter__.font,
951
961
  @hsbColor__,
952
962
  @colorMaxes__,
953
963
  @angleScale__,
@@ -962,9 +972,16 @@ module RubySketch
962
972
  # @return [nil] nil
963
973
  #
964
974
  def popStyle ()
965
- @painter__.pop_state
966
- @hsbColor__, @colorMaxes__, @angleScale__, @rectMode__, @ellipseMode__ =
967
- @styleStack.pop
975
+ raise "Style stack underflow" if @styleStack__.empty?
976
+ @painter__.fill,
977
+ @painter__.stroke,
978
+ @painter__.stroke_width,
979
+ @painter__.font,
980
+ @hsbColor__,
981
+ @colorMaxes__,
982
+ @angleScale__,
983
+ @rectMode__,
984
+ @ellipseMode__ = @styleStack__.pop
968
985
  nil
969
986
  end
970
987
 
@@ -1000,75 +1017,74 @@ module RubySketch
1000
1017
  Rays.perlin(x, y) / 2.0 + 1.0
1001
1018
  end
1002
1019
 
1003
- # Font object.
1020
+ end# Processing
1021
+
1022
+
1023
+ # Font object.
1024
+ #
1025
+ class Processing::Font
1026
+
1027
+ # Initialize font.
1028
+ #
1029
+ # @private
1004
1030
  #
1005
- class Font
1031
+ def initialize (font)
1032
+ @font = font
1033
+ end
1006
1034
 
1007
- # Initialize font.
1008
- #
1009
- # @private
1010
- #
1011
- def initialize (font)
1012
- @font = font
1013
- end
1035
+ # Returns bounding box.
1036
+ #
1037
+ # @overload textBounds(str)
1038
+ # @overload textBounds(str, x, y)
1039
+ # @overload textBounds(str, x, y, fontSize)
1040
+ #
1041
+ # @param str [String] text to calculate bounding box
1042
+ # @param x [Numeric] horizontal position of bounding box
1043
+ # @param y [Numeric] vertical position of bounding box
1044
+ # @param fontSize [Numeric] font size
1045
+ #
1046
+ # @return [TextBounds] bounding box for text
1047
+ #
1048
+ def textBounds (str, x = 0, y = 0, fontSize = nil)
1049
+ f = fontSize ? Rays::Font.new(@font.name, fontSize) : @font
1050
+ TextBounds.new x, y, x + f.width(str), y + f.height
1051
+ end
1014
1052
 
1015
- # Returns bounding box.
1016
- #
1017
- # @overload textBounds(str)
1018
- # @overload textBounds(str, x, y)
1019
- # @overload textBounds(str, x, y, fontSize)
1020
- #
1021
- # @param str [String] text to calculate bounding box
1022
- # @param x [Numeric] horizontal position of bounding box
1023
- # @param y [Numeric] vertical position of bounding box
1024
- # @param fontSize [Numeric] font size
1025
- #
1026
- # @return [TextBounds] bounding box for text
1027
- #
1028
- def textBounds (str, x = 0, y = 0, fontSize = nil)
1029
- f = fontSize ? Rays::Font.new(@font.name, fontSize) : @font
1030
- TextBounds.new x, y, x + f.width(str), y + f.height
1031
- end
1053
+ end# Processing::Font
1032
1054
 
1033
- # Bounding box for text.
1034
- #
1035
- class TextBounds
1036
-
1037
- # Horizontal position
1038
- #
1039
- attr_reader :x
1040
-
1041
- # Vertical position
1042
- #
1043
- attr_reader :y
1044
-
1045
- # Width of bounding box
1046
- #
1047
- attr_reader :w
1048
-
1049
- # Height of bounding box
1050
- #
1051
- attr_reader :h
1052
-
1053
- # Initialize bouding box.
1054
- #
1055
- # @param x [Numeric] horizontal position
1056
- # @param y [Numeric] vertical position
1057
- # @param w [Numeric] width of bounding box
1058
- # @param h [Numeric] height of bounding box
1059
- #
1060
- def initialize (x, y, w, h)
1061
- @x, @y, @w, @h = x, y, w, h
1062
- end
1063
1055
 
1064
- end# TextBounds
1056
+ # Bounding box for text.
1057
+ #
1058
+ class Processing::TextBounds
1059
+
1060
+ # Horizontal position
1061
+ #
1062
+ attr_reader :x
1063
+
1064
+ # Vertical position
1065
+ #
1066
+ attr_reader :y
1065
1067
 
1066
- end# Font
1068
+ # Width of bounding box
1069
+ #
1070
+ attr_reader :w
1067
1071
 
1068
- end# Processing1
1072
+ # Height of bounding box
1073
+ #
1074
+ attr_reader :h
1069
1075
 
1076
+ # Initialize bouding box.
1077
+ #
1078
+ # @param x [Numeric] horizontal position
1079
+ # @param y [Numeric] vertical position
1080
+ # @param w [Numeric] width of bounding box
1081
+ # @param h [Numeric] height of bounding box
1082
+ #
1083
+ def initialize (x, y, w, h)
1084
+ @x, @y, @w, @h = x, y, w, h
1085
+ end
1070
1086
 
1071
- Processing = Processing1
1087
+ end# Processing::TextBounds
1072
1088
 
1073
1089
 
1074
1090
  end# RubySketch
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysketch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-18 00:00:00.000000000 Z
11
+ date: 2020-03-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yard