Skip to content

Commit 192319b

Browse files
committed
revert to single loop when building grid
1 parent a2b9dc9 commit 192319b

File tree

4 files changed

+15
-8
lines changed

4 files changed

+15
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
**v1.2.9** Grid method now in java (and corrected for step greater than 1)
12

23
**v1.2.8** Properly implement post-initialize (it might be useful). Refactor Sketchbook and OS. Update to processing-3.2.4, if you have not updated samples for a while you should now.
34

lib/jruby_art/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22
# A wrapper for version
33
module JRubyArt
4-
VERSION = '1.2.8'.freeze
4+
VERSION = '1.2.9'.freeze
55
end

pom.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
project 'rp5extras', 'https://github.com/ruby-processing/JRubyArt' do
33

44
model_version '4.0.0'
5-
id 'ruby-processing:rp5extras', '1.2.8'
5+
id 'ruby-processing:rp5extras', '1.2.9'
66
packaging 'jar'
77

88
description 'rp5extras for JRubyArt'

src/monkstone/MathToolModule.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -224,12 +224,18 @@ public static IRubyObject createGrid(ThreadContext context, IRubyObject recv, IR
224224
colStep = (Integer) args[3].toJava(Integer.class);
225225
}
226226
if (block.isGiven()) {
227-
for (int x = 0; x < row / rowStep; x++){
228-
for (int y = 0; y < column / colStep; y++){
229-
block.yieldSpecific(context, context.runtime.newFixnum(x * rowStep), context.runtime.newFixnum(y * colStep));
230-
231-
}
232-
}
227+
// for (int x = 0; x < row / rowStep; x++){
228+
// for (int y = 0; y < column / colStep; y++){
229+
// block.yieldSpecific(context, context.runtime.newFixnum(x * rowStep), context.runtime.newFixnum(y * colStep));
230+
//
231+
// }
232+
// }
233+
int tempRow = row / rowStep;
234+
for (int z = 0; z < (tempRow * (column / colStep)); z++){
235+
int x = z % tempRow;
236+
int y = z / tempRow;
237+
block.yieldSpecific(context, context.runtime.newFixnum(x * rowStep), context.runtime.newFixnum(y * colStep));
238+
}
233239
}
234240
return context.nil;
235241

0 commit comments

Comments
 (0)