Drawing src bitmap to dest bitmap with rounded corners

@param src    source bitmap
@param dest   destination bitmap
@param radius radius in destination bitmap scale
349221
public static void drawRoundedCorners(Bitmap src, Bitmap dest, int radius) {
        drawRoundedCorners(src, dest, radius, CLEAR_COLOR);
    }
1192016
public static void copyTriangle(boolean upper , DMatrixRBlock src , DMatrixRBlock dst )
    {
        if( src.blockLength != dst.blockLength )
            throw new IllegalArgumentException("Block size is different");
        if( src.numRows < dst.numRows )
            throw new IllegalArgumentException("The src has fewer rows than dst");
        if( src.numCols < dst.numCols )
            throw new IllegalArgumentException("The src has fewer columns than dst");

        int blockLength = src.blockLength;

        int numRows = Math.min(src.numRows,dst.numRows);
        int numCols = Math.min(src.numCols,dst.numCols);

        if( upper ) {
            for( int i = 0; i < numRows; i += blockLength ) {
                int heightSrc = Math.min(blockLength,src.numRows-i);
                int heightDst = Math.min(blockLength,dst.numRows-i);

                for( int j = i; j < numCols; j += blockLength ) {
                    int widthSrc = Math.min(blockLength,src.numCols-j);
                    int widthDst = Math.min(blockLength,dst.numCols-j);

                    int indexSrc = i*src.numCols + heightSrc*j;
                    int indexDst = i*dst.numCols + heightDst*j;

                    if( j == i ) {
                        for( int k = 0; k < heightDst; k++ ) {
                            for( int l = k; l < widthDst; l++ ) {
                                dst.data[indexDst + widthDst*k+l ] = src.data[indexSrc + widthSrc*k+l ];
                            }
                        }
                    } else {
                        for( int k = 0; k < heightDst; k++ ) {
                            System.arraycopy(src.data, indexSrc + widthSrc * k, dst.data, indexDst + widthDst * k, widthDst);
                        }
                    }
                }
            }
        } else {
            for( int i = 0; i < numRows; i += blockLength ) {
                int heightSrc = Math.min(blockLength,src.numRows-i);
                int heightDst = Math.min(blockLength,dst.numRows-i);

                for( int j = 0; j <= i; j += blockLength ) {
                    int widthSrc = Math.min(blockLength,src.numCols-j);
                    int widthDst = Math.min(blockLength,dst.numCols-j);

                    int indexSrc = i*src.numCols + heightSrc*j;
                    int indexDst = i*dst.numCols + heightDst*j;

                    if( j == i ) {
                        for( int k = 0; k < heightDst; k++ ) {
                            int z = Math.min(k+1,widthDst);
                            for( int l = 0; l < z; l++ ) {
                                dst.data[indexDst + widthDst*k+l ] = src.data[indexSrc + widthSrc*k+l ];
                            }
                        }
                    } else {
                        for( int k = 0; k < heightDst; k++ ) {
                            System.arraycopy(src.data, indexSrc + widthSrc * k, dst.data, indexDst + widthDst * k, widthDst);
                        }
                    }
                }
            }
        }
    }
1125821
def drawCircle(page, center, radius, color=None, fill=None,
               morph=None, dashes=None, width=1,
               roundCap=False, overlay=True):
    
    img = page.newShape()
    Q = img.drawCircle(Point(center), radius)
    img.finish(color=color, fill=fill, dashes=dashes, width=width,
               roundCap=roundCap, morph=morph)
    img.commit(overlay)
    return Q
704196
public function addMapping(string $src, string $dest): void
	{
		$this->mapper[$src] = $dest;
	}
1240874
private void drawCircleDown(@NonNull Canvas canvas, float step, float radius) {
    canvas.drawCircle(
            xCoordinate + step,
            getMeasuredHeight() / 2,
            bounceDotRadius - radius,
            endPaint
    );
  }
732067
public static int[] imageOffsets(double radius, int imgWidth) {


		double PI2 = Math.PI * 2.0;

		double circumference = PI2 * radius;
		int num = (int) Math.ceil(circumference);
		num = num - num % 4;

		double angleStep = PI2 / num;


		int temp[] = new int[(int) Math.ceil(circumference)];
		int i = 0;

		int prev = 0;

		for (double ang = 0; ang < PI2; ang += angleStep) {
			int x = (int) Math.round(Math.cos(ang) * radius);
			int y = (int) Math.round(Math.sin(ang) * radius);

			int pixel = y * imgWidth + x;

			if (pixel != prev) {
//                System.out.println("i = "+i+"  x = "+x+"  y = "+y);
				temp[i++] = pixel;
			}
			prev = pixel;
		}

		if (i == temp.length)
			return temp;
		else {
			int ret[] = new int[i];
			System.arraycopy(temp, 0, ret, 0, i);

			return ret;
		}
	}
982014
public void toNormalImage(File src, File dest) {
        String command = commandDir + (dest.getName().endsWith(".gif") ? "/gif2webp" : "/dwebp ") + src.getPath() + " -o " + dest.getPath();
        this.executeCommand(command);
    }
402079
public static Bitmap flip(Bitmap src) {
        Matrix m = new Matrix();
        m.preScale(-1, 1);
        return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
    }
1104403
private void setShadowInternal(float radius,
                                   @ColorInt int color,
                                   boolean invalidate) {
        mShadowRadius = radius;
        mShadowColor = color;

        // Reset previous shadow layer
        mBorderPaint.clearShadowLayer();
        mCheckedBackgroundPaint.clearShadowLayer();

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            setLayerType(LAYER_TYPE_SOFTWARE, mBorderPaint);
            setLayerType(LAYER_TYPE_SOFTWARE, mCheckedBackgroundPaint);
        }

        mBorderPaint.setShadowLayer(
                mShadowRadius,
                0.0f,
                mShadowRadius / 2,
                mShadowColor);

        if (mAllowCheckStateShadow) {
            mCheckedBackgroundPaint.setShadowLayer(
                    mShadowRadius,
                    0.0f,
                    mShadowRadius / 2,
                    mShadowColor);
        }

        // Invalidate the view if asked
        if (invalidate) {
            invalidate();
        }
    }
1367385
public static BufferedImage copy(BufferedImage src, BufferedImage dest) {
        dest.getGraphics().drawImage(src, 0, 0, null);
        return dest;
    }
1278671
public function drawRoundedRectangle($X1, $Y1, $X2, $Y2, $Radius, array $Format = [])
    {
        $R = isset($Format["R"]) ? $Format["R"] : 0;
        $G = isset($Format["G"]) ? $Format["G"] : 0;
        $B = isset($Format["B"]) ? $Format["B"] : 0;
        $Alpha = isset($Format["Alpha"]) ? $Format["Alpha"] : 100;

        list($X1, $Y1, $X2, $Y2) = $this->fixBoxCoordinates($X1, $Y1, $X2, $Y2);

        if ($X2 - $X1 < $Radius) {
            $Radius = floor((($X2 - $X1)) / 2);
        }
        if ($Y2 - $Y1 < $Radius) {
            $Radius = floor((($Y2 - $Y1)) / 2);
        }

        $Color = ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha, "NoBorder" => true];

        if ($Radius <= 0) {
            $this->drawRectangle($X1, $Y1, $X2, $Y2, $Color);
            return 0;
        }

        if ($this->Antialias) {
            $this->drawLine($X1 + $Radius, $Y1, $X2 - $Radius, $Y1, $Color);
            $this->drawLine($X2, $Y1 + $Radius, $X2, $Y2 - $Radius, $Color);
            $this->drawLine($X2 - $Radius, $Y2, $X1 + $Radius, $Y2, $Color);
            $this->drawLine($X1, $Y1 + $Radius, $X1, $Y2 - $Radius, $Color);
        } else {
            $Color = $this->allocateColor($this->Picture, $R, $G, $B, $Alpha);
            imageline($this->Picture, $X1 + $Radius, $Y1, $X2 - $Radius, $Y1, $Color);
            imageline($this->Picture, $X2, $Y1 + $Radius, $X2, $Y2 - $Radius, $Color);
            imageline($this->Picture, $X2 - $Radius, $Y2, $X1 + $Radius, $Y2, $Color);
            imageline($this->Picture, $X1, $Y1 + $Radius, $X1, $Y2 - $Radius, $Color);
        }

        $Step = 360 / (2 * PI * $Radius);
        for ($i = 0; $i <= 90; $i = $i + $Step) {
            $X = cos(($i + 180) * PI / 180) * $Radius + $X1 + $Radius;
            $Y = sin(($i + 180) * PI / 180) * $Radius + $Y1 + $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos(($i + 90) * PI / 180) * $Radius + $X1 + $Radius;
            $Y = sin(($i + 90) * PI / 180) * $Radius + $Y2 - $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos($i * PI / 180) * $Radius + $X2 - $Radius;
            $Y = sin($i * PI / 180) * $Radius + $Y2 - $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);

            $X = cos(($i + 270) * PI / 180) * $Radius + $X2 - $Radius;
            $Y = sin(($i + 270) * PI / 180) * $Radius + $Y1 + $Radius;
            $this->drawAntialiasPixel($X, $Y, ["R" => $R, "G" => $G, "B" => $B, "Alpha" => $Alpha]);
        }
    }
1191089
public static void drawTo(Bitmap src, Bitmap dest, int color) {
        clearBitmap(src, color);
        Canvas canvas = new Canvas(dest);
        canvas.drawBitmap(src, 0, 0, null);
        canvas.setBitmap(null);
    }
123706
public static RoundedBitmapDrawable fromBitmapDrawable(
      Resources res,
      BitmapDrawable bitmapDrawable) {
    return new RoundedBitmapDrawable(res, bitmapDrawable.getBitmap(), bitmapDrawable.getPaint());
  }
404893
static BufferedImage gaussianBlur(BufferedImage src, BufferedImage dst, int radius) {
        int width  = src.getWidth();
        int height = src.getHeight();

        if (dst == null || dst.getWidth() != width || dst.getHeight() != height || src.getType() != dst.getType()) {
            dst = createColorModelCompatibleImage(src);
        }

        float[] kernel = createGaussianKernel(radius);

        if (src.getType() == BufferedImage.TYPE_INT_ARGB) {
            int[] srcPixels = new int[width * height];
            int[] dstPixels = new int[width * height];

            getPixels(src, 0, 0, width, height, srcPixels);

            // horizontal pass
            blur(srcPixels, dstPixels, width, height, kernel, radius);

            // vertical pass
            // noinspection SuspiciousNameCombination
            blur(dstPixels, srcPixels, height, width, kernel, radius);

            // the result is now stored in srcPixels due to the 2nd pass
            setPixels(dst, 0, 0, width, height, srcPixels);
        } else if (src.getType() == BufferedImage.TYPE_BYTE_GRAY) {
            byte[] srcPixels = new byte[width * height];
            byte[] dstPixels = new byte[width * height];

            getPixels(src, 0, 0, width, height, srcPixels);

            // horizontal pass
            blur(srcPixels, dstPixels, width, height, kernel, radius);

            // vertical pass
            // noinspection SuspiciousNameCombination
            blur(dstPixels, srcPixels, height, width, kernel, radius);

            // the result is now stored in srcPixels due to the 2nd pass
            setPixels(dst, 0, 0, width, height, srcPixels);
        } else {
            throw new IllegalArgumentException("EffectUtils.gaussianBlur() src image is not a supported type, type=[" + src.getType()
                                               + "]");
        }

        return dst;
    }
1372509
function drawRadialMinorTicks(context, options) {
    let radius = radialTicksRadius(context, options);
    let s, range, angle;
    let i = 0;
    let delta = 0;
    let minTicks = Math.abs(options.minorTicks) || 0;
    let ratio = options.ticksAngle / (options.maxValue - options.minValue);

    context.lineWidth = SmartCanvas.pixelRatio;
    context.strokeStyle = options.colorMinorTicks || options.colorStrokeTicks;

    context.save();

    if (options.exactTicks) {
        range = options.maxValue - options.minValue;
        s = minTicks ? range / minTicks : 0;
        delta = (BaseGauge.mod(options.majorTicks[0], minTicks) || 0)  * ratio;
    }

    else {
        s = minTicks * (options.majorTicks.length - 1);
    }

    for (; i < s; ++i) {
        angle = options.startAngle + delta + i * (options.ticksAngle / s);
        if (angle <= (options.ticksAngle + options.startAngle )) {
            context.rotate(drawings.radians(angle));

            context.beginPath();
            context.moveTo(0, radius);
            context.lineTo(0, radius - context.max * 0.075);
            closeStrokedPath(context);
        }
    }
}
950389
public static void drawMasked(Bitmap src, Drawable mask, Bitmap dest, int clearColor) {
        clearBitmap(dest, clearColor);
        Canvas canvas = new Canvas(dest);

        canvas.drawBitmap(src,
                new Rect(0, 0, src.getWidth(), src.getHeight()),
                new Rect(0, 0, dest.getWidth(), dest.getHeight()),
                new Paint(Paint.FILTER_BITMAP_FLAG));

        if (mask instanceof BitmapDrawable) {
            ((BitmapDrawable) mask).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        } else if (mask instanceof NinePatchDrawable) {
            ((NinePatchDrawable) mask).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_IN));
        } else {
            throw new RuntimeException("Supported only BitmapDrawable or NinePatchDrawable");
        }
        mask.setBounds(0, 0, mask.getIntrinsicWidth(), mask.getIntrinsicHeight());
        mask.draw(canvas);
        canvas.setBitmap(null);
    }
422871
public static Bitmap drawShadow(Bitmap map, int radius) {
        if (map == null)
            return null;

        BlurMaskFilter blurFilter = new BlurMaskFilter(radius, BlurMaskFilter.Blur.OUTER);
        Paint shadowPaint = new Paint();
        shadowPaint.setMaskFilter(blurFilter);

        int[] offsetXY = new int[2];
        Bitmap shadowImage = map.extractAlpha(shadowPaint, offsetXY);
        shadowImage = shadowImage.copy(Config.ARGB_8888, true);
        Canvas c = new Canvas(shadowImage);
        c.drawBitmap(map, -offsetXY[0], -offsetXY[1], null);
        return shadowImage;
    }