1/* 2 * Copyright (c) 2024 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 16import drawing from '@ohos.graphics.drawing'; 17import { DrawContext } from '@ohos.arkui.node'; 18 19export class MyFullDrawModifier extends DrawModifier { 20 public scaleX: number = 1; 21 public scaleY: number = 1; 22 23 drawFront(context: DrawContext): void { 24 let canvas = context.canvas; 25 let pen = new drawing.Pen(); 26 pen.setAntiAlias(true) 27 pen.setStrokeWidth(2); 28 pen.setColor({ 29 alpha: 255, 30 red: 0, 31 green: 125, 32 blue: 255 33 }); 34 canvas.attachPen(pen); 35 canvas.drawCircle(8, 28, 6); 36 canvas.detachPen(); 37 38 pen.setStrokeWidth(6); 39 pen.setColor({ 40 alpha: 255, 41 red: 255, 42 green: 255, 43 blue: 255 44 }); 45 canvas.attachPen(pen); 46 canvas.drawCircle(8, 28, 1); 47 canvas.detachPen(); 48 } 49 50 drawBehind(context: DrawContext): void { 51 let canvas = context.canvas; 52 let pen = new drawing.Pen(); 53 pen.setAntiAlias(true) 54 pen.setStrokeWidth(1); 55 pen.setColor({ 56 alpha: 255, 57 red: 157, 58 green: 157, 59 blue: 157 60 }); 61 canvas.attachPen(pen); 62 canvas.drawLine(8, 0, 8, 106); 63 canvas.detachPen(); 64 } 65}