Subversion Repositories wimsdev

Compare Revisions

Ignore whitespace Rev 17585 → Rev 17586

/trunk/wims/src/Misc/canvasdraw/Changelog.md
3,6 → 3,7
- sort out the global/local variable mess...and reorganize headerfile
: zooming and grid: scaling needs to be more adaptive! (use constant amount of grid lines)
## 2023
* 23/2/2023: minor improvement for sub/sup routine for command family strings (use of space is optional)
* 22/2/2023: snaptopoints may be called multiple times (no limit) And restored MAX_INT to 128 (but it's open for change, anyway)
* 22/2/2023: increase the limit MAX_INT to 256
* 21/2/2023: canvasmultidraw now place object with relative coords (%) instead of absolute (px)
/trunk/wims/src/Misc/canvasdraw/canvasdraw.c
4748,8 → 4748,8
@ note: when set ''onclick``, use an extra command ''fontsize`` (default: fontsize=12) to adjust the size of the clicked text-string<br>note: a clicked text string will be hardcoded : fontsize+10 in the font family courier
@ unicode supported: <code>string red,0,0,\\u2232</code><br/> See <a target='new' href='https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode'>https://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode</a><br/> See <a target='new' href='https://en.wikipedia.org/wiki/Greek_script_in_Unicode'>https://en.wikipedia.org/wiki/Greek_script_in_Unicode</a>
@ use a command like <code>fontfamily italic 24px Arial</code> to set fonts on browser that support font change
@ super / sub script is supported, using '<b>_</b>' and '<b>^</b>' <br>The font family for the sub/sup string will be Helvetica e.g. your font family settings will be ignored <br>to end the subscript/supscript, use an extra space...see example:
@%string_sup_sub%size 400,400%xrange -6,6%yrange -6,6%fontfamily 22px Arial%# use single space for separation in formula...%# use double space to create new word%string red,-5,0,H_3 O^+ + OH^\\u2212 \\u2192 2H_2 O%
@ super / sub script is supported, using '<b>_</b>' and '<b>^</b>' <br>The font family for the sub/sup string will be Helvetica e.g. your font family settings will be ignored <br>to force end the subscript/supscript, use an extra space...see example:
@%string_sup_sub%size 400,400%xrange -6,6%yrange -6,6%fontfamily 22px Arial%# you can use a single space for separation in formula...%# use double space to create new word%string blue,-5,3,H_3O^+ + OH^- \\u2192 2H_2O%# you can use a single space for separation in formula...%string red,-5,-3,H_3 O^+ + OH^\\u2212 \\u2192 2H_2 O%
@%string%size 400,400%xrange -10,10%yrange -10,10%fontfamily 14px Arial%crosshair -3,-3,red%crosshair 3,3,blue%string red,-3,-3,Hello World%fontfamily Italic 18px Arial%string red,3,3,Hello World%fontfamily 22pt STIX%string black,-10,8,\\u03B1 \\u03B2 \\u03B3 \\u03B4 \\u03B5 \\u03B6 \\u03B7 \\u03B8 \\u03B9 \\u03BA \\u03BB \\u03BC \\u03BD \\u03BE \\u03BF
*/
if( use_rotate == TRUE ){js_function[JS_ROTATE_MOUSE] = 1; }
/trunk/wims/src/Misc/canvasdraw/canvasutils.c
737,12 → 737,14
var h = ctx.measureText('M').width;\
switch(use_offset){\
case 0:break;\
case 1:y=y-h;;break;\
case 1:y=y-h;break;\
case 2:x=x+h;break;\
case 3:x=x+h;y=y-h;;break;\
case 3:x=x+h;y=y-h;break;\
case 4:x=x-m;break;\
default:break;\
};\
var alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';\
function check_alpha(C){if(alphabet.indexOf(C) != -1){return 1;}else{return 0;};};\
var S = parseInt(ctx.font) || 10;var s = 0.8*(parseInt(ctx.font)) || 8;\
ctx.font = S+'px Helvetica';ctx.textBaseline = baseline;\
for( c = 0 ; c < len ;c++){\
751,10 → 753,16
else\
if(C == '^'){ctx.font = s+'px Helvetica';subsup = 1;c++;space = 3;baseline='bottom';C = txt.charAt(c);}\
else\
if(C == ' '){ctx.font = S+'px Helvetica';if(subsup == 1){space = 0.6*s - (ctx.measureText('M').width);subsup = 0;};baseline = 'middle';}\
if(C == ' ' ){ctx.font = S+'px Helvetica';if(subsup == 1){space = 0.6*s - (ctx.measureText('M').width);subsup = 0;};baseline = 'middle';}\
else\
if( subsup == 1 && c == '-'){c = '\\u2212';ctx.font = s+'px Helvetica';}\
else\
if( subsup == 1 && c == '+'){c = '\\u002B';ctx.font = s+'px Helvetica';}\
else\
if( check_alpha(C) == 1 ){ctx.font = S+'px Helvetica';subsup = 0;baseline = 'middle';}\
else\
if(C >= '0' && C <= '9'){ctx.font = s+'px Helvetica';}\
else{ctx.font = S+'px Helvetica';};\
else{ ctx.font = S+'px Helvetica';};\
ctx.textBaseline = baseline;ctx.fillText(C,x,y);x = space + x + ctx.measureText(C).width;\
};\
ctx.stroke();\