Advertisement
Guest User

Untitled

a guest
Oct 1st, 2019
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.02 KB | None | 0 0
  1. function ImageItemDraw(ctx, offset){
  2. var old_style = ctx.strokeStyle;
  3. var old_fill = ctx.fillStyle;
  4.  
  5. if(this.loaded){
  6.  
  7. var page = {
  8. width:$(window).width(),
  9. height:$(window).height()
  10. };
  11.  
  12. var sc = scale[this.scale_index];
  13. var sc_x = Math.round(sc * this.size.x);
  14. var sc_y = Math.round(sc * this.size.y);
  15.  
  16.  
  17. // if(this.size.x > page.width*0.5) {
  18. // this.size.x = page.width*0.5 ;
  19. // }
  20. //
  21. // if(this.size.y > page.height*0.5) {
  22. // this.size.y = page.height*0.5;
  23. // }
  24. // if(this.scale_index == 3){
  25. // console.log(sc_x + ", " + sc_y );
  26. // console.log(this.size);
  27. // }
  28.  
  29. if(this.highlight_dragbar === false){
  30. ctx.fillStyle = "#222222";
  31. }else{
  32. ctx.fillStyle = "#444444";
  33. }
  34. // Dragbar Top
  35. ctx.beginPath();
  36. var tb_width = this.size.x;
  37. ctx.fillRect(this.loc.x, this.loc.y - 20 - offset, tb_width , 20);
  38. ctx.stroke();
  39. ctx.closePath();
  40.  
  41. ctx.font = "14px verdana";
  42. ctx.fillStyle = "#eeffee";
  43. ctx.fillText(this.filename, this.loc.x + 5 , this.loc.y -5 - offset, this.size.x);
  44.  
  45. ctx.linewidth = 5;
  46. ctx.strokeStyle = "#222222";
  47.  
  48. // Outline of image
  49. ctx.beginPath();
  50. ctx.moveTo(this.loc.x, this.loc.y - offset);
  51. ctx.lineTo(this.loc.x+sc_x, this.loc.y - offset);
  52. ctx.lineTo(this.loc.x+sc_x, this.loc.y+sc_y - offset);
  53. ctx.lineTo(this.loc.x,this.loc.y+sc_y - offset);
  54. ctx.lineTo(this.loc.x,this.loc.y - offset);
  55. ctx.stroke();
  56. ctx.closePath();
  57.  
  58.  
  59.  
  60.  
  61. // Image
  62.  
  63. ctx.drawImage(this.img, this.loc.x, this.loc.y - offset, sc_x, sc_y);
  64. // var jpgURLat50PercentQuality = canvas.toDataURL("image/jpeg", 0.5);
  65. // Buttons on image
  66. // ctx.fillStyle = "#000000";
  67. // ctx.fillRect( this.loc.x + (sc_x - 100), this.loc.y+sc_y, 40,50 ) ;
  68. // ctx.strokeStyle = "#ffffff";
  69. // ctx.beginPath();
  70. // ctx.moveTo(this.loc.x + (sc_x - 100) + 10, this.loc.y+sc_y + 25);
  71. // ctx.lineTo(this.loc.x + (sc_x - 100) + 30, this.loc.y+sc_y + 25);
  72. // ctx.moveTo(this.loc.x + (sc_x - 100) + 20, this.loc.y+sc_y + 15);
  73. // ctx.lineTo(this.loc.x + (sc_x - 100) + 20, this.loc.y+sc_y + 35);
  74. // ctx.stroke();
  75. // ctx.closePath();
  76.  
  77. // ctx.fillRect( this.loc.x + (sc_x - 50), this.loc.y+sc_y, 40,50 ) ;
  78. // // Draw the minus sign
  79. // ctx.beginPath();
  80. // ctx.moveTo(this.loc.x + (sc_x - 50) + 10, this.loc.y+sc_y + 25);
  81. // ctx.lineTo(this.loc.x + (sc_x - 50) + 30, this.loc.y+sc_y + 25);
  82. // ctx.stroke();
  83. // ctx.closePath();
  84.  
  85. // Draw any assets that are attached to the image
  86. for(var i=0;!cursor.moving && i<this.assets.length;i++){
  87. var ass = this.assets[i];
  88. ass.draw(ctx, offset, this);
  89. }
  90.  
  91. // Resize pips - bottom right hand corner
  92. ctx.strokeStyle = '#222222';
  93. ctx.beginPath();
  94. ctx.moveTo(this.loc.x + this.size.x - 20, this.loc.y + this.size.y - offset - 2);
  95. ctx.lineTo(this.loc.x + this.size.x - 2, this.loc.y + this.size.y - offset - 20);
  96. ctx.moveTo(this.loc.x + this.size.x - 15, this.loc.y + this.size.y - offset - 2);
  97. ctx.lineTo(this.loc.x + this.size.x - 2, this.loc.y + this.size.y - offset - 15);
  98. ctx.moveTo(this.loc.x + this.size.x - 10, this.loc.y + this.size.y - offset - 2);
  99. ctx.lineTo(this.loc.x + this.size.x - 2, this.loc.y + this.size.y - offset - 10);
  100. ctx.moveTo(this.loc.x + this.size.x - 5, this.loc.y + this.size.y - offset - 2);
  101. ctx.lineTo(this.loc.x + this.size.x - 2, this.loc.y + this.size.y - offset - 5);
  102. // ctx.moveTo(this.l)
  103. ctx.stroke();
  104. ctx.closePath();
  105. }
  106.  
  107. ctx.strokeStyle = old_style;
  108. ctx.fillStyle = old_fill;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement