Skip to content

Commit 2929c95

Browse files
committed
2 parents 41cc568 + c77ffe4 commit 2929c95

File tree

2 files changed

+18
-16
lines changed

2 files changed

+18
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# picrate-examples
2-
Examples for picrate see also picrate-examples (as they are easily translated). Can be autorun with `rake`. The contributed folder exists for you to add your own (and submit as a PR). Ordinarily we expect users to install these examples with `picrate -i samples` or for first time users `picrate --install` which also installs `geany` configuration. If you use `geany` as your editor, will be able to run files from the editor, to run individual sketches from command line `cd` to folder of sketch and `jruby --dev your_sketch.rb`. Passing the `--dev` flag speeds `jruby` start-up.
2+
Examples for picrate see also JRubyArt-examples (as they are easily translated). Can be autorun with `rake`. The contributed folder exists for you to add your own (and submit as a PR). Ordinarily we expect users to install these examples with `picrate -i samples` or for first time users `picrate --install` which also installs `geany` configuration. If you use `geany` as your editor, will be able to run files from the editor, to run individual sketches from command line `cd` to folder of sketch and `jruby --dev your_sketch.rb`. Passing the `--dev` flag speeds `jruby` start-up.

shaders/bw_shader.rb

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# frozen_string_literal: true
2+
13
require 'picrate'
24

35
class BwShader < Processing::App
@@ -21,29 +23,29 @@ def setup
2123
def draw
2224
background(0)
2325
shader(bw_shader)
24-
translate(width/2, height/2)
26+
translate(width / 2, height / 2)
2527
rotate_y(angle)
2628
shape(can)
2729
@angle += 0.01
2830
end
2931

3032
def create_can(r, h, detail, tex)
3133
texture_mode(NORMAL)
32-
sh = create_shape
33-
sh.begin_shape(QUAD_STRIP)
34-
sh.no_stroke
35-
sh.texture(tex)
36-
(0..detail).each do |i|
37-
angle = TAU / detail
38-
x = sin(i * angle)
39-
z = cos(i * angle)
40-
u = i.to_f / detail
41-
sh.normal(x, 0, z)
42-
sh.vertex(x * r, -h/2, z * r, u, 0)
43-
sh.vertex(x * r, +h/2, z * r, u, 1)
34+
create_shape.tap do |sh|
35+
sh.begin_shape(QUAD_STRIP)
36+
sh.no_stroke
37+
sh.texture(tex)
38+
(0..detail).each do |i|
39+
angle = TAU / detail
40+
x = sin(i * angle)
41+
z = cos(i * angle)
42+
u = i.to_f / detail
43+
sh.normal(x, 0, z)
44+
sh.vertex(x * r, -h / 2, z * r, u, 0)
45+
sh.vertex(x * r, +h / 2, z * r, u, 1)
46+
end
47+
sh.end_shape
4448
end
45-
sh.end_shape
46-
sh
4749
end
4850
end
4951

0 commit comments

Comments
 (0)