1 /*
2  * Copyright (c) 2022 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 #include "path_effect_test.h"
17 
18 namespace OHOS {
19 namespace Rosen {
20 namespace Drawing {
TestDrawDashPathEffect(Canvas & canvas,uint32_t width,uint32_t height)21 void PathEffectTest::TestDrawDashPathEffect(Canvas& canvas, uint32_t width, uint32_t height)
22 {
23     LOGI("+++++++ TestDrawDashPathEffect");
24 
25     Pen pen;
26     pen.SetAntiAlias(true);
27     pen.SetColor(Drawing::Color::COLOR_RED);
28     pen.SetWidth(10); // The thickness of the pen is 10
29     scalar vals[] = { 10.0, 20.0 };
30     // Number of elements in the intervals array is 2; offset into the intervals array is 25.
31     pen.SetPathEffect(PathEffect::CreateDashPathEffect(vals, 2, 25));
32     canvas.AttachPen(pen);
33 
34     Brush brush;
35     brush.SetColor(Drawing::Color::COLOR_BLUE);
36     canvas.AttachBrush(brush);
37     canvas.DrawRect({ 1200, 300, 1500, 600 }); // rect is set to (fLeft, fTop, fRight, fBottom)
38 
39     canvas.DetachPen();
40     canvas.DrawRect({ 1200, 700, 1500, 1000 }); // rect is set to (fLeft, fTop, fRight, fBottom)
41     LOGI("------- TestDrawDashPathEffect");
42 }
43 
PathEffectTestCase()44 std::vector<PathEffectTest::TestFunc> PathEffectTest::PathEffectTestCase()
45 {
46     std::vector<TestFunc> testFuncVec;
47     testFuncVec.push_back(TestDrawDashPathEffect);
48     return testFuncVec;
49 }
50 } // namespace Drawing
51 } // namespace Rosen
52 } // namespace OHOS