openharmony 鸿蒙 arkts-apis-graphics-drawing-PointUtils

2026-08-25 浏览 (1)

Class (PointUtils)

Provides tools for processing coordinate points.

NOTE

  • The initial APIs of this module are supported since API version 11. Newly added APIs will be marked with a superscript to indicate their earliest API version.

  • The initial APIs of this Class are supported since API version 26.0.0.

  • This module uses the physical pixel unit, px.

  • The module operates under a single-threaded model. The caller needs to manage thread safety and context state transitions.

Modules to Import

import { drawing } from '@kit.ArkGraphics2D';

negate

static negate(point: common2D.Point): void

Negates the coordinates of a point.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Graphics.Drawing

Parameters

NameTypeMandatoryDescription
pointcommon2D.PointYesPoint to be negated.

Example:

import { common2D, drawing } from '@kit.ArkGraphics2D';

let point: common2D.Point = { x: 10, y: 20 };
drawing.PointUtils.negate(point);
console.info('point.x:', point.x);
console.info('point.y:', point.y);

offset

static offset(point: common2D.Point, dx: number, dy: number): void

Offsets a specified coordinate point by a certain distance along the x-axis and y-axis.

Since: 26.0.0

Model restriction: This API can be used only in the stage model.

System capability: SystemCapability.Graphics.Drawing

Parameters

NameTypeMandatoryDescription
pointcommon2D.PointYesPoint to be offset.
dxnumberYesHorizontal distance to translate. A positive number indicates a translation towards the positive direction of the X axis, and a negative number indicates a translation towards the negative direction of the X axis. The value is a floating point number. The unit is physical pixel (px).
dynumberYesVertical distance to translate. A positive number indicates a translation towards the positive direction of the Y axis, and a negative number indicates a translation towards the negative direction of the Y axis. The value is a floating point number. The unit is physical pixel (px).

Example:

import { common2D, drawing } from '@kit.ArkGraphics2D';

let point: common2D.Point = { x: 10, y: 20 };
drawing.PointUtils.offset(point, 5, 10);
console.info('point.x:', point.x);
console.info('point.y:', point.y);

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 鸿蒙 软件
  • 版权声明: 本文链接 https://seaxiang.com/blog/KynzAUuI