# US 2024/0005573 A1 · Method for generating signed distance field image, method for generating text effect image, device and medium

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2024/0005573 A1
- Document ID: US20240005573A1
- Status: Published application
- Kind: A1
- Application number: 18/357,651
- Filed: 2023-07-24
- Published: 2024-01-04
- Earliest claimed: 2021-01-28
- Assignees: Beijing Zitiao Network Technology Co., Ltd.
- Applicants: Beijing Zitiao Network Technology Co., Ltd.
- Inventors: Liyou XU; Chenxiang ZHAO
- Web page: https://patentgrep.com/patent/US20240005573A1

## CPC

- G06T 11/23: using straight lines or curves
- G06T 7/90: Determination of colour characteristics
- G06T 11/60: Creating or editing images; Combining images with text
- G06V 10/56: relating to colour
- G06V 10/751: {Comparing pixel values or logical combinations thereof, or feature values having positional relevance, e.g. template matching}
- G06T 2207/10024: Color image
- G06T: IMAGE DATA PROCESSING OR GENERATION, IN GENERAL
- G06V: IMAGE OR VIDEO RECOGNITION OR UNDERSTANDING

## Abstract

A method for generating a signed distance field image, methods for processing a text effect, a device and a medium are provided. The method for generating a signed distance field image includes: determining a target closed curve in an unsigned distance field image of target text, and drawing a target triangle; performing counting for pixels within the target triangle based on a drawing direction of the target triangle; determining that pixels having counting results equal to 0 in the unsigned distance field image are located in an interior region of the target text, and determining that pixels having counting results not equal to 0 in the unsigned distance field image are located in the exterior region of the target text; and generating a signed distance field image of the target text based on the pixels located in the exterior region of the target text, the pixels located in the interior region of the target text, and the unsigned distance field image.

## Claims

### Claim 1

A method for generating a signed distance field image, comprising:
determining a target closed curve in an unsigned distance field image of target text, and determining an origin corresponding to the target closed curve;
drawing a target triangle by taking two adjacent sample points on the target closed curve and the origin as vertices according to a sampling order of the adjacent sample points, wherein the sampling order is a preset direction along the target closed curve;
performing counting for pixels within the target triangle based on a drawing direction of the target triangle, wherein
the drawing direction of the target triangle is a clockwise direction or a counterclockwise direction;
a counting manner in a case where the drawing direction is the clockwise direction is inverse to a counting manner in a case where the drawing direction is the counterclockwise direction; and
the counting manners comprise increment by N per count or decrement by N per count, and N is a nonzero number;
determining that pixels having counting results equal to 0 in the unsigned distance field image are located in an interior region of the target text, and determining that pixels having counting results not equal to 0 in the unsigned distance field image are located in the exterior region of the target text; and
generating a signed distance field image of the target text based on the pixels located in the exterior region of the target text, the pixels located in the interior region of the target text, and the unsigned distance field image.

### Claim 2 (depends on 1)

The method according to claim 1, wherein that the counting manner in the case where the drawing direction is the clockwise direction is inverse to the counting manner in the case where the drawing direction is the counterclockwise direction comprises that:
the counting manner for pixels within the target triangle is increment by N per count in the case that the drawing direction is the clockwise direction, and the counting manner for pixels within the target triangle is decrement by N per count in the case that the drawing direction is the counterclockwise direction; or
the counting manner for pixels within the target triangle is decrement by N per count in the case that the drawing direction is the clockwise direction, and the counting manner for pixels within the target triangle is increment by N per count in the case that the drawing direction is the counterclockwise direction.

### Claim 3 (depends on 1)

The method according to claim 1, further comprising:
for each of pixels in the signed distance field image,
splitting a distance field value corresponding to the pixel into four 8-bit unsigned integers; and
storing the four 8-bit unsigned integers by using four color channels of RGBA respectively.

### Claim 4 (depends on 1)

The method according to claim 1, further comprising:
buffering the signed distance field image of the target text.

### Claim 5 (depends on 1)

The method according to claim 1, wherein the signed distance field image of the target text is generated in real time.

### Claim 6 (depends on 1)

The method according to claim 1, wherein before determining the target closed curve in the unsigned distance field image of target text, the method further comprises:
converting a third-order Bezier curve in a target typeface file into a second-order Bezier curve to obtain a converted target typeface file; and
generating the unsigned distance field image of the target text collectively based on the converted target typeface file and vector contour information of the target text.

### Claim 7 (depends on 1)

The method according to claim 1, further comprising:
obtaining a first effect distance field image;
calculating a sum of a distance field value of a pixel in the signed distance field image of the target text and a distance field value of a pixel in the first effect distance field image located at same position coordinates as the pixel in the signed distance field image, and determining the sum as a distance field value of a pixel located at the same position coordinates in a first target distance field image; and
drawing a first target effect image for the target text based on distance field values of pixels in the first target distance field image.

### Claim 8 (depends on 7)

The method according to claim 7, further comprising:
obtaining a second effect distance field image, wherein the first effect distance field image and the second effect distance field image belong to a distance-field-image sequence and have different time stamps;
calculating a sum of a distance field value of a pixel in the signed distance field image of the target text and a distance field value of a pixel in the second effect distance field image located at same position coordinates as the pixel in the signed distance field image of the target text, and determining the sum as a distance field value of a pixel located at the same position coordinates in a second target distance field image;
drawing a second target effect image for the target text based on distance field values of pixels in the second target distance field image; and
generating a sequential effect animation for the target text based on the first target effect image and the second target effect image according to a chronological order of the time stamps.

### Claim 9 (depends on 1)

The method according to claim 1, further comprising:
in response to detecting, in the signed distance field image of the target text, a pixel having same position coordinates as a pixel in an image already drawn on a canvas, comparing a distance field value of the pixel in the signed distance field image with a distance field value of the pixel in the image already drawn on the canvas;
in response to determining, among the pixels having the same position coordinates, that the distance field value of the pixel in the signed distance field image is less than a first value, drawing the pixel in the signed distance field image onto the canvas; and
generating a contour-effect image corresponding to the target text based on pixels in the signed distance field image which are drawn onto the canvas.

### Claim 10 (depends on 1)

The method according to claim 1, further comprising:
determining, in the signed distance field image of the target text, pixels having distance field values within a preset range as target pixels corresponding to the target text;
determining color transparency values corresponding to the target pixels based on the distance field values of the target pixels, wherein for each of the target pixels, an absolute value of a distance field value of the target pixel is inversely proportional to a color transparency value of the target pixel; and
drawing a luminous-effect image corresponding to the target text based on the color transparency values corresponding to the target pixels.

### Claim 11 (depends on 1)

The method according to claim 1, further comprising:
performing position offset on pixels in the signed distance field image of the target text to obtain a first distance field image, wherein the first distance field image comprises original pixels and offset pixels obtained after the original pixels are subjected to position offset;
drawing an initial interior-shadow-effect image corresponding to the target text based on the first distance field image;
determining a target region composed of offset pixels, in the first distance field image, having distance field values greater than a preset value; and
removing the target region from the initial interior-shadow-effect image to obtain an interior-shadow-effect image for the target text.

### Claim 12 (depends on 1)

The method according to claim 1, further comprising:
determining, based on position information of pixels in the signed distance field image of the target text and a gradient-direction vector, gradient values corresponding to the pixels, wherein the gradient-direction vector represents a direction of color gradient;
determining color values of the pixels based on the gradient values corresponding to the pixels and target gradient colors; and
drawing a color-gradient-effect image corresponding to the target text based on the color values of the pixels.

### Claim 13

An electronic device, comprising:
a processor; and
a memory storing executable instructions, wherein the processor, when executing the executable instructions, is configured to:
determine a target closed curve in an unsigned distance field image of target text, and determine an origin corresponding to the target closed curve;
draw a target triangle by taking two adjacent sample points on the target closed curve and the origin as vertices according to a sampling order of the adjacent sample points, wherein the sampling order is a preset direction along the target closed curve;
perform counting for pixels within the target triangle based on a drawing direction of the target triangle, wherein
the drawing direction of the target triangle is a clockwise direction or a counterclockwise direction;
a counting manner in a case where the drawing direction is the clockwise direction is inverse to a counting manner in a case where the drawing direction is the counterclockwise direction; and
the counting manners comprise increment by N per count or decrement by N per count, and N is a nonzero number;
determine that pixels having counting results equal to 0 in the unsigned distance field image are located in an interior region of the target text, and determine that pixels having counting results not equal to 0 in the unsigned distance field image are located in the exterior region of the target text; and
generate a signed distance field image of the target text based on the pixels located in the exterior region of the target text, the pixels located in the interior region of the target text, and the unsigned distance field image.

### Claim 14 (depends on 13)

The electronic device according to claim 13, wherein the processor, when executing the executable instructions, is further configured to:
obtain a first effect distance field image;
calculate a sum of a distance field value of a pixel in the signed distance field image of the target text and a distance field value of a pixel in the first effect distance field image located at same position coordinates as the pixel in the signed distance field image, and determine the sum as a distance field value of a pixel located at the same position coordinates in a first target distance field image; and
draw a first target effect image for the target text based on distance field values of pixels in the first target distance field image.

### Claim 15 (depends on 13)

The electronic device according to claim 13, wherein the processor, when executing the executable instructions, is further configured to:
in response to detecting in the signed distance field image of the target text, a pixel having the same position coordinates as a pixel in an image already drawn on a canvas, compare a distance field value of the pixel in the signed distance field image with a distance field value of the pixel in the image already drawn on the canvas;
in response to determining, among the pixels having the same position coordinates, that the distance field value of the pixel in the signed distance field image is less than a first value, draw the pixel in the signed distance field image onto the canvas; and
generate a contour-effect image corresponding to the target text based on pixels in the signed distance field image which are drawn onto the canvas.

### Claim 16 (depends on 13)

The electronic device according to claim 13, wherein the processor, when executing the executable instructions, is further configured to:
determine, in the signed distance field image of the target text, pixels having distance field values within a preset range as target pixels corresponding to the target text;
determine color transparency values corresponding to the target pixels based on the distance field values of the target pixels, wherein for each of the target pixels, an absolute value of a distance field value of the target pixel is inversely proportional to a color transparency value of the target pixel; and
draw a luminous-effect image corresponding to the target text based on the color transparency values corresponding to the target pixels.

### Claim 17 (depends on 13)

The electronic device according to claim 13, wherein the processor, when executing the executable instructions, is further configured to:
perform position offset on pixels in the signed distance field image of the target text to obtain a first distance field image, wherein the first distance field image comprises original pixels and offset pixels obtained after the original pixels are subjected to position offset;
draw an initial interior-shadow-effect image corresponding to the target text based on the first distance field image;
determine a target region composed of offset pixels, in the first distance field image, having distance field values greater than a preset value; and
remove the target region from the initial interior-shadow-effect image to obtain an interior-shadow-effect image for the target text.

### Claim 18 (depends on 13)

The electronic device according to claim 13, wherein the processor, when executing the executable instructions, is further configured to:
determine, based on position information of pixels in the signed distance field image of the target text and a gradient-direction vector, gradient values corresponding to the pixels, wherein the gradient-direction vector represents a direction of color gradient;
determine color values of the pixels based on the gradient values corresponding to the pixels and target gradient colors; and
draw a color-gradient-effect image corresponding to the target text based on the color values of the pixels.

### Claim 19

A non-volatile computer-readable storage medium having instructions stored thereon, wherein the instructions, when being executed by a terminal device, cause the terminal device to implement steps of:
determining a target closed curve in an unsigned distance field image of target text, and determining an origin corresponding to the target closed curve;
drawing a target triangle by taking two adjacent sample points on the target closed curve and the origin as vertices according to a sampling order of the adjacent sample points, wherein the sampling order is a preset direction along the target closed curve;
performing counting for pixels within the target triangle based on a drawing direction of the target triangle, wherein
the drawing direction of the target triangle is a clockwise direction or a counterclockwise direction;
a counting manner in a case where the drawing direction is the clockwise direction is inverse to a counting manner in a case where the drawing direction is the counterclockwise direction; and
the counting manners comprise increment by N per count or decrement by N per count, and N is a nonzero number;
determining that pixels having counting results equal to 0 in the unsigned distance field image are located in an interior region of the target text, and determining that pixels having counting results not equal to 0 in the unsigned distance field image are located in the exterior region of the target text; and
generating a signed distance field image of the target text based on the pixels located in the exterior region of the target text, the pixels located in the interior region of the target text, and the unsigned distance field image.

### Claim 20 (depends on 19)

The computer-readable storage medium according to claim 19, wherein the instructions, when being executed by a terminal device, further cause the terminal device to implement steps of:
obtaining a first effect distance field image;
calculating a sum of a distance field value of a pixel in the signed distance field image of the target text and a distance field value of a pixel in the first effect distance field image located at same position coordinates as the pixel in the signed distance field image, and determining the sum as a distance field value of a pixel located at the same position coordinates in a first target distance field image; and
drawing a first target effect image for the target text based on distance field values of pixels in the first target distance field image.
