Sinael

Snippet

Sep 8th, 2022
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. ui void plotPixel (int x0, int y0, Color col = Color(0,0,0), vector2 scale = (0.5,0.5), double alpha = 1.0, uint RenderStyle = STYLE_Normal)
  2. {
  3. if(pix)
  4. {
  5. vector2 texsize;
  6. [texsize.x, texsize.y] = TexMan.GetSize(curpix);
  7. Screen.DrawTexture(curpix,true,x0,y0,
  8. DTA_DestWidth, int(texsize.x*scale.x),
  9. DTA_DestHeight, int(texsize.y*scale.y),
  10. DTA_ColorOverlay, col,
  11. DTA_Alpha, alpha,
  12. DTA_LegacyRenderStyle, RenderStyle
  13. );
  14. }
  15. }
  16. ui void drawLine( double x0, double y0, double x1, double y1, Color col, vector2 origin = (0,0), double maxdist = 128, double alpha = 1.0)
  17. {
  18. if( (x0 < 0 && x1 < 0) ||
  19. (y0 < 0 && y1 < 0) ||
  20. (x0 > scrw && x1 > scrw) ||
  21. (y0 > scrh && y1 > scrh) ) return;
  22.  
  23. if(maxdist < scrw)
  24. {
  25. double fromdist = VDist2D((x0,y0), origin);
  26. double todist = VDist2D((x1,y1), origin);
  27. if( (fromdist > maxdist || todist > maxdist) )
  28. {
  29. if(fromdist > maxdist*1.2 && todist > maxdist*1.2) return;
  30. double lineangle = atan2(y1-y0, x1-x0);
  31. double dist = VDist2D((x0,y0),(x1,y1));
  32. double step = 1;
  33. for(int i = 0; i < dist; i+=step)
  34. {
  35. vector2 pixpos = (x0+cos(lineangle)*i, y0+sin(lineangle)*i);
  36. double fulldist = VDist2D(pixpos, origin);
  37. if(fulldist > maxdist) continue;
  38. plotPixel(pixpos.x,pixpos.y, col, (0.5,0.5), alpha);
  39. }
  40. return;
  41. }
  42. }
  43. Screen.DrawThickLine(x0,y0,x1,y1,2,col,alpha*255);
  44. }
Advertisement
Add Comment
Please, Sign In to add comment