15 std::vector<double> NinePatchConverter::InitSlices(
double img0,
21 auto imageDim = img1 - img0;
22 auto destDim = dst1 - dst0;
24 if (imageDim == destDim) {
27 return {img0, dst0, img1, dst1};
30 auto edge0Dim = imgC0 - img0;
31 auto edge1Dim = img1 - imgC1;
32 auto edgesDim = edge0Dim + edge1Dim;
34 if (edgesDim >= destDim) {
38 auto dstC = dst0 + destDim * edge0Dim / edgesDim;
41 img0, dst0, imgC0, dstC,
42 imgC1, dstC, img1, dst1,
49 auto dstC0 = dst0 + edge0Dim;
50 auto dstC1 = dst1 - edge1Dim;
53 img0, dst0, imgC0, dstC0,
54 imgC0, dstC0, imgC1, dstC1,
55 imgC1, dstC1, img1, dst1,
69 auto image_size = image->GetSize();
75 for (
size_t yi = 0; yi < vSlices.size(); yi += 4) {
76 auto srcY0 = vSlices[yi];
77 auto dstY0 = vSlices[yi + 1];
78 auto srcY1 = vSlices[yi + 2];
79 auto dstY1 = vSlices[yi + 3];
80 for (
size_t xi = 0; xi < hSlices.size(); xi += 4) {
81 auto srcX0 = hSlices[xi];
82 auto dstX0 = hSlices[xi + 1];
83 auto srcX1 = hSlices[xi + 2];
84 auto dstX1 = hSlices[xi + 3];
void DrawImageRect(const std::shared_ptr< Texture > &image, Rect source, Rect dest, const Paint &paint, const SamplerDescriptor &sampler={}, SourceRectConstraint src_rect_constraint=SourceRectConstraint::kFast)
void DrawNinePatch(const std::shared_ptr< Texture > &image, Rect center, Rect dst, const SamplerDescriptor &sampler, Canvas *canvas, Paint *paint)
@ kStrict
Sample only within the source rectangle. May be slower.
constexpr auto GetBottom() const
constexpr auto GetTop() const
constexpr bool IsEmpty() const
Returns true if either of the width or height are 0, negative, or NaN.
constexpr auto GetLeft() const
constexpr auto GetRight() const
constexpr static TRect MakeLTRB(Type left, Type top, Type right, Type bottom)