Guest User

Untitled

a guest
Mar 24th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. Editor.Drawing.Context.globalAlpha = 0.3;
  2. var amount = 3;
  3.  
  4. for(var t = -amount; t <= amount; t += 3) {
  5. for(var n = -amount; n <= amount; n += 3) {
  6. Editor.Drawing.Context.drawImage(Editor.Drawing.ClipCanvas, -(n-1), -(t-1));
  7. }
  8. }
  9.  
  10. function brushLine(ctx, x1, y1, x2, y2) {
  11.  
  12. var diffX = Math.abs(x2 - x1), // calc diffs
  13. diffY = Math.abs(y2 - y1),
  14. dist = Math.sqrt(diffX * diffX + diffY * diffY), // find length
  15. step = 20 / (dist ? dist : 1), // "resolution"
  16. i = 0, // iterator for length
  17. t = 0, // t [0, 1]
  18. b, x, y;
  19.  
  20. while (i <= dist) {
  21. t = Math.max(0, Math.min(1, i / dist));
  22. x = x1 + (x2 - x1) * t;
  23. y = y1 + (y2 - y1) * t;
  24. b = (Math.random() * 3) | 0;
  25. ctx.drawImage(brush, x - bw * 0.5, y - bh * 0.5); // draw brush
  26. i += step;
  27. }
  28. }
Add Comment
Please, Sign In to add comment