Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix serialization error

  • Loading branch information...
commit 38f83fb0171c66603cf3b6d8eb45269347c752f1 1 parent df3d042
Hugo Heuzard authored
Showing with 14 additions and 13 deletions.
  1. +5 −3 src/opacairo/client.opa
  2. +9 −10 src/opacairo/main.opa
View
8 src/opacairo/client.opa
@@ -72,6 +72,7 @@ initialize_client(atoms) =
| {~set_color} -> {set=(pos,set_color,size)} //change color
| {~set_pos} -> {set=(set_pos,color,size)} //change positon
| {~move} -> //move to the new positon
+ do Log.info("change_size","{size}")
do draw_line(ctx, pos,move,color,size)
do send_line(pos,move,color,size)
{set=(move,color,size)}
@@ -79,7 +80,8 @@ initialize_client(atoms) =
do draw_line(ctx, p1, p2, color, size)
{unchanged}
end
- treat_msg = Session.make(({x_px=0 y_px=0},Color.black,5), dispatch)
+ slider_size = 5
+ treat_msg = Session.make(({x_px=0 y_px=0},Color.black,slider_size), dispatch)
treat_atoms = Session.make_callback( atoms -> List.iter(atom -> Session.send(treat_msg,{line=atom}),List.rev(atoms)))
// add drawing tools
// color picker
@@ -99,7 +101,7 @@ initialize_client(atoms) =
thumb_over = WStyler.make_class(["thumb_over"])
gauge = WStyler.make_class(["gauge"])
}
- change_size(set_size) = Session.send(treat_msg, {~set_size})
+ change_size(set_size) = do Log.info("change_size","{set_size}") Session.send(treat_msg, {~set_size})
config_slider = { style=style_slider on_change=change_size on_release=change_size range=(1,50) init=5 step=2}
slider = WSlider.html(config_slider, "{id}_size")
@@ -117,7 +119,7 @@ initialize_client(atoms) =
//register session to reveive updates
do NetworkBuffer.add(treat_atoms,atoms_network)
//Initial state
- do Session.send(treat_msg, {set_size=String.to_int(Dom.get_value(#slider))})
+ do Session.send(treat_msg, {set_size=slider_size})
do Session.send(treat_msg, {set_color=Color.darkblue})
//function call when drawing
View
19 src/opacairo/main.opa
@@ -61,7 +61,6 @@ f(size,co,x1,y1,x2,y2) =
ttt : channel(list(line)) = Session.make_callback(
l ->
- do Log.warning("CANVAS","update")
List.iter((from,to,co,size) ->
f(size,co,from.x_px,from.y_px,to.x_px,to.y_px),
l))
@@ -91,13 +90,13 @@ server = Server.simple_server(urls)
@server
atoms_sess2 : channel(list(line)) = SessionBuffer.make_send_to(Session.make_callback(l -> NetworkBuffer.broadcast(l,atoms_network)),250)
-@server
-color_random()=
- r()=Random.int(255)
- {r=r() g=r() b=r() a=255}
-@server
-_ = Scheduler.timer(100, ->
- rand(size) = Random.int(Int.of_float(size))
- rand_dim() = {x_px=rand(canvas_width) y_px=rand(canvas_height)}
+// @server
+// color_random()=
+// r()=Random.int(255)
+// {r=r() g=r() b=r() a=255}
+// @server
+// _ = Scheduler.timer(100, ->
+// rand(size) = Random.int(Int.of_float(size))
+// rand_dim() = {x_px=rand(canvas_width) y_px=rand(canvas_height)}
- Session.send(atoms_sess2,[(rand_dim(), rand_dim(), color_random(), Random.int(50))]))
+// Session.send(atoms_sess2,[(rand_dim(), rand_dim(), color_random(), Random.int(50))]))
Please sign in to comment.
Something went wrong with that request. Please try again.