Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit bbbab0c

Browse files
committed
use Signal instead of Input. See JuliaGizmos/Reactive.jl#65
1 parent 18d281a commit bbbab0c

31 files changed

+154
-82
lines changed

examples/image_processing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ vec2i(vec::Vec) = vec2i(vec...)
2020
function screen(robj, w)
2121
bb = boundingbox(robj).value
2222
m = vec2i(bb.minimum)
23-
area = Input(Rectangle{Int}(0,0, ((vec2i(bb.maximum)-m)+30)...))
23+
area = Signal(Rectangle{Int}(0,0, ((vec2i(bb.maximum)-m)+30)...))
2424
view(visualize(area, style=Cint(OUTLINED)), method=:fixed_pixel)
2525
robj[:model] = translationmatrix(Vec3f0(15,15,0)-bb.minimum)
2626
view(robj, method=:fixed_pixel)

examples/juliaset.jl

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,48 @@
1+
meshgrid(v::AbstractVector) = meshgrid(v, v)
2+
3+
function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T})
4+
m, n = length(vy), length(vx)
5+
vx = reshape(vx, 1, n)
6+
vy = reshape(vy, m, 1)
7+
(repmat(vx, m, 1), repmat(vy, 1, n))
8+
end
9+
10+
function meshgrid{T}(vx::AbstractVector{T}, vy::AbstractVector{T},
11+
vz::AbstractVector{T})
12+
m, n, o = length(vy), length(vx), length(vz)
13+
vx = reshape(vx, 1, n, 1)
14+
vy = reshape(vy, m, 1, 1)
15+
vz = reshape(vz, 1, 1, o)
16+
om = ones(Int, m)
17+
on = ones(Int, n)
18+
oo = ones(Int, o)
19+
(vx[om, :, oo], vy[:, on, oo], vz[om, on, :])
20+
end
21+
122
# Calculate the Julia set on a grid
2-
x = [Float32(i)*im for i=-1.5:0.5:500]
3-
y = [Float32(i)*im for i=-1:1:500]
23+
x,y = meshgrid(-1.5f0:0.5f0:500f0, -1f0:1f0:500f0)
24+
x *= 1im
25+
y *= 1im
426
println(size(x))
527
println(size(y))
628
z = x + 1im * y
729

8-
julia = zeros(Float32, size(z))
30+
const julia = zeros(Float32, size(z))
931

1032
for i=1:50
11-
z = z^2 - 0.70176 - 0.3842im
12-
julia += 1 / 2f0 + i) * (z * conj(z) > 4)
33+
for i in eachindex(julia)
34+
z[i] = (z[i]^2) - 0.70176 - 0.3842im
35+
x = (z[i] * (real(conj(z[i])) > 4))
36+
julia[i] += real(1f0 / (2f0 + i) * x)
37+
end
1338
end
14-
39+
maxval = maximum(julia)
40+
map!(julia ) do val
41+
val / maxval
42+
end
43+
using GLVisualize
44+
w,r =glscreen()
1545
# Display it
1646
view(visualize(julia))
1747

18-
# A view into the "Canyon"
19-
view(65, 27, 322, [30., -13.7, 136])
20-
show()
21-
48+
r()

examples/mario.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ const mario_images = Dict()
4747
play{T}(array::Array{T, 3}, slice) = array[:, :, slice]
4848

4949

50-
signify{T}(x::Array{T, 2}) = Input(x)
50+
signify{T}(x::Array{T, 2}) = Signal(x)
5151
function signify{T}(x::Array{T, 3})
5252
const_lift(play, x, loop(1:size(x, 3)))
5353
end

examples/tests/minimal_test.jl

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ function visualize_default(grid::Union{Texture{Float32, 2}, Matrix{Float32}})
188188
:grid_max => grid_max,
189189
:scale => scale,
190190
:norm => Vec2f0(0, 5),
191-
:model => Input(eye(Mat4f0)),
192-
:light => Input(Vec3f0[Vec3f0(1.0,1.0,1.0), Vec3f0(0.1,0.1,0.1), Vec3f0(0.9,0.9,0.9), Vec3f0(20,20,20)]),
191+
:model => Signal(eye(Mat4f0)),
192+
:light => Signal(Vec3f0[Vec3f0(1.0,1.0,1.0), Vec3f0(0.1,0.1,0.1), Vec3f0(0.9,0.9,0.9), Vec3f0(20,20,20)]),
193193
:preferred_camera => :perspective
194194
)
195195
end
@@ -207,9 +207,9 @@ function visualize(grid::Texture{Float32, 2}, customizations=visualize_default(g
207207
frag_shader
208208
)
209209
checkerror()
210-
boundingbox = Input(AABB(Vec3f0(0), Vec3f0(1)))
210+
boundingbox = Signal(AABB(Vec3f0(0), Vec3f0(1)))
211211

212-
robj = instanced_renderobject(data, Input(program), boundingbox, GL_TRIANGLES, grid)
212+
robj = instanced_renderobject(data, Signal(program), boundingbox, GL_TRIANGLES, grid)
213213
checkerror()
214214
robj
215215
end
@@ -236,7 +236,7 @@ push!(ROOT_SCREEN.renderlist, robj2)
236236
push!(ROOT_SCREEN.renderlist, robj3)
237237
push!(ROOT_SCREEN.renderlist, robj4)
238238

239-
const SELECTION = Dict{Symbol, Input{Matrix{Vec{2, Int}}}}()
239+
const SELECTION = Dict{Symbol, Signal{Matrix{Vec{2, Int}}}}()
240240
const SELECTION_QUERIES = Dict{Symbol, Rectangle{Int}}()
241241
immutable SelectionID{T}
242242
objectid::T
@@ -246,14 +246,14 @@ typealias GLSelection SelectionID{UInt16}
246246
typealias ISelection SelectionID{Int}
247247
function insert_selectionquery!(name::Symbol, value::Rectangle)
248248
SELECTION_QUERIES[name] = value
249-
SELECTION[name] = Input(Vec{2, Int}[]')
249+
SELECTION[name] = Signal(Vec{2, Int}[]')
250250
SELECTION[name]
251251
end
252252
function insert_selectionquery!(name::Symbol, value::Signal{Rectangle{Int}})
253253
const_lift(value) do v
254254
SELECTION_QUERIES[name] = v
255255
end |> preserve
256-
SELECTION[name] = Input(Array(Vec{2, Int}, value.value.w, value.value.h))
256+
SELECTION[name] = Signal(Array(Vec{2, Int}, value.value.w, value.value.h))
257257
SELECTION[name]
258258
end
259259
function delete_selectionquery!(name::Symbol)

examples/tests/nbody.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ function send_frame(i, planets)
8686
reshape(p, (2,2))
8787
end
8888

89-
const time_i = Input(1)
89+
const time_i = Signal(1)
9090
println(size(planets[:, 1]))
91-
const positions = const_lift(send_frame, time_i, Input(planets))
91+
const positions = const_lift(send_frame, time_i, Signal(planets))
9292
const robj = visualize(positions, model=scalematrix(Vec3(0.1f0)))
9393
len = length(planets[:, 1])
9494
const planet_lines = [visualize(reshape(planets[:, i], (250, 100)), particle_color=RGBA(rand(Float32,3)..., 0.4f0), model=scalematrix(Vec3(0.01f0))) for i=1:4]

examples/tests/test_color.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ end
105105
const dragdiff_id = get_drag_diff(inputs)
106106
gizmo_dir = const_lift(/, const_lift(gizmodir_const_lift, dragdiff_id), 10f0)
107107

108-
model = getmodel(Input(0f0), Input(0f0), Input(0f0), gizmo_dir)
108+
model = getmodel(Signal(0f0), Signal(0f0), Signal(0f0), gizmo_dir)
109109

110110

111111
msh = GLNormalMesh(file"cat.obj")

examples/tests/test_lines.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ lines = std_renderobject(Dict(
3030
:vertex => GLBuffer(verts), #NOT WORKING
3131
:index => indexbuffer(indexes), #NOT WORKING
3232
:projectionview => GLVisualize.ROOT_SCREEN.perspectivecam.projectionview
33-
), Input(lineshader), Input(AABB{Float32}(verts)), GL_LINES) #Input(AABB(verts)) -> calculates boundingbox
33+
), Signal(lineshader), Signal(AABB{Float32}(verts)), GL_LINES) #Signal(AABB(verts)) -> calculates boundingbox
3434

3535
push!(GLVisualize.ROOT_SCREEN.renderlist, lines)
3636

examples/tests/test_particle2.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
using GLVisualize, AbstractGPUArray, GLAbstraction, GeometryTypes, Reactive, ColorTypes, Meshes, MeshIO
22

33
# install a time varying signal
4-
const timer = Input(1)
4+
const timer = Signal(1)
55

66
function mkCube(p::GeometryTypes.Point3{Float32}, hsz::Float32)
77
cube = GLNormalMesh( Cube( Vec3( p.x, p.y, p.z), Vec3(hsz)))

examples/tests/test_reactangle.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
using GLVisualize, GeometryTypes, GLAbstraction, Reactive, ColorTypes
22

33

4-
a = Input(Rectangle{Int64}(20,20,900,1000))
5-
b = Input(Rectangle{Int64}(960,0,960,1280))
4+
a = Signal(Rectangle{Int64}(20,20,900,1000))
5+
b = Signal(Rectangle{Int64}(960,0,960,1280))
66
view(visualize(a, color=RGBA(1f0,0f0,1f0,0.5f0)))
77
#view(visualize(b, color=RGBA(0f0,0f0,1f0,1f0)))
88

examples/tests/test_transformation.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ end
104104
const dragdiff_id = get_drag_diff(inputs)
105105
gizmo_dir = const_lift(/, const_lift(gizmodir_const_lift, dragdiff_id), 10f0)
106106

107-
model = getmodel(Input(0f0), Input(0f0), Input(0f0), gizmo_dir)
107+
model = getmodel(Signal(0f0), Signal(0f0), Signal(0f0), gizmo_dir)
108108

109109

110110
msh = GLNormalMesh(file"cat.obj")

0 commit comments

Comments
 (0)