Rev 7858 | Rev 7863 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 7858 | Rev 7862 | ||
---|---|---|---|
Line 2516... | Line 2516... | ||
2516 | case CLOCK: |
2516 | case CLOCK: |
2517 | /* |
2517 | /* |
2518 | @ clock x,y,r(px),H,M,S,type hourglass,interactive [ ,H_color,M_color,S_color,background_color,foreground_color ] |
2518 | @ clock x,y,r(px),H,M,S,type hourglass,interactive [ ,H_color,M_color,S_color,background_color,foreground_color ] |
2519 | @ type hourglass:<br />type = 0 : only segments<br />type = 1 : only numbers<br />type = 2 : numbers and segments |
2519 | @ type hourglass:<br />type = 0 : only segments<br />type = 1 : only numbers<br />type = 2 : numbers and segments |
2520 | @ colors are optional: if not defined, default values will be used<br />default colours: clock 0,0,60,4,35,45,1,2,[space]<br />default colours: clock 0,0,60,4,35,45,1,2,,,,,<br />custom colours: clock 0,0,60,4,35,45,1,2,,,,yellow,red<br />custom colours: clock 0,0,60,4,35,45,1,2,white,white,white,black,yellow |
2520 | @ colors are optional: if not defined, default values will be used<br />default colours: clock 0,0,60,4,35,45,1,2,[space]<br />default colours: clock 0,0,60,4,35,45,1,2,,,,,<br />custom colours: clock 0,0,60,4,35,45,1,2,,,,yellow,red<br />custom colours: clock 0,0,60,4,35,45,1,2,white,white,white,black,yellow |
- | 2521 | @ if you don't want a seconds hand (or minutes...), just make it invisible by using the background color of the hourglass... |
|
2521 | @ interactive <ul><li>0 : not interactive, just clock(s)</li><li>1 : function read_canvas() will read all active clocks in H:M:S format<br />The active clock(s) can be adjusted by pupils</li><li>2 : function read_canvas() will return the clicked clock <br />(like multiplechoice; first clock in script in nr. 0 )</li></ul> |
2522 | @ interactive <ul><li>0 : not interactive, just clock(s)</li><li>1 : function read_canvas() will read all active clocks in H:M:S format<br />The active clock(s) can be adjusted by pupils</li><li>2 : function read_canvas() will return the clicked clock <br />(like multiplechoice; first clock in script in nr. 0 )</li></ul> |
2522 | @ canvasdraw will not check validity of colornames...the javascript console is your best friend |
2523 | @ canvasdraw will not check validity of colornames...the javascript console is your best friend |
2523 | @ no combinations with other reply_types allowed, for now |
2524 | @ no combinations with other reply_types allowed, for now |
2524 | @ if interactive, 6 buttons per clock will be displayed for adjusting a clock (H+ M+ S+ H- M- S-)<br /> set_clock(clock_id,type,incr) <br />first clock has clock_id=0 ; type : H=1,M=2,S=3 ; incr : increment integer |
2525 | @ if interactive, 6 buttons per clock will be displayed for adjusting a clock (H+ M+ S+ H- M- S-)<br /> set_clock(clock_id,type,incr) <br />first clock has clock_id=0 ; type : H=1,M=2,S=3 ; incr : increment integer |
2525 | */ |
2526 | */ |
Line 3471... | Line 3472... | ||
3471 | }\ |
3472 | }\ |
3472 | else\ |
3473 | else\ |
3473 | {\ |
3474 | {\ |
3474 | return reply+\"\\n\"+input_reply;\ |
3475 | return reply+\"\\n\"+input_reply;\ |
3475 | }\ |
3476 | }\ |
3476 | } |
3477 | }\ |
3477 | else\ |
3478 | else\ |
3478 | {\ |
3479 | {\ |
3479 | if( typeof userdraw_text != 'undefined' ){\ |
3480 | if( typeof userdraw_text != 'undefined' ){\ |
3480 | return reply+\"\\n\"+userdraw_text;\ |
3481 | return reply+\"\\n\"+userdraw_text;\ |
3481 | }\ |
3482 | }\ |
Line 5494... | Line 5495... | ||
5494 | var clock_ctx = clock_canvas.getContext(\"2d\");\ |
5495 | var clock_ctx = clock_canvas.getContext(\"2d\");\ |
5495 | var clock = function(xc,yc,radius,H,M,S,type,interaction,h_color,m_color,s_color,bg_color,fg_color){\ |
5496 | var clock = function(xc,yc,radius,H,M,S,type,interaction,h_color,m_color,s_color,bg_color,fg_color){\ |
5496 | clock_ctx.save();\ |
5497 | clock_ctx.save();\ |
5497 | this.type = type || 0;\ |
5498 | this.type = type || 0;\ |
5498 | this.interaction = interaction || 0;\ |
5499 | this.interaction = interaction || 0;\ |
5499 | this.H = H |
5500 | this.H = H;\ |
5500 | this.M = M |
5501 | this.M = M;\ |
5501 | this.S = S |
5502 | this.S = S;\ |
5502 | this.xc = xc || xsize/2;\ |
5503 | this.xc = xc || xsize/2;\ |
5503 | this.yc = yc || ysize/2;\ |
5504 | this.yc = yc || ysize/2;\ |
5504 | this.radius = radius || xsize/4;\ |
5505 | this.radius = radius || xsize/4;\ |
5505 | var font_size = parseInt(0.2*this.radius);\ |
5506 | var font_size = parseInt(0.2*this.radius);\ |
5506 | this.H_color = h_color || \"blue\";\ |
5507 | this.H_color = h_color || \"blue\";\ |
Line 5540... | Line 5541... | ||
5540 | clock_ctx.closePath();\ |
5541 | clock_ctx.closePath();\ |
5541 | clock_ctx.stroke();\ |
5542 | clock_ctx.stroke();\ |
5542 | break;\ |
5543 | break;\ |
5543 | case 1:\ |
5544 | case 1:\ |
5544 | for(var p= 1; p <= 12 ; p++){ angle = (p - 3) * (Math.PI * 2) / 12;x1 = 0.9*this.radius*Math.cos(angle);y1 = 0.9*this.radius*Math.sin(angle);clock_ctx.fillText(p, x1, y1);};break;\ |
5545 | for(var p= 1; p <= 12 ; p++){ angle = (p - 3) * (Math.PI * 2) / 12;x1 = 0.9*this.radius*Math.cos(angle);y1 = 0.9*this.radius*Math.sin(angle);clock_ctx.fillText(p, x1, y1);};break;\ |
- | 5546 | case 2:\ |
|
5545 | |
5547 | for(var p= 1; p <= 12 ; p++){ angle = (p - 3) * (Math.PI * 2) / 12;x1 = 0.8*this.radius*Math.cos(angle);y1 = 0.8*this.radius*Math.sin(angle);clock_ctx.fillText(p, x1, y1);};\ |
5546 | clock_ctx.beginPath();\ |
5548 | clock_ctx.beginPath();\ |
5547 | for(var p = 1; p <= 12 ; p++){\ |
5549 | for(var p = 1; p <= 12 ; p++){\ |
5548 | angle_cos = this.radius*(Math.cos(p * (Math.PI * 2) / 12));\ |
5550 | angle_cos = this.radius*(Math.cos(p * (Math.PI * 2) / 12));\ |
5549 | angle_sin = this.radius*(Math.sin(p * (Math.PI * 2) / 12));\ |
5551 | angle_sin = this.radius*(Math.sin(p * (Math.PI * 2) / 12));\ |
5550 | x1 = 0.9*angle_cos;y1 = 0.9*angle_sin;x2 = angle_cos;y2 = angle_sin;\ |
5552 | x1 = 0.9*angle_cos;y1 = 0.9*angle_sin;x2 = angle_cos;y2 = angle_sin;\ |