Skip to content

Commit b60a993

Browse files
author
monkstone
committed
fix dodgy logic in Rect.containsPoint
1 parent c27064a commit b60a993

File tree

9 files changed

+40
-12
lines changed

9 files changed

+40
-12
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
**v0.5.1** Mainly corrections.
2+
**v0.6.0** Some corrections to the Rect and Vec3D contains logic (mea culpa, caued by injudicious refactoring)
33

44
**v0.5.0** New version toxiclibs update to use jdk8 syntax, require jdk8 and probably therefore JRubyArt only new MeshToVBO class.
55

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ gem install toxiclibs
77

88
### NB: Use version 0.4 for ruby-processing
99

10-
Here I have created create a gem to use Karsten Schmidts (aka toxi, @postspectacular) toxiclibs jars in JRubyArt. To compile the gem follow the instructions for [JRubyArt][]. Most parts of toxiclibs API is exposed in the latest version, (but only a few examples are included) in principle it should be possible to make all available!!! For this demonstration I have used up to date source code for version 21, since [toxis final release][] may never materialise (he's probably got more interesting things to do). There are reported to be number of outstanding bugs with toxiclibs, if they affect you report it [here][] (or better fix them yourself and submit a pull request). Version 0.5.0 features java code updated to use java lambda (jdk8) and was compiled against processing-3.0.1 core.jar. Added features are export Mesh to PShape and export Mesh to [povray mesh2](http://www.povray.org/documentation/3.7.0/r3_4.html#r3_4_5_2_4).
10+
Here I have created create a gem to use Karsten Schmidts (aka toxi, @postspectacular) toxiclibs jars in JRubyArt. To compile the gem follow the instructions for [JRubyArt][]. Most parts of toxiclibs API is exposed in the latest version, (but only a few examples are included) in principle it should be possible to make all available!!! For this demonstration I have used up to date source code for version 21, since [toxis final release][] may never materialise (he's probably got more interesting things to do). There are reported to be number of outstanding bugs with toxiclibs, if they affect you report it [here][] (or better fix them yourself and submit a pull request). Version 0.5.0+ features java code updated to use java lambda (jdk8) and was compiled against processing-3.0.1 core.jar. Added features are export Mesh to PShape and export Mesh to [povray mesh2](http://www.povray.org/documentation/3.7.0/r3_4.html#r3_4_5_2_4).
1111

1212
![grayscott image](http://4.bp.blogspot.com/-d4MiL4_0Njk/VFJMv6VUicI/AAAAAAAAEgY/fFAfrXDxNXM/s400/grayscott.png)
1313

examples/test_rect.rb

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
require 'toxiclibs'
2+
3+
attr_reader :points, :bounds, :gfx
4+
5+
def settings
6+
size(400,400)
7+
end
8+
9+
def setup
10+
sketch_title 'Test Rect'
11+
@points = []
12+
@bounds = Toxi::Rect.new(200, 200, 0, 0)
13+
@gfx = Gfx::ToxiclibsSupport.new(self)
14+
end
15+
16+
def draw
17+
background(255)
18+
no_fill
19+
stroke(0)
20+
gfx.rect(bounds)
21+
fill(255, 0, 0)
22+
no_stroke
23+
points.each { |p| gfx.circle(p, 5) }
24+
end
25+
26+
def mouse_pressed
27+
p = TVec2D.new(mouse_x, mouse_y)
28+
points << p
29+
bounds.grow_to_contain_point(p)
30+
end

lib/toxiclibs/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Toxiclibs
2-
VERSION = '0.5.1'.freeze
2+
VERSION = '0.6.0'.freeze
33
end

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.ruby-processing</groupId>
55
<artifactId>toxiclibs</artifactId>
6-
<version>0.5.0</version>
6+
<version>0.6.0</version>
77
<packaging>jar</packaging>
88
<description>
99
toxiclibs-library for JRubyArt

src/toxi/geom/Rect.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ public boolean containsPoint(ReadonlyVec2D p) {
146146
if (px < x || px > x + width) {
147147
return false;
148148
}
149-
return (py >= y || py <= y + height);
149+
return (py >= y && py <= y + height);
150150
}
151151

152152
/**

src/toxi/geom/Vec2D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -743,7 +743,7 @@ public boolean isInRectangle(Rect r) {
743743
if (x < r.x || x > r.x + r.width) {
744744
return false;
745745
}
746-
return (y >= r.y || y <= r.y + r.height);
746+
return (y >= r.y && y <= r.y + r.height);
747747
}
748748

749749
@Override

src/toxi/geom/Vec3D.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ public boolean isInAABB(Vec3D boxOrigin, Vec3D boxExtent) {
994994
return false;
995995
}
996996
w = boxExtent.z;
997-
return (z > boxOrigin.z - w || z < boxOrigin.z + w);
997+
return (z >= boxOrigin.z - w && z <= boxOrigin.z + w);
998998
}
999999

10001000
@Override

toxiclibs.gemspec

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,16 @@ Gem::Specification.new do |spec|
1717
spec.licenses = %w{MIT LGPL-3.0}
1818
spec.authors = %w{Karsten\ Schmidt Martin\ Prout}
1919
spec.email = 'martin_p@lineone.net'
20-
spec.homepage = 'https://github.com/ruby-processing/toxiclibs'
20+
spec.homepage = 'http://ruby-processing.github.io/toxicgem/'
2121
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
2222
spec.files << 'lib/toxiclibs.jar'
2323
spec.files << 'lib/args4j-2.0.31.jar'
2424
spec.require_paths = ['lib']
25-
spec.add_dependency 'jruby_art', '~> 1.0'
26-
spec.add_development_dependency "rake", "~> 10.0"
27-
spec.add_development_dependency "minitest", "~> 5.8"
25+
spec.add_dependency 'jruby_art', '~> 1.0', '>= 1.0.1'
26+
spec.add_development_dependency 'rake', '~> 10.4', '>= 10.4.2'
2827
spec.platform = 'java'
2928
spec.requirements << 'A decent graphics card'
3029
spec.requirements << 'java runtime >= 1.8+'
3130
spec.requirements << 'processing = 3.0.1+'
3231
spec.requirements << 'maven = 3.3.3'
33-
spec.requirements << 'jruby_art = 1.0+'
3432
end

0 commit comments

Comments
 (0)