diff --git a/android/src/main/java/com/horcrux/svg/Brush.java b/android/src/main/java/com/horcrux/svg/Brush.java index 5d100615..0e8aed9d 100644 --- a/android/src/main/java/com/horcrux/svg/Brush.java +++ b/android/src/main/java/com/horcrux/svg/Brush.java @@ -111,11 +111,12 @@ class Brush { float offsetX = rect.left; float offsetY = rect.top; + float textSize = paint.getTextSize(); if (mType == BrushType.PATTERN) { - double x = PropHelper.fromRelative(mPoints[0], width, offsetX, scale, paint.getTextSize()); - double y = PropHelper.fromRelative(mPoints[1], height, offsetY, scale, paint.getTextSize()); - double w = PropHelper.fromRelative(mPoints[2], width, offsetX, scale, paint.getTextSize()); - double h = PropHelper.fromRelative(mPoints[3], height, offsetY, scale, paint.getTextSize()); + double x = PropHelper.fromRelative(mPoints[0], width, offsetX, scale, textSize); + double y = PropHelper.fromRelative(mPoints[1], height, offsetY, scale, textSize); + double w = PropHelper.fromRelative(mPoints[2], width, offsetX, scale, textSize); + double h = PropHelper.fromRelative(mPoints[3], height, offsetY, scale, textSize); RectF vbRect = mPattern.getViewBox(); RectF eRect = new RectF((float)x, (float)y, (float)w, (float)h); @@ -157,10 +158,10 @@ class Brush { } if (mType == BrushType.LINEAR_GRADIENT) { - double x1 = PropHelper.fromRelative(mPoints[0], width, offsetX, scale, paint.getTextSize()); - double y1 = PropHelper.fromRelative(mPoints[1], height, offsetY, scale, paint.getTextSize()); - double x2 = PropHelper.fromRelative(mPoints[2], width, offsetX, scale, paint.getTextSize()); - double y2 = PropHelper.fromRelative(mPoints[3], height, offsetY, scale, paint.getTextSize()); + double x1 = PropHelper.fromRelative(mPoints[0], width, offsetX, scale, textSize); + double y1 = PropHelper.fromRelative(mPoints[1], height, offsetY, scale, textSize); + double x2 = PropHelper.fromRelative(mPoints[2], width, offsetX, scale, textSize); + double y2 = PropHelper.fromRelative(mPoints[3], height, offsetY, scale, textSize); Shader linearGradient = new LinearGradient( (float) x1, @@ -179,10 +180,10 @@ class Brush { paint.setShader(linearGradient); } else if (mType == BrushType.RADIAL_GRADIENT) { - double rx = PropHelper.fromRelative(mPoints[2], width, 0f, scale, paint.getTextSize()); - double ry = PropHelper.fromRelative(mPoints[3], height, 0f, scale, paint.getTextSize()); - double cx = PropHelper.fromRelative(mPoints[4], width, offsetX, scale, paint.getTextSize()); - double cy = PropHelper.fromRelative(mPoints[5], height, offsetY, scale, paint.getTextSize()) / (ry / rx); + double rx = PropHelper.fromRelative(mPoints[2], width, 0f, scale, textSize); + double ry = PropHelper.fromRelative(mPoints[3], height, 0f, scale, textSize); + double cx = PropHelper.fromRelative(mPoints[4], width, offsetX, scale, textSize); + double cy = PropHelper.fromRelative(mPoints[5], height, offsetY, scale, textSize) / (ry / rx); // TODO: support focus point. //double fx = PropHelper.fromRelative(mPoints[0], width, offsetX, scale); //double fy = PropHelper.fromRelative(mPoints[1], height, offsetY, scale) / (ry / rx);