not really known
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
3.9 KiB

  1. function XOMan(innerc, outerc, editor,num){
  2. this.svgwidth = null;
  3. this.svgheight = null;
  4. this.xomanpic = null;
  5. this.stroke = outerc;
  6. this.fill = innerc;
  7. this.colnumber = num;
  8. this.xoSVG = function(innercol,outercol){
  9. this.svgwidth = 240 * editor.scale;
  10. this.svgheight = 260 * editor.scale;
  11. var svgstring = this.header() +
  12. '<g>' +
  13. '<g id="XO">' +
  14. '<path id="Line1" d="M'+(165.5 * editor.scale).toFixed(1)+','+(97 * editor.scale).toFixed(1)+' C'+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(74.5 * editor.scale).toFixed(1)+','+(188 * editor.scale).toFixed(1)+'" stroke="'+outercol+'" stroke-width="'+(37 * editor.scale).toFixed(1)+'" stroke-linecap="round" fill="none" visibility="visible" />' +
  15. '<path id="Line2" d="M'+(165.5 * editor.scale).toFixed(1)+','+(188 * editor.scale).toFixed(1)+' C'+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(74.5 * editor.scale).toFixed(1)+','+(97 * editor.scale).toFixed(1)+'" stroke="'+outercol+'" stroke-width="'+(37 * editor.scale).toFixed(1)+'" stroke-linecap="round" fill="none" visibility="visible" />' +
  16. '<path id="Fill1" d="M'+(165.5 * editor.scale).toFixed(1)+','+(97 * editor.scale).toFixed(1)+' C'+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(74.5 * editor.scale).toFixed(1)+','+(188 * editor.scale).toFixed(1)+'" stroke="'+innercol+'" stroke-width="'+(17 * editor.scale).toFixed(1)+'" stroke-linecap="round" fill="none" visibility="visible" />' +
  17. '<path id="Fill2" d="M'+(165.5 * editor.scale).toFixed(1)+','+(188 * editor.scale).toFixed(1)+' C'+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(120 * editor.scale).toFixed(1)+','+(140.5 * editor.scale).toFixed(1)+' '+(74.5 * editor.scale).toFixed(1)+','+(97 * editor.scale).toFixed(1)+'" stroke="'+innercol+'" stroke-width="'+(17 * editor.scale).toFixed(1)+'" stroke-linecap="round" fill="none" visibility="visible" />' +
  18. '<circle id="Circle" cx="'+(120 * editor.scale).toFixed(1)+'" cy="'+(61.5 * editor.scale).toFixed(1)+'" r="'+(27.5 * editor.scale).toFixed(1)+'" fill="'+innercol+'" stroke="'+outercol+'" stroke-width="'+(11 * editor.scale).toFixed(1)+'" visibility="visible" />'+'</g></g>\n'+this.footer();
  19. return svgstring;
  20. }
  21. this.header = function(){
  22. return '<svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" width="'+this.svgwidth.toFixed(0)+'px" height="'+this.svgheight.toFixed(0)+'px" xml:space="preserve">\n';
  23. }
  24. this.footer = function(){
  25. return '</svg>';
  26. }
  27. this.updateSVG = function(icol, ocol, number){
  28. this.stroke = ocol;
  29. this.fill = icol;
  30. this.colnumber = number;
  31. var svg = this.xoSVG(icol,ocol);
  32. var svg = window.btoa(svg);
  33. var bitmap = new createjs.Bitmap('data:image/svg+xml;base64,'+svg);
  34. bitmap.x = editor.stage.canvas.width/2-this.svgwidth/2;
  35. bitmap.y = editor.stage.canvas.height/2-this.svgheight/2;
  36. editor.stage.removeChild(this.xomanpic);
  37. this.xomanpic = bitmap;
  38. editor.stage.addChild(this.xomanpic);
  39. editor.stage.update();
  40. }
  41. this.init = function(){
  42. this.stroke = outerc;
  43. this.fill = innerc;
  44. this.colnumber = num;
  45. var svg = this.xoSVG(innerc,outerc);
  46. var svg = window.btoa(svg);
  47. var bitmap = new createjs.Bitmap('data:image/svg+xml;base64,'+svg);
  48. bitmap.x = editor.stage.canvas.width/2-this.svgwidth/2;
  49. bitmap.y = editor.stage.canvas.height/2-this.svgheight/2;
  50. this.xomanpic = bitmap;
  51. editor.stage.addChild(this.xomanpic);
  52. editor.stage.update();
  53. }
  54. }