A method and related apparatus for generating handwriting.

CN116027954BActive Publication Date: 2026-09-01TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202111248680.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-10-26
Publication Date
2026-09-01
Estimated Expiration
2041-10-26

AI Technical Summary

Technical Problem

这样连接得到的线条直来直去、僵硬呆板,线条质量就很差,进而导致笔划以及最终形成的文字达不到书法艺术最起码的要求,文字绘制效果与真实书法存在较大差异

Benefits of technology

[0011]由上述技术方案可以看出,当用户希望通过手写输入的方式生成笔迹时,用户可以通过触摸对象触碰触摸屏幕并按照希望书写的文字的笔划进行移动。当触摸对象触碰到触摸屏幕并开始移动时,可以获取触摸点集合。根据触摸点集合中触摸点的分布信息确定笔划类型,不同的笔划类型根据对应字体的书法规则有不同的书写方式,进而其展示效果有所不同,尤其是在书法中,不同笔划类型尤其对应的笔锋特性。因此,可以根据笔划类型和目标字体的书法规则,得到表示笔锋位置的轨迹点,然后根据表示笔锋位置的轨迹点和触摸点集合确定第一轨迹点集合,以便将仿真笔形在第一轨迹点集合中的轨迹点上进行放置和绘制,生成对应的笔迹,并将笔迹展示在触摸屏幕上。由于第一轨迹点集合中包括了表示笔锋位置的轨迹点,且是根据目标字体的书法规则生成的,因此,在将仿真笔形在第一轨迹点集合中的轨迹点上进行放置和绘制时,生成的笔迹带有符合书法规则的笔锋特性,生成的笔迹效果更加接近于真实书法效果。本方案分析了目标字体的书法规则,将先验知识引入到笔迹的绘制美化过程中,产生了符合现实的笔锋与笔形,在忠于用户输入的基础上,实现笔迹的在线美化,且美化效果更加接近于真实书法效果,提高用户体验。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116027954B_ABST
    Figure CN116027954B_ABST
Patent Text Reader

Abstract

This application discloses a method and related apparatus for generating handwriting. When a touch object touches a touch screen and begins to move, a set of touch points can be acquired. The stroke type is determined based on the distribution information of the touch points in the set. Different stroke types have different writing methods according to the calligraphy rules of the corresponding font, resulting in different display effects, especially in calligraphy, where different stroke types correspond to specific brush tip characteristics. Therefore, based on the stroke type and the calligraphy rules of the target font, trajectory points representing the brush tip position are obtained. Then, based on the trajectory points representing the brush tip position and the set of touch points, a first set of trajectory points is determined. The simulated brush shape is then placed and drawn on the trajectory points in the first set of trajectory points to generate the corresponding handwriting, which is then displayed on the touch screen. This solution, while faithful to user input, achieves online handwriting enhancement, and the enhancement effect is closer to the real calligraphy effect, improving the user experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing, and in particular to a method and apparatus for generating handwriting. Background Technology

[0002] With the rapid development of computer technology and the increasing demand for human-computer interaction, various computer devices such as mobile phones, laptops, and tablets have successively launched handwriting input functions. The handwriting input function based on computer devices has not only improved the efficiency of people's daily office work, but also enriched the way of writing text, and therefore has been widely used in a variety of scenarios.

[0003] Taking the generation of handwritten text by installing writing software on a computer device as an example, the writing software needs to obtain discrete touch points returned by the electronic device, convert the discrete touch points into a continuous trajectory, form strokes in writing, and form text based on the strokes, thereby realizing the handwriting input function.

[0004] However, this method merely connects touch points based on their positions to form lines, then uses these lines as strokes to create characters. The resulting lines are straight, stiff, and lifeless, resulting in poor quality lines. Consequently, the strokes and the final characters fail to meet the most basic requirements of calligraphy, and the drawn characters differ significantly from authentic calligraphy. Summary of the Invention

[0005] To address the aforementioned technical issues, this application provides a handwriting generation method and related apparatus that produce realistic pen strokes and shapes. While remaining faithful to user input, it enables online handwriting enhancement, with the enhancement effect more closely resembling real calligraphy, thereby improving the user experience.

[0006] The embodiments of this application disclose the following technical solutions: In a first aspect, embodiments of this application provide a handwriting generation method, the method comprising: When a touch object touches the touch screen and begins to move, obtain the set of touch points; The stroke type is determined based on the distribution information of the touch points in the set of touch points; Based on the stroke type and the calligraphy rules of the target font, the trajectory points representing the position of the stroke are obtained; The first set of trajectory points is determined based on the trajectory points representing the position of the pen tip and the set of touch points; The simulated pen shape is placed and drawn on the trajectory points in the first trajectory point set to generate the corresponding handwriting, and the handwriting is displayed on the touch screen.

[0007] Secondly, embodiments of this application provide a handwriting generation device, the device comprising an acquisition unit, a determination unit, a generation unit, and a display unit: The acquisition unit is used to acquire a set of touch points when a touch object touches the touch screen and begins to move; The determining unit is used to determine the stroke type based on the distribution information of the touch points in the touch point set; The determining unit is further configured to obtain trajectory points representing the position of the brush tip based on the stroke type and the calligraphy rules of the target font; The determining unit is further configured to determine a first set of trajectory points based on the trajectory points representing the pen tip position and the set of touch points; The generation unit is used to place and draw the simulated pen shape on the trajectory points in the first trajectory point set to generate the corresponding handwriting. The display unit is used to display the handwriting on the touch screen.

[0008] Thirdly, embodiments of this application provide a computer device, the computer device including a processor and a memory: The memory is used to store program code and transmit the program code to the processor; The processor is used to execute the aforementioned handwriting generation method according to the instructions in the program code.

[0009] Fourthly, embodiments of this application provide a computer-readable storage medium for storing program code for executing the aforementioned handwriting generation method.

[0010] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the aforementioned handwriting generation method.

[0011] As can be seen from the above technical solution, when a user wants to generate handwriting through handwriting input, the user can touch the touch screen with a touch object and move it according to the strokes of the text to be written. When the touch object touches the touch screen and begins to move, a set of touch points can be obtained. The stroke type is determined based on the distribution information of the touch points in the touch point set. Different stroke types have different writing methods according to the calligraphy rules of the corresponding font, and thus their display effects are different. Especially in calligraphy, different stroke types have specific brush tip characteristics. Therefore, based on the stroke type and the calligraphy rules of the target font, trajectory points representing the brush tip position can be obtained. Then, based on the trajectory points representing the brush tip position and the set of touch points, a first set of trajectory points is determined so that the simulated pen shape can be placed and drawn on the trajectory points in the first set of trajectory points to generate the corresponding handwriting, which is then displayed on the touch screen. Since the first set of trajectory points includes trajectory points representing the position of the brushstrokes and is generated according to the calligraphy rules of the target font, when the simulated brush shape is placed and drawn on the trajectory points in the first set, the generated handwriting possesses brushstroke characteristics that conform to calligraphy rules, resulting in a handwriting effect that is closer to real calligraphy. This solution analyzes the calligraphy rules of the target font and introduces prior knowledge into the handwriting drawing and beautification process, producing realistic brushstrokes and shapes. While remaining faithful to user input, it achieves online handwriting beautification with an effect that is closer to real calligraphy, thus improving the user experience. Attached Figure Description

[0012] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0013] Figure 1 An example diagram of a software interface for implementing handwriting input function is provided in an embodiment of this application; Figure 2 A schematic diagram of the system architecture of a handwriting generation method provided in this application embodiment; Figure 3 Example diagram of a hardware device for a handwriting generation method provided in this application embodiment; Figure 4 A flowchart of a handwriting generation method provided in an embodiment of this application; Figure 5 An example diagram illustrating a jitter point discrimination method provided in an embodiment of this application; Figure 6An example diagram of corresponding stroke types under different angle ranges provided by the embodiments of the present application; Figure 7 An example diagram of a horizontal stroke with a brush edge provided by the embodiments of the present application; Figure 8 An example diagram of a determination method of trajectory points representing brush edge positions provided by the embodiments of the present application; Figure 9 An example diagram of a contact shape provided by the embodiments of the present application; Figure 10 An example diagram of a simulated brush shape provided by the embodiments of the present application; Figure 11 An example diagram of obtaining a closed shape by performing polygon filling on a simulated brush shape provided by the embodiments of the present application; Figure 12 An example diagram of a simulated brush shape, rotation of the simulated brush shape, and scaling of the simulated brush shape provided by the embodiments of the present application; Figure 13 An example diagram of a first trajectory point set, and the effect of placing and drawing a simulated brush shape based on the first trajectory point set provided by the embodiments of the present application; Figure 14 An effect diagram of handwriting generated by two existing whiteboard softwares and an effect diagram of handwriting generated by the method provided by the embodiments of the present application provided by the embodiments of the present application; Figure 15 An example diagram of a calligraphy effect with a stroke type of "left-falling stroke" provided by the embodiments of the present application; Figure 16 An example diagram of a calligraphy effect with a stroke type of "right-falling stroke" provided by the embodiments of the present application; Figure 17 A flowchart of a handwriting generation method provided by the embodiments of the present application; Figure 18 A structural diagram of a handwriting generation apparatus provided by the embodiments of the present application; Figure 19 A structural diagram of a terminal device provided by the embodiments of the present application; Figure 20 A structural diagram of a server provided by the embodiments of the present application. DETAILED DESCRIPTION

[0014] The following describes the embodiments of the present application with reference to the accompanying drawings.

[0015] With the rapid development of computer technology and the increasing demand for human-computer interaction, various computer devices can realize handwriting input functions. This handwriting input function mainly involves creating handwriting through handwriting input methods. The generated handwriting can be the final handwriting displayed on the screen (e.g., in various meeting software, whiteboard software, drawing software, and memo software). Figure 1 Two whiteboard software and memo software are shown. Alternatively, handwriting can be used as an intermediate product to finally display printed text on the screen based on handwriting input to determine printed text from a candidate word library (input method software, see...). Figure 1 (As shown).

[0016] When users input text on a touchscreen via handwriting, the movement of the touch object is relatively random, merely displaying the strokes that make up the characters—horizontal, vertical, left-falling, right-falling, etc.—and lacks the aesthetic appeal of writing on paper. This results in messy, unattractive handwriting that fails to match the experience of writing on paper. Therefore, it is crucial to enhance the handwriting during the handwriting generation process to achieve a more realistic calligraphy effect.

[0017] To address the aforementioned technical issues, this application provides a handwriting generation method. This method analyzes the calligraphy rules of the target font, introduces prior knowledge into the handwriting drawing and beautification process, and generates realistic strokes and shapes. Based on faithful user input, it achieves online handwriting beautification, and the beautification effect is closer to the real calligraphy effect, thus improving the user experience.

[0018] The method provided in this application can be applied to any scenario with handwriting input, including but not limited to various meeting software, whiteboard software, input method software, drawing software, memo software, etc.

[0019] It should be noted that the text input by handwriting in this embodiment can be Chinese, English, or other languages, and the font can be KaiTi, SongTi, HeiTi, or other fonts. This embodiment does not limit this.

[0020] It should be noted that the execution subject of the handwriting generation method provided in this application embodiment can be a computer device with a touch screen to realize handwriting input. The computer device can be, for example, a terminal device, a server, or both a terminal device and a server. The server can be an independent physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smartphone, tablet computer, laptop computer, vehicle terminal, etc., but is not limited to these. The terminal device and the server can be directly or indirectly connected through wired or wireless communication, which is not limited in this application. The following description will take a terminal device as an example to illustrate the handwriting generation method.

[0021] See Figure 2 , Figure 2 This is a schematic diagram of the system architecture for the handwriting generation method provided in an embodiment of this application. The system architecture includes a terminal device 201. The terminal device 201 includes a touch screen, which can be found in [reference needed]. Figure 3 As shown. Users can touch the touchscreen and begin moving the object, thus displaying the movement trajectory on the touchscreen according to the movement of their finger.

[0022] The touch object is the object that the user touches on the touch screen, such as the user's finger, stylus (stylus), etc. Figure 3 Taking the user's finger as an example, the finger moves sequentially from left to right, eventually forming a shape on the touch screen. Figure 3 The movement trajectory shown.

[0023] When a user wants to generate handwriting input, the user can touch the touch screen and move it according to the strokes of the text they want to write. The movement trajectory is actually the user's handwriting, thus obtaining the text the user wants to write.

[0024] When a touch object touches the touch screen and begins to move, the set of touch points can be obtained, for example... Figure 2 The set of touch points includes , , ... , , , ... These represent different touch points. The stroke type is determined based on the distribution information of the touch points in the touch point set. Different stroke types have different writing methods according to the calligraphy rules of the corresponding font, resulting in different display effects. This is especially true in calligraphy, where different stroke types correspond to specific brush tip characteristics. Therefore, based on the stroke type and the calligraphy rules of the target font, the trajectory points representing the brush tip position can be obtained (see...). Figure 2 middle and (As shown). Among them, the brush tip is an important component of calligraphy, used to embody the artistic techniques and characteristics of writing characters, and is generally mainly reflected at the beginning and end of the stroke.

[0025] Then, a first set of trajectory points is determined based on the trajectory points representing the pen tip position and the set of touch points. This allows the simulated pen shape to be placed and drawn on the trajectory points in the first set, generating corresponding handwriting, which is then displayed on the touch screen. Because the first set of trajectory points includes trajectory points representing the pen tip position and is generated according to the calligraphy rules of the target font, the generated handwriting, when placed and drawn on the trajectory points in the first set, possesses pen tip characteristics conforming to calligraphy rules, resulting in a handwriting effect closer to real calligraphy.

[0026] Next, the handwriting generation method provided in the embodiments of this application will be described with reference to the accompanying drawings, using a terminal device as the execution subject. See also Figure 4 The method includes: S401. When a touch object touches the touch screen and begins to move, obtain the set of touch points.

[0027] When a touch object, such as a finger, touches the touch screen and begins to move, the terminal device returns the location information (e.g., coordinates) of the touch point and the corresponding acquisition time (accurate to milliseconds). Then, based on these touch points, a set of touch points is obtained, which can be represented by T.

[0028] In one possible implementation, due to hardware errors in the terminal device and slight finger tremors, jitter points may be generated, meaning the collected touch points may be jitter points. Therefore, to avoid jitter points affecting subsequent handwriting generation, in this embodiment, it can be determined whether the collected touch points are jitter points, and then touch points that are not jitter points can be added to the touch point set.

[0029] In this embodiment, it can be determined whether a touch point is a jitter point based on Euclidean spatial distance. If it is a jitter point, it is ignored; if it is not a jitter point, the touch point is added to the touch point set T. The method for determining whether a touch point (called the current touch point) is a jitter point based on Euclidean spatial distance can be to calculate the distance d between the current touch point and the previous touch point (this distance d is the Euclidean spatial distance). If the distance d is less than a distance threshold D, then the current touch point is a jitter point; if the distance d is greater than the distance threshold D, then the current touch point is not a jitter point. Figure 5 As shown. Touch points that are not jitter points are added to the touch point set T. Specifically, let the coordinates of the previous touch point be represented as [pre_x, pre_y], and the coordinates of the current touch point be represented as [cur_x, cur_y]. Then the calculated position of the smoothing point is: [1-D / d cur_x+D / d pre_x, 1-D / d cur_y+D / d [pre_y], where D is the distance threshold, d is the distance between the current touch point and the previous touch point, pre_x represents the x-coordinate of the previous touch point, pre_y represents the y-coordinate of the previous touch point, cur_x represents the x-coordinate of the current touch point, and cur_y represents the y-coordinate of the current touch point. The calculated smoothing points are as follows: Figure 5 The point marked with M is shown in the image. This smoothed point is then added to the touch point set T, and the previous touch point is updated to a smoothed point. The same operation is performed for subsequent touch points. Note that for the first touch point, it is directly added to the touch point set T.

[0030] By removing jitter points, errors caused by hardware defects in the terminal device and slight finger tremors can be avoided, resulting in more accurate handwriting in subsequent generation.

[0031] S402. Determine the stroke type based on the distribution information of the touch points in the set of touch points.

[0032] Based on the distribution information of touch points in the touch point set, the direction of the trajectory formed by the touch points can be determined, thereby determining the movement direction of the touched object and thus determining the type of stroke the user wishes to write. Stroke types include basic stroke types and compound stroke types. Basic stroke types can include, for example, dots, horizontal strokes, vertical strokes, left-falling strokes, right-falling strokes, hooks, and rising strokes. Compound stroke types can be composed of basic stroke types, such as horizontal strokes with a bend, horizontal strokes with a bend and a hook, etc. Compound stroke types have a clear inflection point at the junction of basic stroke types, meaning that the movement direction of the touched object changes significantly.

[0033] In some cases, the distribution information includes quantity information and position information, then the implementation of S402 may be: when the touch object stops touching the touch screen, if it is determined according to the quantity information that the number of touch points in the touch point set is less than the quantity threshold, the stroke type is determined to be a dot. If it is determined according to the quantity information that the number of touch points in the touch point set reaches the quantity threshold, the angle of the connecting line between the touch points in the touch point set is determined according to the position information, and then the stroke type is determined according to the angle of the connecting line between the touch points.

[0034] Wherein, since the initial movement direction of the touch object can be reflected by the position change between the earliest collected touch points, the angle of the connecting line between the touch points may be the angle of the connecting line between the first touch point and the second touch point in the touch point set , then according to the stroke type is determined.

[0035] The judgment rules are shown in Table 1 and Figure 6 , in Table 1, when the angle is in different angle ranges, the determined stroke types may be different: Table 1

[0036] Wherein, Figure 6 the corresponding stroke types under different angle ranges are shown in the form of a two-dimensional plane coordinate system.

[0037] S403: Obtain trajectory points representing brush edge positions according to the stroke type and the calligraphy rules of a target font.

[0038] In an actual writing process (such as writing with a writing brush, a pen, a pencil, or a marker pen), each stroke has three steps of "starting the stroke", "writing the stroke" and "closing the stroke" according to calligraphy rules, and the "starting the stroke" and "closing the stroke" form the brush edges. Different fonts correspond to different calligraphy rules, and the formed brush edges may also be different. However, in a user's handwritten input, the movement of the touch object only reflects the stroke writing step, so the brush edges are missing. Taking the font being regular script, the calligraphy rule being the calligraphy rule of regular script, and the stroke type being "horizontal" as an example, the "horizontal" stroke with a brush edge is as shown in Figure 7 , wherein the position marked by a circle is the brush edge position.

[0039] Therefore, in the embodiment of the present application, in order to supplement the brush edges, a terminal device needs to obtain trajectory points representing brush edge positions according to the stroke type and the calligraphy rules of a target font. Wherein, the target font may be a default font or preset by a user, and the target font may be regular script, Song typeface, boldface or other fonts. The embodiment of the present application is mainly introduced by taking the target font being regular script as an example.

[0040] By calculating the position of the brush tip, the corresponding trajectory points can be filled in, so that the brush tip characteristics can be generated in the subsequent handwriting generation, thus more closely resembling the effect of real calligraphy.

[0041] In one possible implementation, for different stroke types, the stroke length and target angle can be set according to the calligraphy rules of different fonts. The coordinates of the trajectory point representing the stroke position are related to its adjacent touch points, stroke length, and target angle. Therefore, in S403, the way to obtain the trajectory point representing the stroke position based on the stroke type and the calligraphy rules of the target font can be to determine the stroke length and target angle based on the stroke type and the calligraphy rules of the target font, and then determine the trajectory point representing the stroke position based on the stroke length, target angle, and the position information of adjacent touch points. Here, adjacent touch points are the touch points in the touch point set that are adjacent to the trajectory point representing the stroke position.

[0042] It should be noted that when the touch object stops touching the touch screen, it can be considered that the user has completed writing a stroke. At this time, the trajectory points indicating the position of the stroke include the starting trajectory point and the ending trajectory point. When the touch object continues to touch the touch screen, it can be considered that the user is still writing the stroke. At this time, the trajectory points indicating the position of the stroke include the starting trajectory point.

[0043] Below, taking the trajectory points representing the position of the brush tip, including the starting trajectory point and the ending trajectory point, as an example, combined with... Figure 8 This section describes how to determine the trajectory points representing the position of the pen tip.

[0044] by Figure 8 Taking the horizontal line in the middle as an example, the black dots , ... are the touch points. , These are the first and second touch points, respectively, and the line segment. The angle is , This represents the i-th touch point, whose coordinates are... Set the pen tip length to The target angle is 135 degrees, and the starting point of the completed stroke trajectory is... The point where the stroke ends is In calculating the starting trajectory point At that time, the target angle is the line connecting them. and The angle. Obtained through calculation. Coordinates are Similarly, if the last touch point is... And the angle between the two last two touch points is Then the point of the ending trajectory Coordinates are .

[0045] Similarly, the starting and ending points of other stroke types can be calculated using a similar method. Note that the determination of the stroke position here is only based on the regular script as an example; the principle can be extended to other fonts.

[0046] S404. Determine the first set of trajectory points based on the trajectory points representing the pen tip position and the set of touch points.

[0047] For ease of explanation, the first set of trajectory points can be represented by R. In the embodiments of this application, the method for determining the first set of trajectory points may vary depending on the situation. In some cases, if the collected touch points are relatively dense, the set of touch points and the trajectory points representing the pen stroke position are sufficient to generate a relatively smooth and effective handwriting. In this case, the trajectory points representing the pen stroke position are added to the set of touch points to directly obtain the first set of trajectory points.

[0048] However, in other cases, due to the response time required for a touchscreen to respond to a touch object, the number of touch points collected by the terminal device may be relatively small due to the limitation of response time (which is related to the sampling rate). In this case, in order to obtain a smoother, more natural, and better handwriting later, the method for determining the first trajectory point set can be to add the trajectory points representing the pen stroke position to the touch point set to obtain a second trajectory point set, and then interpolate the trajectory points in the second trajectory point set to obtain the first trajectory point set. The first trajectory point set includes the trajectory points in the second trajectory point set and the interpolated points. The interpolation method used in this embodiment can be any known interpolation method, such as Bezier interpolation, natural neighbor interpolation, nearest neighbor interpolation, etc. This embodiment mainly uses Bezier interpolation (interpolation based on Bezier curves) as an example.

[0049] Specifically, if the order of the Bézier curve is set to k-1, then the equation of the Bézier curve is:

[0050]

[0051] in, Represents a Bézier curve. Indicate control points The corresponding coefficients, This represents the (i+1)th control point, where k is the Bessel order plus 1. This represents the number of control points, where t is the step size. The number of interpolation points is set to... Then t The step size is 0, increasing to 1. Following the acquisition order, select k+1 trajectory points from the first trajectory point set as control points, with a repetition count of 1. Repeat this step until the end. If the number of trajectory points in the first trajectory point set is not divisible by k+1, adjust the Bezier order of the last iteration to reduce the remaining number by one. For example, when the trajectory points in the first trajectory point set are sequentially (... , , ... , ),in, , , ... This represents the touch point in the first set of trajectory points. This represents the starting trajectory point in the first trajectory point set. Let k represent the ending trajectory point in the first trajectory point set, and k be 4. Then the control points for the three trajectories are respectively ( , , , (), , , , , (), , , , ).

[0052] Through the above interpolation process, a smoother, more natural transition, and better effect of handwriting can be obtained, which is closer to the effect of real calligraphy.

[0053] S405. Place and draw the simulated pen shape on the trajectory points in the first trajectory point set to generate the corresponding handwriting, and display the handwriting on the touch screen.

[0054] In the physical world, the contact shape between the pen tip and the paper surface will be a "dot", as follows: Figure 9 As shown. This application's embodiments, referencing the physical world, design boundary points for the contact shape, defining the set of boundary points as a simulated pen shape U, as... Figure 10 As shown, in Figure 10 The simulated pen shape U includes And the point between the two, where express Figure 9 The diagram shows the boundary points at both ends of the simulated pen shape. In one possible implementation, the boundary points of the contact shape can be manually designed using the Belse curve tool.

[0055] During the design process, it is possible to make The midpoint of the line connecting the points is the origin of the coordinate system. Next, let the simulated pen shape U be the vertex, and use polygon filling technology to obtain a closed shape, such as... Figure 11 As shown.

[0056] It should be noted that the simulated pen shape in the embodiments of this application is a calligraphy brush shape, and the idea can be extended to markers, pencils, fountain pens, etc., to set different simulated pen shapes.

[0057] During the writing process, the angle of the contact shape may change with the movement direction of the touched object. Simultaneously, the variation in pen width in the physical world reflects the fluidity of calligraphy. To match the actual calligraphic effect, the width of the contact shape (equivalent to the pen width in the physical world) may also change accordingly. Therefore, in one possible implementation, the simulated pen shape is placed and drawn on trajectory points in the first trajectory point set. The method for generating the corresponding handwriting can be to determine the rotation angle and scaling factor corresponding to each trajectory point of the simulated pen shape in the first trajectory point set, and then place and draw the simulated pen shape on the corresponding trajectory point according to the rotation angle and scaling factor to generate the corresponding handwriting. Here, the rotation angle can be 0 (relative to the designed simulated pen shape (e.g., ...). Figure 10 (As shown) No rotation occurred, or it can be other values; the scaling factor can be 0 (relative to the designed simulated pen shape (e.g.) Figure 10 (As shown) No scaling occurred, i.e., no change in the width of the contact shape occurred; it can also be other values.

[0058] After obtaining the rotation angle and scaling factor, the simulated pen shape can be transformed according to the rotation angle and scaling factor, using the trajectory points in the first trajectory point set as the origin of the coordinate system, to obtain the boundary point coordinates of the transformed simulated pen shape; the transformed simulated pen shape can be placed and drawn according to the boundary point coordinates; the transformed simulated pen shape can be filled with polygons to obtain a closed shape, thus forming the corresponding handwriting.

[0059] For example Figure 12 As shown, Figure 12 Figure (1) shows the simulated pen shape obtained from the design. The angle is 0 (i.e.) If the rotation angle is... Then after rotation The angle is , that is to Rotate the entire simulated pen shape with the center as the origin of the coordinate system. , to obtain Figure 12 As shown in Figure (2), for all boundary points in the simulated pen shape, the following formula is used for rotation processing to obtain the rotated simulated pen shape. :

[0060] in, To simulate the coordinates of boundary points in the pen shape, These are the coordinates of the boundary points of the rotated simulated pen shape.

[0061] Finally, place the simulated pen shape according to the scaling factor. If the user-specified standard line width is... The design of the simulated pen shape The length is e, and the scaling factor corresponding to the trajectory point is Based on scaling factor The coordinates of the boundary points of the simulated pen shape after scaling transformation are as follows:

[0062] in,( ( ) represents the coordinates of the boundary points of the transformed simulated pen shape. Let (x, y) be the coordinates of the boundary points of the rotated simulated pen shape, and (x, y) be the coordinates of the trajectory points in the first trajectory point set. The final transformed simulated pen shape is as follows: Figure 12 The figure shown in (3) is shown in the middle.

[0063] In summary, the embodiments of this application target each trajectory point in the first trajectory point set, such as... Figure 13 As shown in Figure 1301, a simulated pen shape with width and angle transformations is placed, as follows. Figure 13 As shown in Figure 1302. Finally, for each transformed simulated pen shape, polygon filling is performed to obtain a closed shape, forming the corresponding handwriting.

[0064] The method provided in this application's embodiments is compared with two existing whiteboard software programs, such as... Figure 14 As shown, 1401 and 1402 are the effect diagrams of handwriting generated by two current whiteboard software programs, and 1403 is the effect diagram of handwriting generated by the method provided in this application embodiment. It can be seen that the beautification effect of the method provided in this application embodiment is closer to the real calligraphy effect and can produce a more beautiful beautification effect.

[0065] As can be seen from the above technical solution, when a user wants to generate handwriting through handwriting input, the user can touch the touch screen with a touch object and move it according to the strokes of the text to be written. When the touch object touches the touch screen and begins to move, a set of touch points can be obtained. The stroke type is determined based on the distribution information of the touch points in the touch point set. Different stroke types have different writing methods according to the calligraphy rules of the corresponding font, and thus their display effects are different. Especially in calligraphy, different stroke types have specific brush tip characteristics. Therefore, based on the stroke type and the calligraphy rules of the target font, trajectory points representing the brush tip position can be obtained. Then, based on the trajectory points representing the brush tip position and the set of touch points, a first set of trajectory points is determined so that the simulated pen shape can be placed and drawn on the trajectory points in the first set of trajectory points to generate the corresponding handwriting, which is then displayed on the touch screen. Since the first set of trajectory points includes trajectory points representing the position of the brushstrokes and is generated according to the calligraphy rules of the target font, when the simulated brush shape is placed and drawn on the trajectory points in the first set, the generated handwriting possesses brushstroke characteristics that conform to calligraphy rules, resulting in a handwriting effect that is closer to real calligraphy. This solution analyzes the calligraphy rules of the target font and introduces prior knowledge into the handwriting drawing and beautification process, producing realistic brushstrokes and shapes. While remaining faithful to user input, it achieves online handwriting beautification with an effect that is closer to real calligraphy, thus improving the user experience.

[0066] Next, we will provide a detailed explanation of how the rotation angle and scaling factor involved in S405 are determined.

[0067] Since the angle of the contact shape may change with the movement direction of the touched object, and for a certain trajectory point, such as a target trajectory point, the movement direction of the touched object can be represented by the angle of the line connecting the trajectory points, in this embodiment, for a certain trajectory point, such as a target trajectory point, the angle of the line connecting the target trajectory point and the next trajectory point of the target trajectory point can be determined, and the angle of the line is used as the rotation angle of the simulated pen shape at the target trajectory point. The rotation angle can be... express.

[0068] It should be noted that the trajectory points in the first trajectory point set may be touch points or trajectory points representing pen tip positions. In other cases, the first trajectory point set may include interpolation points in addition to the two types of trajectory points mentioned above. The method for determining the scaling factor may differ for different trajectory point types. Therefore, in this embodiment, the method for determining the scaling factor corresponding to each trajectory point in the first trajectory point set of the simulated pen shape may be to determine the trajectory point type to which the trajectory point in the first trajectory point set belongs; and then determine the scaling factor of the corresponding trajectory point based on the trajectory point type.

[0069] In the physical world, writers control the thickness of strokes by applying pressure to the pen tip. However, since most touchscreens on common terminal devices lack pressure sensors, they cannot acquire pressure values. Considering that writing speed is highly correlated with pressure (i.e., slower speed where the pressure is heavier and faster speed where the pressure is lighter), the writing speed can be used as a control factor for the width variation of the contact shape. Specifically, if the trajectory point type of the first trajectory point in the first trajectory point set belongs to all other touch points in the touch point set except the first touch point, the scaling factor of the simulated pen shape corresponding to the first trajectory point is determined based on the writing speed corresponding to the first trajectory point.

[0070] According to S401 in this embodiment, when acquiring the set of touch points, the position information of the touch points and the acquisition time corresponding to the touch points are obtained. Taking the first trajectory point as an example, the moving speed can be approximately calculated by the distance between the first trajectory point and the previous trajectory point and the acquisition time difference. This embodiment analyzes a large amount of user input information and manually sets a baseline speed. Let the moving speed of the nth touch point be... Then the scaling factor corresponding to the nth touch point .

[0071] Meanwhile, experienced calligraphers maintain smooth pressure control without drastic changes that could lead to abrupt changes in pen width. Therefore, to approximate the actual effect of calligraphy, this application's embodiments introduce a smoothing factor. The smoothed scaling factor is The iterative expression for the designed smoothing scaling factor is shown below. The smoothing factor is manually set according to different stroke types. Different: +

[0072] in, This is the smoothed scaling factor corresponding to the nth touch point. As a smoothing factor, This is the smoothed scaling factor corresponding to the (n-1)th touch point. This is the scaling factor corresponding to the nth touch point.

[0073] It should be noted that the scaling factor calculated by the method provided in this application embodiment does not require a pressure sensor on the touch screen of the terminal device, thus making it applicable to various terminal devices and expanding the scope of application.

[0074] In a possible implementation, for the start of a stroke (e.g., a starting trajectory point representing the position of a brush tip or the first touch point in the set of touch points) or the end of a stroke (e.g., an ending trajectory point representing the position of a brush tip), according to calligraphy rules, the thickness of the start point or end point of different stroke types has corresponding conventions, for example Figure 15 as shown in the figure, the start of a "pie" (left-falling stroke) is thick and the end is thin. As another example Figure 16 as shown in the figure, the start of a "na" (right-falling stroke) is thin and the end is thick. Therefore, it is necessary to manually set value according to the stroke type, value can be set according to calligraphy rules. That is, if the trajectory point type to which the second trajectory point in the first set of trajectory points belongs is a starting trajectory point representing a brush tip position, an ending trajectory point representing a brush tip position, or the first touch point in the set of touch points, the scaling factor corresponding to the second trajectory point is determined according to the calligraphy rules of the target font.

[0075] For example, in the embodiment of the present application, the of a "pie" can be set to 1, and the of a "na" can be set to 0.5, and the starting stroke width is determined by . Of course, can also be set according to actual requirements. Of course, if it is necessary to set the ending stroke width, a similar method can be used to set the of the trajectory point corresponding to the end of different stroke types.

[0076] In some possible implementations, the first set of trajectory points may be obtained by interpolating trajectory points in the second set of trajectory points, that is, the first set of trajectory points may include interpolation points. If the trajectory point type to which the third trajectory point in the first set of trajectory points belongs is an interpolation point between two trajectory points, since the interpolation point lacks acquisition events and the movement speed cannot be calculated, when calculating the scaling factor corresponding to the simulated brush shape at the third trajectory point, the scaling factor corresponding to the simulated brush shape at the third trajectory point can be obtained by linearly varying the scaling factors of the two trajectory points according to the positional relationship between the third trajectory point and the two trajectory points.

[0077] For example, there are m interpolation points between the (n-1)th trajectory point and the nth trajectory point, and it is necessary to calculate the scaling factor for each interpolation point, but the interpolation point lacks acquisition events and the movement speed cannot be calculated. Therefore, the scaling factor of the interpolation point varies linearly between the scaling factor values at the two ends of the interpolated element (the (n-1)th trajectory point and the nth trajectory point), then the scaling factor of the simulated brush shape at interpolation point t

[0078]

[0079] wherein, t is the index of the interpolation point, is the scaling factor of the simulated brush shape at interpolation point t, The scaling factor for the nth trajectory point. t is the scaling factor for the (n-1)th trajectory point, m is the number of interpolation points, and i indicates that the interpolation point t is the i-th interpolation point between the (n-1)th trajectory point and the nth trajectory point.

[0080] It is worth noting that, in order to prevent abnormal values ​​in the width of the contact shape due to abnormal user input or hardware failure, the scaling factor needs to be limited to the range of 0.2 to 1.0.

[0081] It should be noted that for trajectory points of different types mentioned above, it is relatively convenient to obtain the corresponding scaling factors using appropriate methods. These different scaling factors can be uniformly represented using... This means that the formula for calculating the boundary point coordinates of the simulated pen shape after the above transformation is substituted into the formula for calculation.

[0082] It should be noted that, based on the implementation methods provided in the above aspects, this application can be further combined to provide more implementation methods.

[0083] The handwriting generation method provided in this application embodiment will be described below in conjunction with practical application scenarios. Taking the target font as KaiTi and the generated handwriting effect as calligraphy as an example, the pre-designed simulated pen shape is a calligraphy pen shape. During the process of the user moving their finger on the touch screen to generate handwriting, in order to make the handwriting effect displayed on the touch screen closer to the effect of real calligraphy, this application embodiment provides a handwriting generation method, see [link to relevant documentation]. Figure 17 The method includes: S1701, when a user's finger touches the touch screen and begins to move, the terminal device records the distribution information of the touch point and the collection time.

[0084] The distribution information includes location information and quantity information.

[0085] S1702. The terminal device determines the jitter points to obtain the set of touch points.

[0086] S1703. The terminal device determines the stroke type based on the distribution information of the touch points in the touch point set.

[0087] S1704. The terminal device obtains the trajectory points representing the position of the brush tip based on the stroke type and the calligraphy rules of regular script.

[0088] S1705. The terminal device adds the trajectory points representing the pen stroke position to the touch point set to obtain the second trajectory point set.

[0089] S1706. The terminal device performs Bezier interpolation on the trajectory points in the second trajectory point set to obtain the first trajectory point set.

[0090] S1707. The terminal device determines the rotation angle and scaling factor corresponding to each trajectory point in the first trajectory point set for the simulated pen shape.

[0091] S1708. The trajectory points in the first trajectory point set of the terminal device are the origin of the coordinate system. The simulated pen shape is transformed according to the rotation angle and scaling factor to obtain the boundary point coordinates of the transformed simulated pen shape.

[0092] S1709. The terminal device places and draws the transformed simulated pen shape based on the boundary point coordinates.

[0093] S1710 The terminal device performs polygon filling on the transformed simulated pen shape to obtain a closed shape, thus forming the corresponding handwriting.

[0094] Based on the handwriting generation method provided in the foregoing embodiments, this application also provides a handwriting generation device 1800, see [link to previous document]. Figure 18 The device 1800 includes an acquisition unit 1801, a determination unit 1802, a generation unit 1803, and a display unit 1804. The acquisition unit 1801 is used to acquire a set of touch points when a touch object touches the touch screen and begins to move. The determining unit 1802 is used to determine the stroke type based on the distribution information of the touch points in the touch point set; The determining unit 1802 is further configured to obtain a trajectory point representing the position of the brush tip based on the stroke type and the calligraphy rules of the target font; The determining unit 1802 is further configured to determine a first set of trajectory points based on the trajectory points representing the pen tip position and the set of touch points; The generation unit 1803 is used to place and draw the simulated pen shape on the trajectory points in the first trajectory point set to generate the corresponding handwriting. The display unit 1804 is used to display the handwriting on the touch screen.

[0095] In one possible implementation, the determining unit 1802 is configured to: The stroke length and target angle are determined according to the stroke type and the calligraphy rules of the target font; Based on the pen tip length, the target angle, and the position information of adjacent touch points, the trajectory point representing the pen tip position is determined, and the adjacent touch point is the touch point in the set of touch points that is adjacent to the trajectory point representing the pen tip position.

[0096] In one possible implementation, when the touch object stops touching the touch screen, the trajectory point representing the pen stroke position includes a starting trajectory point and an ending trajectory point; when the touch object continues to touch the touch screen, the trajectory point representing the pen stroke position includes a starting trajectory point.

[0097] In one possible implementation, the determining unit 1802 is configured to: The trajectory points representing the pen tip positions are added to the touch point set to obtain a second trajectory point set; Interpolate the trajectory points in the second trajectory point set to obtain the first trajectory point set, which includes the trajectory points in the second trajectory point set and the interpolated points.

[0098] In one possible implementation, the generation unit 1803 is used for: Determine the rotation angle and scaling factor of the simulated pen shape for each trajectory point in the first trajectory point set; The simulated pen shape is placed and drawn on the corresponding trajectory point according to the rotation angle and the scaling factor to generate the corresponding handwriting.

[0099] In one possible implementation, each trajectory point in the first set of trajectory points is used as a target trajectory point, and the generation unit 1803 is used to: Determine the angle of the line connecting the target trajectory point and the next trajectory point of the target trajectory point; The angle of the connecting line is taken as the rotation angle of the simulated pen shape at the target trajectory point.

[0100] In one possible implementation, the generation unit 1803 is used for: Determine the type of trajectory point to which the trajectory points in the first set of trajectory points belong; The scaling factor of the corresponding trajectory point is determined based on the trajectory point type.

[0101] In one possible implementation, the generation unit 1803 is used for: If the trajectory point type of the first trajectory point in the first trajectory point set is any of the other touch points in the touch point set besides the first touch point, the scaling factor of the simulated pen shape at the first trajectory point is determined according to the moving speed corresponding to the first trajectory point. If the trajectory point type of the second trajectory point in the first trajectory point set is the starting trajectory point representing the position of the pen tip, or the ending trajectory point representing the position of the pen tip, or the first touch point in the touch point set, the scaling factor corresponding to the second trajectory point is determined according to the calligraphy rules of the target font. If the first set of trajectory points is obtained by interpolating the trajectory points in the second set of trajectory points, and the trajectory point type of the third trajectory point in the first set of trajectory points is an interpolation point between the two trajectory points, then the scaling factor of the two trajectory points is linearly changed according to the positional relationship between the third trajectory point and the two trajectory points to obtain the scaling factor of the simulated pen shape corresponding to the third trajectory point.

[0102] In one possible implementation, the generation unit 1803 is used for: Using the trajectory points in the first set of trajectory points as the origin of the coordinate system, the simulated pen shape is transformed according to the rotation angle and the scaling factor to obtain the boundary point coordinates of the transformed simulated pen shape. The transformed simulated pen shape is placed and drawn based on the coordinates of the boundary points; The transformed simulated pen shape is filled with polygons to obtain a closed shape, which constitutes the corresponding handwriting.

[0103] In one possible implementation, the distribution information includes quantity information and location information, and the determining unit 1802 is used for: If the touch object stops touching the touch screen, the number of touch points in the touch point set is determined to be less than the number threshold based on the quantity information, and the stroke type is determined to be a dot. If the number of touch points in the touch point set reaches the number threshold based on the quantity information, the angle of the line connecting the touch points in the touch point set is determined based on the position information; The stroke type is determined based on the angle of the line connecting the touch points.

[0104] In one possible implementation, the acquisition unit 1801 is used for: Determine whether the collected touch points are jitter points; Add touch points that are not the jitter points to the touch point set.

[0105] As can be seen from the above technical solution, when a user wants to generate handwriting through handwriting input, the user can touch the touch screen with a touch object and move it according to the strokes of the text to be written. When the touch object touches the touch screen and begins to move, a set of touch points can be obtained. The stroke type is determined based on the distribution information of the touch points in the touch point set. Different stroke types have different writing methods according to the calligraphy rules of the corresponding font, and thus their display effects are different. Especially in calligraphy, different stroke types have specific brush tip characteristics. Therefore, based on the stroke type and the calligraphy rules of the target font, trajectory points representing the brush tip position can be obtained. Then, based on the trajectory points representing the brush tip position and the set of touch points, a first set of trajectory points is determined so that the simulated pen shape can be placed and drawn on the trajectory points in the first set of trajectory points to generate the corresponding handwriting, which is then displayed on the touch screen. Since the first set of trajectory points includes trajectory points representing the position of the brushstrokes and is generated according to the calligraphy rules of the target font, when the simulated brush shape is placed and drawn on the trajectory points in the first set, the generated handwriting possesses brushstroke characteristics that conform to calligraphy rules, resulting in a handwriting effect that is closer to real calligraphy. This solution analyzes the calligraphy rules of the target font and introduces prior knowledge into the handwriting drawing and beautification process, producing realistic brushstrokes and shapes. While remaining faithful to user input, it achieves online handwriting beautification with an effect that is closer to real calligraphy, thus improving the user experience.

[0106] Based on the above embodiments, this application also provides a computer device, which can be a terminal device, taking a smartphone as an example: Figure 19 This is a block diagram illustrating a portion of the structure of a smartphone related to the terminal provided in the embodiments of this application. (Reference) Figure 19 The smartphone includes components such as: radio frequency (RF) circuitry 1910, memory 1920, input unit 1930, display unit 1940, sensor 1950, audio circuitry 1960, wireless fidelity (WiFi) module 1970, processor 1980, and power supply 1990. Input unit 1930 may include touch panel 1931 and other input devices 1932, display unit 1940 may include display panel 1941, and audio circuitry 1960 may include speaker 1961 and microphone 1962. Those skilled in the art will understand that... Figure 19 The smartphone structure shown does not constitute a limitation on smartphones and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0107] The memory 1920 can be used to store software programs and modules. The processor 1980 executes various functions and data processing of the smartphone by running the software programs and modules stored in the memory 1920. The memory 1920 may mainly include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback function, image playback function, etc.), etc.; the data storage area may store data created according to the use of the smartphone (such as audio data, phonebook, etc.). In addition, the memory 1920 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0108] The processor 1980 is the control center of the smartphone, connecting various parts of the smartphone via various interfaces and lines. It performs various functions and processes data by running or executing software programs and / or modules stored in the memory 1920, and by calling data stored in the memory 1920. Optionally, the processor 1980 may include one or more processing units; preferably, the processor 1980 may integrate an application processor and a modem processor, wherein the application processor mainly handles the operating system, user interface, and applications, and the modem processor mainly handles wireless communication. It is understood that the modem processor may also not be integrated into the processor 1980.

[0109] In this embodiment, the processor 1980 in the smartphone can perform the following steps: When a touch object touches the touch screen and begins to move, obtain the set of touch points; The stroke type is determined based on the distribution information of the touch points in the set of touch points; Based on the stroke type and the calligraphy rules of the target font, the trajectory points representing the position of the stroke are obtained; The first set of trajectory points is determined based on the trajectory points representing the position of the pen tip and the set of touch points; The simulated pen shape is placed and drawn on the trajectory points in the first trajectory point set to generate the corresponding handwriting, and the handwriting is displayed on the touch screen.

[0110] The computer device provided in this application embodiment can also be a server. Please refer to [link / reference]. Figure 20 As shown, Figure 20The diagram illustrates the structure of a server 2000 provided in this embodiment. The server 2000 can vary significantly due to different configurations or performance characteristics. It may include one or more central processing units (CPUs) 2022 (e.g., one or more processors) and memory 2032, and one or more storage media 2030 (e.g., one or more mass storage devices) for storing application programs 2042 or data 2044. The memory 2032 and storage media 2030 may be temporary or persistent storage. The program stored in the storage media 2030 may include one or more modules (not shown in the diagram), each module including a series of instruction operations on the server. Furthermore, the CPU 2022 may be configured to communicate with the storage media 2030 and execute the series of instruction operations stored in the storage media 2030 on the server 2000.

[0111] Server 2000 may also include one or more power supplies 2026, one or more wired or wireless network interfaces 2050, one or more input / output interfaces 2058, and / or one or more operating systems 2041, such as Windows Server. TM Mac OS X TM Unix TM Linux TM FreeBSD TM etc.

[0112] In this embodiment, the steps performed by the server can be based on Figure 20 The server structure shown is implemented.

[0113] According to one aspect of this application, a computer-readable storage medium is provided for storing program code for performing the handwriting generation method described in the foregoing embodiments.

[0114] According to one aspect of this application, a computer program product or computer program is provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads the computer instructions from the computer-readable storage medium and executes the computer instructions, causing the computer device to perform the methods provided in various optional implementations of the above embodiments.

[0115] The descriptions of the processes or structures corresponding to the above-mentioned figures each have their own emphasis. For parts of a process or structure that are not described in detail, please refer to the relevant descriptions of other processes or structures.

[0116] The terms “first,” “second,” “third,” “fourth,” etc. (if present) in the specification and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented, for example, in orders other than those illustrated or described herein. Furthermore, the terms “comprising” and “having,” and any variations thereof, are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.

[0117] In the several embodiments provided in this application, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection between apparatuses or units through some interfaces, and may be electrical, mechanical, or other forms.

[0118] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0119] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0120] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0121] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application.

Claims

1. A handwriting generation method, characterized in that, The method includes: When a touch object touches the touch screen and begins to move, obtain the set of touch points; The stroke type is determined based on the distribution information of the touch points in the set of touch points; The stroke length and target angle are determined according to the stroke type and the calligraphy rules of the target font; Based on the pen stroke length, the target angle, and the position information of adjacent touch points, a trajectory point representing the pen stroke position is calculated; the adjacent touch point is the touch point in the touch point set that is adjacent to the trajectory point representing the pen stroke position; wherein, if the adjacent touch point is the first touch point in the touch point set, the target angle is the angle between the line connecting the first touch point and the trajectory point representing the pen stroke position, and the line connecting the first touch point and the second touch point in the touch point set; if the adjacent touch point is the last touch point in the touch point set, the target angle is the angle between the line connecting the last touch point and the trajectory point representing the pen stroke position, and the line connecting the last touch point and the second-to-last touch point in the touch point set; The first set of trajectory points is determined based on the trajectory points representing the position of the pen tip and the set of touch points; The simulated pen shape is placed and drawn on the trajectory points in the first trajectory point set to generate the corresponding handwriting, and the handwriting is displayed on the touch screen.

2. The method according to claim 1, characterized in that, When the touch object stops touching the touch screen, the trajectory point representing the pen stroke position includes the starting trajectory point and the ending trajectory point; when the touch object continues to touch the touch screen, the trajectory point representing the pen stroke position includes the starting trajectory point.

3. The method according to claim 1, characterized in that, Determining the first set of trajectory points based on the trajectory points representing the pen tip position and the set of touch points includes: The trajectory points representing the pen tip positions are added to the touch point set to obtain a second trajectory point set; Interpolate the trajectory points in the second trajectory point set to obtain the first trajectory point set, which includes the trajectory points in the second trajectory point set and the interpolated points.

4. The method according to any one of claims 1-3, characterized in that, The step of placing and drawing the simulated pen shape on the trajectory points in the first trajectory point set to generate the corresponding handwriting includes: Determine the rotation angle and scaling factor of the simulated pen shape for each trajectory point in the first trajectory point set; The simulated pen shape is placed and drawn on the corresponding trajectory point according to the rotation angle and the scaling factor to generate the corresponding handwriting.

5. The method according to claim 4, characterized in that, Taking each trajectory point in the first set of trajectory points as a target trajectory point, the rotation angle of the simulated pen shape corresponding to the target trajectory point is determined, including: Determine the angle of the line connecting the target trajectory point and the next trajectory point of the target trajectory point; The angle of the connecting line is taken as the rotation angle of the simulated pen shape at the target trajectory point.

6. The method according to claim 4, characterized in that, Determining the scaling factor corresponding to each trajectory point in the first trajectory point set for the simulated pen shape includes: Determine the type of trajectory point to which the trajectory points in the first set of trajectory points belong; The scaling factor of the corresponding trajectory point is determined based on the trajectory point type.

7. The method according to claim 6, characterized in that, The step of determining the scaling factor of the corresponding trajectory point according to the trajectory point type includes: If the trajectory point type of the first trajectory point in the first trajectory point set is any of the other touch points in the touch point set besides the first touch point, the scaling factor of the simulated pen shape at the first trajectory point is determined according to the moving speed corresponding to the first trajectory point. If the trajectory point type of the second trajectory point in the first trajectory point set is the starting trajectory point representing the position of the pen tip, or the ending trajectory point representing the position of the pen tip, or the first touch point in the touch point set, the scaling factor corresponding to the second trajectory point is determined according to the calligraphy rules of the target font. If the first set of trajectory points is obtained by interpolating the trajectory points in the second set of trajectory points, and the trajectory point type of the third trajectory point in the first set of trajectory points is an interpolation point between the two trajectory points, then the scaling factor of the two trajectory points is linearly changed according to the positional relationship between the third trajectory point and the two trajectory points to obtain the scaling factor of the simulated pen shape corresponding to the third trajectory point.

8. The method according to claim 4, characterized in that, The step of placing and drawing the simulated pen shape on the corresponding trajectory point according to the rotation angle and the scaling factor to generate the corresponding handwriting includes: Using the trajectory points in the first set of trajectory points as the origin of the coordinate system, the simulated pen shape is transformed according to the rotation angle and the scaling factor to obtain the boundary point coordinates of the transformed simulated pen shape. The transformed simulated pen shape is placed and drawn based on the coordinates of the boundary points; The transformed simulated pen shape is filled with polygons to obtain a closed shape, which constitutes the corresponding handwriting.

9. The method according to any one of claims 1-3, characterized in that, The distribution information includes quantity information and location information. Determining the stroke type based on the distribution information of the touch points in the touch point set includes: If the touch object stops touching the touch screen, the number of touch points in the touch point set is determined to be less than the number threshold based on the quantity information, and the stroke type is determined to be a dot. If the number of touch points in the touch point set reaches the number threshold based on the quantity information, the angle of the line connecting the touch points in the touch point set is determined based on the position information; The stroke type is determined based on the angle of the line connecting the touch points.

10. The method according to any one of claims 1-3, characterized in that, The acquisition of the touch point set includes: Determine whether the collected touch points are jitter points; Add touch points that are not the jitter points to the touch point set.

11. A handwriting generation device, characterized in that, The device includes an acquisition unit, a determination unit, a generation unit, and a display unit: The acquisition unit is used to acquire a set of touch points when a touch object touches the touch screen and begins to move; The determining unit is used to determine the stroke type based on the distribution information of the touch points in the touch point set; The determining unit is further configured to determine the stroke length and target angle according to the stroke type and the calligraphy rules of the target font; calculate the trajectory point representing the stroke position according to the stroke length, the target angle, and the position information of adjacent touch points; the adjacent touch point is the touch point in the touch point set that is adjacent to the trajectory point representing the stroke position; wherein, if the adjacent touch point is the first touch point in the touch point set, the target angle is the angle between the line connecting the first touch point and the trajectory point representing the stroke position, and the line connecting the first touch point and the second touch point in the touch point set; if the adjacent touch point is the last touch point in the touch point set, the target angle is the angle between the line connecting the last touch point and the trajectory point representing the stroke position, and the line connecting the last touch point and the second-to-last touch point in the touch point set; The determining unit is further configured to determine a first set of trajectory points based on the trajectory points representing the pen tip position and the set of touch points; The generation unit is used to place and draw the simulated pen shape on the trajectory points in the first trajectory point set to generate the corresponding handwriting. The display unit is used to display the handwriting on the touch screen.

12. The apparatus according to claim 11, characterized in that, When the touch object stops touching the touch screen, the trajectory point representing the pen stroke position includes the starting trajectory point and the ending trajectory point; when the touch object continues to touch the touch screen, the trajectory point representing the pen stroke position includes the starting trajectory point.

13. The apparatus according to claim 11, characterized in that, The determining unit is specifically used for: The trajectory points representing the pen tip positions are added to the touch point set to obtain a second trajectory point set; Interpolate the trajectory points in the second trajectory point set to obtain the first trajectory point set, which includes the trajectory points in the second trajectory point set and the interpolated points.

14. The apparatus according to any one of claims 11-13, characterized in that, The generation unit is specifically used for: Determine the rotation angle and scaling factor of the simulated pen shape for each trajectory point in the first trajectory point set; The simulated pen shape is placed and drawn on the corresponding trajectory point according to the rotation angle and the scaling factor to generate the corresponding handwriting.

15. A computer device, characterized in that, The computer device includes a processor and memory: The memory is used to store program code and transmit the program code to the processor; The processor is configured to execute the method according to any one of claims 1-10 according to the instructions in the program code.

16. A computer-readable storage medium, characterized in that, The computer-readable storage medium is used to store program code for performing the method according to any one of claims 1-10.

17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-10.

Citation Information

Patent Citations

  • Method for beautifying handwritten Chinese character based on trajectory analysis

    CN101699518A

  • Handwriting processing method, equipment and medium

    CN111381754A

  • Input processing method, input processing device, electronic device and storage medium

    CN112346633A

  • Writing stroke implementation method and device, electronic equipment and readable storage medium

    CN112905102A