Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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)
- {
- if(pix)
- {
- vector2 texsize;
- [texsize.x, texsize.y] = TexMan.GetSize(curpix);
- Screen.DrawTexture(curpix,true,x0,y0,
- DTA_DestWidth, int(texsize.x*scale.x),
- DTA_DestHeight, int(texsize.y*scale.y),
- DTA_ColorOverlay, col,
- DTA_Alpha, alpha,
- DTA_LegacyRenderStyle, RenderStyle
- );
- }
- }
- ui void drawLine( double x0, double y0, double x1, double y1, Color col, vector2 origin = (0,0), double maxdist = 128, double alpha = 1.0)
- {
- if( (x0 < 0 && x1 < 0) ||
- (y0 < 0 && y1 < 0) ||
- (x0 > scrw && x1 > scrw) ||
- (y0 > scrh && y1 > scrh) ) return;
- if(maxdist < scrw)
- {
- double fromdist = VDist2D((x0,y0), origin);
- double todist = VDist2D((x1,y1), origin);
- if( (fromdist > maxdist || todist > maxdist) )
- {
- if(fromdist > maxdist*1.2 && todist > maxdist*1.2) return;
- double lineangle = atan2(y1-y0, x1-x0);
- double dist = VDist2D((x0,y0),(x1,y1));
- double step = 1;
- for(int i = 0; i < dist; i+=step)
- {
- vector2 pixpos = (x0+cos(lineangle)*i, y0+sin(lineangle)*i);
- double fulldist = VDist2D(pixpos, origin);
- if(fulldist > maxdist) continue;
- plotPixel(pixpos.x,pixpos.y, col, (0.5,0.5), alpha);
- }
- return;
- }
- }
- Screen.DrawThickLine(x0,y0,x1,y1,2,col,alpha*255);
- }
Advertisement
Add Comment
Please, Sign In to add comment