1/* 2 * Copyright (c) 2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * 通过lattice拉伸图片 18 */ 19import { drawing } from '@kit.ArkGraphics2D'; 20 21@Entry 22@Component 23struct drawingLatticeTest { 24 private xDivs: Array<number> = [1, 2, 200]; 25 private yDivs: Array<number> = [1, 2, 200]; 26 private fXCount: number = 3; 27 private fYCount: number = 3; 28 private drawingLatticeFirst: DrawingLattice = 29 drawing.Lattice.createImageLattice(this.xDivs, this.yDivs, this.fXCount, this.fYCount); 30 31 build() { 32 Scroll() { 33 Column({ space: 10 }) { 34 Text('Original Image').fontSize(20).fontWeight(700) 35 Column({ space: 10 }) { 36 Image($r('app.media.mountain')) 37 .width(260).height(260) 38 }.width('100%') 39 40 Text('Resize by lattice').fontSize(20).fontWeight(700) 41 Column({ space: 10 }) { 42 Image($r('app.media.mountain')) 43 .objectRepeat(ImageRepeat.X) 44 .width(260) 45 .height(260) 46 .resizable({ 47 lattice: this.drawingLatticeFirst 48 }) 49 }.width('100%') 50 }.width('100%') 51 } 52 } 53}