Method and device for drawing handwriting, electronic equipment, medium and product
By simulating the calculation of pressure sensing values and graphic size, the handwriting segments are drawn based on the contour point set, which solves the problem of jagging and delay in writing handwriting caused by high pixel density of infrared screens, and achieves a smoother writing experience.
Patent Information
- Application Number
- CN202411943566.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-26
- Publication Date
- 2025-04-25
AI Technical Summary
The high pixel density of infrared screens leads to jagged writing and has a large writing delay at high resolution.
By determining the simulated pressure sensing value of the current touch point, calculating the current graph size, and drawing handwriting segments based on the curve generated by the overall contour point set, reducing sawtooth and CPU/GPU performance consumption.
Maximally reduce jagging, reduce delay, and improve writing experience.
Smart Images

Figure CN119883093A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of touch screens, and in particular to a method, device, electronic equipment, medium and product for drawing handwriting. Background Art
[0002] With the popularity of touch screens, handwriting input has been widely used. When writing on electronic whiteboards or other writing software, if the pen tip function can be realized, the user's writing experience can be improved. The pen tip function refers to simulating the thickness changes of traditional brushes, pens or other writing tools to produce the pen tip effect of writing or painting.
[0003] In the related technology, for infrared touch screens (referred to as infrared screens), the pen tip function is realized by the density of touch point set data. Specifically, the writing software determines the fill pattern according to the user's selection. After acquiring the touch data of the touch screen, a coefficient is added according to the distance between two adjacent touch points to determine the width of the fill pattern between two adjacent touch points and the spacing between the fill patterns between two adjacent touch points. Then, the fill and draw are performed in the vector direction of the original touch point set, thereby realizing the pen tip function.
[0004] However, in the above method, if the pixel density of the infrared screen is high, filling and drawing multiple pictures will cause the handwriting to have large jagged edges. Moreover, the higher the resolution of the infrared screen, the more pictures need to be filled, resulting in greater writing delays. Summary of the invention
[0005] In view of this, the present invention provides a method, device, electronic device, medium and product for drawing handwriting, so as to improve the problems of jagged handwriting and large writing delay.
[0006] In a first aspect, the present invention provides a method for drawing handwriting, the method comprising: determining an analog pressure value of a current touch point; determining a current graphic size according to the analog pressure value of the current touch point, wherein the current graphic size is the graphic size of a drawing area corresponding to the current touch point; determining an overall contour point set of a previous touch point and a current touch point according to the current graphic size, current touch coordinates, a previous graphic size and a previous touch coordinates, wherein the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, and the previous touch coordinates are the coordinates of the previous touch point; and drawing a handwriting line segment from the previous touch point to the current touch point based on a curve generated based on the overall contour point set.
[0007] The method for drawing handwriting provided in this embodiment determines the current graphic size according to the simulated pressure value of the current touch point after determining the simulated pressure value of the current touch point, and then determines the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates, and finally draws the handwriting line segment from the previous touch point to the current touch point based on the curve generated by the overall contour point set. In this embodiment, by drawing the contour boundary points of the shape, calculating the contour boundary point set of the drawing path, and drawing the handwriting line segment with the point set, compared with the method of filling and drawing with multiple pictures, it can greatly reduce jaggedness, reduce CPU / GPU performance consumption, and reduce latency during drawing.
[0008] In an optional embodiment, determining the analog pressure value of the current touch point includes: determining the analog pressure value of the current touch point based on a first distance and a first corresponding relationship, wherein the first distance is the distance between the current touch point and the previous touch point, and the first corresponding relationship represents the correspondence between the distance between the two touch points and the pressure coefficient.
[0009] In this embodiment, by identifying the distance between the current touch point and the previous touch point, the simulated pressure value is dynamically adjusted, and then the pen tip is simulated based on the relationship between the simulated pressure value and the change in pen gestures, so that non-capacitive screens, electromagnetic screens and other pressure-free touch screens can also simulate similar pressure-sensitive writing effects.
[0010] In an optional implementation, the first corresponding relationship represents that the pressure sensitivity coefficient and the distance between the two touch points are in an exponential relationship.
[0011] In this embodiment, the first corresponding relationship is defined as an exponential function, so that when writing is slow (that is, the distance between the two touch points is short), there can also be an obvious drop in the simulated pressure value, reflecting the change in handwriting thickness.
[0012] In an optional embodiment, based on the first spacing and the first corresponding relationship, the analog pressure value of the current touch point is determined, including: based on the first spacing, the minimum preset spacing and the maximum preset spacing, the effective spacing is determined, wherein when the first spacing is greater than or equal to the maximum preset spacing, the effective spacing is the maximum preset spacing, when the first spacing is less than or equal to the minimum preset spacing, the effective spacing is the minimum preset spacing, and when the first spacing is greater than the minimum preset spacing and the first spacing is less than the maximum preset spacing, the effective spacing is the first spacing; based on the ratio of the effective spacing to the difference between the maximum preset spacing and the minimum preset spacing, the pressure increase coefficient and the first corresponding relationship, the analog pressure value of the current touch point is determined.
[0013] In an optional implementation, the first corresponding relationship is a corresponding relationship between a plurality of preset intervals between two touch points and a plurality of preset pressure sensitivity coefficients.
[0014] In an optional embodiment, the method also includes: obtaining a pressure sensitivity value data set, wherein the pressure sensitivity value data set includes n preset pressure sensitivity values, and n is an integer greater than 1; determining the analog pressure sensitivity value of the current touch point, including: determining the first preset pressure sensitivity value among the n preset pressure sensitivity values as the analog pressure sensitivity value of the current touch point, wherein, when 1<N≤n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the first touch point are updated to the second preset pressure sensitivity value to the Nth preset pressure sensitivity value in sequence; when n<N<2n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the N-n+1th touch point are updated to the second preset pressure sensitivity value to the nth preset pressure sensitivity value in sequence; when N=2n, N is updated to Nn, N represents the order of the current touch point, and N is an integer greater than or equal to 1.
[0015] The method for drawing handwriting provided in this embodiment, after obtaining the pressure sensitivity value data set, changes the simulated pressure sensitivity coefficient of each touch point in real time according to the pressure sensitivity value data set during the writing process, and then realizes the simulation of the pen tip according to the relationship between the simulated pressure sensitivity value and the pen gesture change. It can not only make non-capacitive screens, electromagnetic screens and other non-pressure-sensitive touch screens simulate similar pressure-sensitive writing effects, but also realize the writing function of running script.
[0016] In a second aspect, the present invention provides a device for drawing handwriting, the device comprising: a first determination module, used to determine the simulated pressure value of the current touch point; a second determination module, used to determine the current graphic size according to the simulated pressure value of the current touch point, wherein the current graphic size is the graphic size of the drawing area corresponding to the current touch point; a third determination module, used to determine the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates, wherein the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, and the previous touch coordinates are the coordinates of the previous touch point; a drawing module, used to draw a handwriting line segment from the previous touch point to the current touch point based on a curve generated based on the overall contour point set.
[0017] In a third aspect, the present invention provides an electronic device comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the method of the first aspect or any corresponding embodiment thereof by executing the computer instructions.
[0018] In a fourth aspect, the present invention provides a computer-readable storage medium having computer instructions stored thereon, the computer instructions being used to cause a computer to execute the method of the first aspect or any corresponding embodiment thereof.
[0019] In a fifth aspect, the present invention provides a computer program product, comprising computer instructions for causing a computer to execute the method of the first aspect or any corresponding embodiment thereof. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] In order to more clearly illustrate the specific embodiments of the present invention or the technical solutions in the related technologies, the drawings required for use in the specific embodiments or the related technical descriptions will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0021] Figure 1 is a schematic diagram of a driver stack of a Windows touch screen according to an embodiment of the present invention;
[0022] Figure 2 is a schematic diagram of a Windows electronic whiteboard touch message link according to an embodiment of the present invention;
[0023] Figure 3 is a schematic diagram of a filling pattern between two touch points according to an embodiment of the present invention;
[0024] Figure 4 is based on Figure 3 Schematic diagram of touch movement trajectory obtained by filling method;
[0025] Figure 5 is a flow chart of a method for drawing handwriting according to an embodiment of the present invention;
[0026] Figure 6 is a schematic diagram of drawing a shape according to an embodiment of the present invention;
[0027] Figure 7 is a schematic diagram of shapes drawn at corresponding positions of touch point A and touch point B according to an embodiment of the present invention;
[0028] Figure 8 is a schematic diagram of a minimum contour point set according to an embodiment of the present invention;
[0029] Fig. 9 is a schematic diagram of the highest point and the lowest point of the current graph and the previous graph according to an embodiment of the present invention;
[0030] Fig.10 is Fig. 9 A schematic diagram of a trapezoidal area formed on the basis of;
[0031] Fig.11 is a schematic diagram of a first type of handwriting line segment according to an embodiment of the present invention;
[0032] Fig.12 is a flow chart of another method for drawing handwriting according to an embodiment of the present invention;
[0033] Fig.13 is a schematic diagram of multiple touch point trajectories according to an embodiment of the present invention;
[0034] Fig.14 is a schematic diagram of a first corresponding relationship according to an embodiment of the present invention;
[0035] Fig.15 is a schematic diagram of a first writing effect according to an embodiment of the present invention;
[0036] Fig.16 is a schematic diagram of a second writing effect according to an embodiment of the present invention;
[0037] Fig.17 is a schematic diagram of a third writing effect according to an embodiment of the present invention;
[0038] Fig.18 is a flowchart of another method for drawing handwriting according to an embodiment of the present invention;
[0039] Fig.19 is a schematic diagram of a second handwriting line segment according to an embodiment of the present invention;
[0040] Fig. 20 is a schematic diagram of a fourth writing effect according to an embodiment of the present invention;
[0041] Fig.21 is a structural block diagram of a device for drawing handwriting according to an embodiment of the present invention;
[0042] Fig. 22 It is a schematic diagram of the hardware structure of the electronic device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0043] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. According to the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative work are within the scope of protection of the present invention.
[0044] A touch screen is an inductive liquid crystal display device that can receive touch input signals. As an input medium, it is currently a relatively simple and convenient way of human-computer interaction and is widely used in various electronic devices, such as mobile phones, tablets or computers.
[0045] In Windows operating system, the touch screen is a human interface device (HID), which can be connected to the HID based on Universal Serial Bus (USB), I based 2 C or Serial Peripheral Interface (SPI)-based HID to a Windows host.
[0046] Figure 1 The Windows touch screen driver stack is shown as Figure 1 As shown, at the bottom layer, the USB bus driver (USB Bus Driver), I 2 C controller driver (I 2 Bus drivers such as C Controller Driver, General-Purpose Input / Output (GPIO) Controller Driver or SPI Controller Driver receive touch data from touch screen hardware, and after a series of kernel-driven data conversions, the data is finally expressed as system events such as touch press, lift and move at the user level.
[0047] in, Figure 1 The HID class (HIDClass) in is a device driver used to handle devices that interact with users (such as touch screens). HIDUSB represents HID connected to the Windows host through the USB interface, and HIDI2C represents HID connected to the Windows host through I 2 C bus to the Windows host, HIDSPI represents the HID connected to the Windows host via SPI, and the third-party touchscreen HID mini-port driver (3rd Party Touchscreen HID Mini-Port Driver) is usually provided by the device manufacturer to support the connection of a specific touchscreen device to the Windows host. SPBCx represents a specific driver for processing the input and output of the touchscreen device.
[0048] There are many types of touch screens. According to the working principle and the medium for transmitting information, the touch screen can include a capacitive touch screen (capacitive screen for short) and an infrared screen.
[0049] The capacitive screen can be composed of a four-layer composite glass layer. The inner surface layer and the interlayer of each glass layer are provided with indium tin oxide (ITO) conductive material, which uses the induced voltage to form a current to change the regional capacitance, so that the integrated circuits (IC) at the four corners can determine the coordinate position of the sensing area.
[0050] Specifically, the capacitive screen uses the current induction of the human body to work. When a finger touches or approaches the capacitive screen, a coupling capacitor is formed between the user and the surface of the capacitive screen due to the electric field of the human body. For high-frequency current, the capacitor is a direct conductor, so the finger absorbs a very small current from the contact point. This current flows out from the electrodes on the four corners of the capacitive screen, and the current flowing through these four electrodes is proportional to the distance from the finger to the four corners. The controller can obtain the position information (coordinates) of the touch point by accurately calculating the ratios of the four currents.
[0051] With the development of capacitive screens, in order to improve the user's writing experience and effect, capacitive screens are usually equipped with a stylus (i.e., a capacitive pen). When using a capacitive pen on a touch screen, the pressure value of the user during writing can be detected. Specifically, the pressure value can be detected by setting a capacitor in the capacitive pen. The capacitor is located at the rear end of the pen tip. When pressure is applied, the pen tip moves into the pen body, causing the distance between the positive and negative poles of the capacitor to change, thereby changing the capacitance and realizing the sensing of pressure.
[0052] The infrared screen uses a dense infrared matrix in the X and Y directions to detect and locate the position of the touch point. The infrared screen includes a circuit board frame installed on the edge of the display. The circuit board arranges infrared transmitting tubes and infrared receiving tubes on the four sides of the display. The infrared transmitting tubes and the infrared receiving tubes correspond to each other one by one to form a horizontal and vertical cross infrared matrix. The infrared screen does not support the detection of pressure sensitivity values.
[0053] Specifically, when the infrared screen is performing touch detection, the infrared transmitting tube can periodically emit infrared rays, which can form an invisible infrared light grid on the screen surface. The infrared receiving tube can continuously detect whether the infrared rays are received. When the user's finger or touch pen touches the infrared screen, part of the infrared rays will be blocked, causing the signal detected by the corresponding receiving tube to change. The controller can determine the coordinates of the touch point based on the signal change detected by the receiving tube.
[0054] An electronic whiteboard is an application for writing on a touch screen. After receiving touch data such as touch press, lift and move, the touch movement track can be drawn on the touch screen. The Windows electronic whiteboard touch message link can be as follows: Figure 2As shown, writing applications such as electronic whiteboards can interact with core system files and drivers of the Windows operating system through the Windows Presentation Foundation (WPF) framework to ensure that user touch operations can be responded to and processed accurately and promptly.
[0055] in, Figure 2 The USB Common Class Generic Parent Driver (USBCCGP) in the Windows operating system is a universal USB class driver used to handle the common functions of USB devices. The USB hub (USBHUB) is used to expand the number of USB interfaces and connect multiple USB devices. HIDUSB.SYS represents the driver used to handle HID devices connected through the USB interface, and is a bridge between the HID device and the USB bus. HIDCLASS.SYS represents the system driver used to handle HID devices in the Windows operating system. Win32K.sys represents a core system file in the Windows operating system, which belongs to the kernel mode driver and is used to handle Windows graphics, window management, user input and other functions. The WPF framework represents the technical framework used to build Windows client applications, which can provide rich user interface (UI) functions and graphics rendering capabilities.
[0056] User mode is the environment in which applications run, while kernel mode is the environment in which the operating system core and drivers run. Data and control flow from user mode applications down through various drivers into kernel mode and finally to the USB device.
[0057] When writing in the writing area displayed on the electronic whiteboard, realizing the pen stroke function involves dual support of hardware and software. The capacitive screen can realize the pen stroke function through the pressure coefficient collected by the high-precision touch sensor and the pressure-sensitive pen, while the infrared screen cannot detect the pressure value, and it is difficult to realize the pen stroke function through the pressure value. The electronic whiteboard software level can simulate a similar pen stroke effect through the density of the touch point set data.
[0058] In some embodiments, the writing software determines the fill pattern (e.g. Figure 3 After acquiring the touch data of the touch screen, a coefficient is added according to the distance between two adjacent touch points to determine the width of the fill pattern of the two adjacent touch points and the spacing between the fill patterns between the two adjacent touch points. For example, Figure 3The radius of the filling figure of the two touch points is r1 and r2, the spacing of the filling points is d, and then the filling and drawing are performed in the vector direction of the original touch point set, thereby realizing the pen stroke function. On a display screen with a smaller size, the touch movement trajectory obtained based on this method can be as follows Figure 4 shown.
[0059] However, on large-size touch screens, the pixel density of the infrared screen is relatively high. When filling and drawing multiple images, it is difficult to achieve high-density filling due to performance reasons, resulting in large jagged edges in the moving trajectory drawn in the above manner. Moreover, the higher the resolution of the infrared screen, the more images need to be filled, and more central processing units (CPUs) are required to complete 2D drawing, resulting in large writing delays. The delay is more obvious in 8K screen scenes with 8K resolution.
[0060] In view of this, the present invention provides a method for drawing handwriting, which draws the outline boundary points of the shape, calculates the outline boundary point set of the drawing path, and draws the handwriting line segments with the point set. Compared with the method of filling and drawing with multiple pictures, the method can greatly reduce jagged edges, reduce CPU / graphics processing unit (GPU) performance consumption, and reduce latency during drawing.
[0061] The method for drawing handwriting provided by the present invention is applied to a touch screen without pressure sensitivity, such as the above-mentioned infrared screen.
[0062] According to an embodiment of the present invention, a method embodiment for drawing handwriting is provided. It should be noted that the steps shown in the flowchart of the accompanying drawings can be executed in an electronic device, and although a logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in an order different from that shown here.
[0063] In this embodiment, a method for drawing handwriting is provided, which can be used in electronic devices such as mobile phones, tablet computers, etc. Figure 5 FIG. 1 is a flow chart of a method for drawing handwriting according to an embodiment of the present invention. Figure 5 As shown, the method comprises the following steps:
[0064] Step S501, determining the simulated pressure value of the current touch point.
[0065] Specifically, the analog pressure value refers to the simulated pressure applied to the touch point when the user writes on a non-pressure-sensitive touch screen, which is similar to the pressure value obtained by the above-mentioned capacitive screen detection. The analog pressure value can be between 0 and 1, and includes 0 and 1. The analog pressure value is a floating point value. The smaller the number, the smaller the pressure, and the larger the number, the greater the pressure.
[0066] The present invention does not limit the method of determining the analog pressure value of the current touch point. For example, the analog pressure value may be determined based on the distance between the current touch point and the previous touch point, or the analog pressure value may be adaptively adjusted according to the touch screen reporting rate, etc. Exemplarily, the specific process of determining the analog pressure value of the current touch point is described in detail below and will not be described here.
[0067] The reporting rate of the touch screen refers to the number of times the touch IC reports the touch coordinates per unit time. The reporting rate is also called the single reporting interval. The reporting rate of the infrared screen is related to the interval between the internal lamp posts (infrared transmitting tube and infrared receiving tube). The fewer the lamp posts, the less time it takes to cycle through all the lamp posts, and the less time it takes to complete a single detection. However, the corresponding touch position accuracy will decrease, increasing the probability of touch jitter. The higher the touch reporting rate, the smaller the writing delay. The common touch point reporting interval is between 4ms and 8ms.
[0068] Step S502, determining the current graphic size according to the simulated pressure value of the current touch point.
[0069] The current graphic size is the graphic size of the drawing area corresponding to the current touch point.
[0070] Specifically, after determining the simulated pressure value of the current touch point, the default graphic size can be adjusted based on the simulated pressure value of the current touch point to obtain the current graphic size. The default graphic size can be the graphic size of the writing and drawing area determined based on the user's selection.
[0071] Exemplarily, the default graphic and the default graphic size may be obtained from the drawing attributes (DrawingAttributes), and the DrawingAttributes may be set by the user in writing software such as an electronic whiteboard.
[0072] DrawingAttributes is a collection of various drawing-related attributes, which is used to define the appearance of the handwriting during the entire drawing process. The appearance features include but are not limited to the shape of the drawing area, the color of the line, the thickness of the line, the transparency, and the style of the line (such as solid line, dotted line, etc.). The stylus tip (StylusTip) in DrawingAttributes is used to define the drawing shape (default shape) of the writing drawing area (StylusShape). The drawing shape can be as follows: Figure 6 As shown, the shapes include but are not limited to circle, rectangle, and ellipse, etc., and can also be customized shapes.
[0073] When the default graphic is a circle, the size of the default graphic may be represented by a radius or a diameter; when the default graphic is a rectangle, the size of the default graphic may be represented by a length and a width; and when the default graphic is an ellipse, the size of the default graphic may be represented by a major axis and a minor axis.
[0074] Specifically, after determining the simulated pressure value of the current touch point and the default graphic size, the product of the default graphic size and the simulated pressure value of the current touch point may be determined as the current graphic size.
[0075] Taking the default graphic as a circle as an example, the current graphic size can be determined by the following formula (1):
[0076]
[0077] In formula (1), R1 represents the current graphic size. When the default graphic is a circle, the current graphic size is the radius of the current graphic. inkSize represents the default graphic size (that is, the thickness of the note line). When the default graphic is a circle, the default graphic size can be the diameter of the default graphic. The pressureFactor field represents the simulated pressure value.
[0078] Step S503, determining the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates.
[0079] Among them, the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, the previous touch coordinates are the coordinates of the previous touch point, and the overall contour point set can be a set of position points that describe the shape contour of the drawing area formed by the two touch points.
[0080] Specifically, the current touch point and the previous touch point are relative. During the touch detection process, the most recently detected touch point is the current touch point, and the most recently detected touch point is the previous touch point. For example, if the most recently detected touch point is the fifth touch point, the fifth touch point is the current touch point, and the fourth touch point is the previous touch point. If a sixth touch point is added, the sixth touch point is the current touch point, and the fifth touch point becomes the previous touch point.
[0081] When the fifth touch point is the current touch point, the graphic size of the drawing area corresponding to the fifth touch point is the current graphic size; when the sixth touch point is the current touch point, the graphic size of the drawing area corresponding to the fifth touch point is the previous graphic size, and the graphic size of the drawing area corresponding to the sixth touch point is the current graphic size.
[0082] Exemplarily, the touch coordinates can be obtained through the application framework. Specifically, the touch screen hardware sensor detects the user's touch input and converts the signal, i.e., the touch event, into digital data, and passes the data to the operating system (such as Windows). The operating system then processes the touch data through its touch input subsystem. The touch hardware driver (Touch Driver) is a hardware-specific driver that communicates with the touch sensor and converts the raw data into an interpretable format (standard touch event message). This touch hardware driver is usually implemented as a HID device driver, complies with the HID protocol and standard, and interacts with HIDClass.sys. The application layer framework encapsulates specific touch device information and provides additional details, such as the ID and location of the touch point.
[0083] Specifically, the above step S503 includes step a1 and step a2:
[0084] Step a1, determining the minimum point set of the outline of the current graphic based on the current graphic size and the current touch coordinates, and determining the minimum point set of the outline of the previous graphic based on the previous graphic size and the previous touch coordinates.
[0085] The minimum contour point set is a minimum set of position points of the graphic contour that describes the drawing area of the touch point.
[0086] Exemplarily, when the drawing graphics (the current graphics and the previous graphics) are circular or elliptical, the drawing graphics can be described by position points in eight directions to obtain the minimum point set of the outline; when the drawing graphics are rectangular, the drawing graphics can be described by four points of the top, bottom, left and right to obtain the minimum point set of the outline; when the drawing graphics are custom shapes (custom shapes), the drawing graphics can be described by the path point set corresponding to the PathGeometry to obtain the minimum point set of the outline.
[0087] PathGeometry is a data structure used to describe the geometric path of complex shapes in graphics drawing. It is an advanced graphics representation that allows custom shapes to be created by defining a series of path segments (such as straight lines, arcs, Bezier curves, etc.).
[0088] The following takes the example of drawing a circle, the touch coordinates of the previous touch point (touch point A) are (100d, 100d), the simulated pressure value of the previous touch point is 0.8, the touch coordinates of the current touch point (touch point B) are (500d, 100d), and the simulated pressure value of the current touch point B is 0.4 to illustrate the minimum point set of the contour of the current figure and the minimum point set of the contour of the previous figure.
[0089] After determining the current graphic size, current touch coordinates, previous graphic size, and previous touch coordinates, the shapes drawn at the corresponding positions of touch point A and touch point B can be as follows: Figure 7 As shown, after that, Figure 8 As shown, points are taken in 8 directions of touch point A to describe the drawing corresponding to touch point A, and points are taken in 8 directions of touch point B to describe the drawing corresponding to touch point B. At this time, the minimum contour point set of the previous figure shapeOutLinePointsA = [A1, A2, A3, ..., A8], and the minimum contour point set of the current figure shapeOutLinePointsB = [B1, B2, B3, ..., B8].
[0090] Specifically, the coordinates of the eight position points (A1 to A8) of the drawn graphic (i.e., the previous graphic) corresponding to the touch point A can be determined based on the touch coordinates of the touch point A, the size of the previous graphic, and the angles of each position point. The calculation method can be as shown in formula (2):
[0091]
[0092] In formula (2), x_Ai and y_Ai represent the coordinates of the i-th position point, i=1, 2, ..., 8; x_A and y_A represent the touch coordinates of touch point A (i.e., the previous touch coordinates), inkSizeA represents the diameter of the circle corresponding to touch point A (i.e., the previous graphic size), and angle_Ai represents the angle between the i-th position point and the x-axis.
[0093] The coordinates of the eight position points (B1 to B8) of the drawn graphic (i.e., the current graphic) corresponding to the touch point B can be determined based on the touch coordinates of the touch point B, the current graphic size, and the angles of each position point. The calculation method is similar to the above formula (2).
[0094] Step a2: determining the overall contour point set of the previous touch point and the current touch point based on the minimum contour point set of the current graphic and the minimum contour point set of the previous graphic.
[0095] Exemplarily, after determining the minimum outline point set of the current figure and the minimum outline point set of the previous figure, obtain the union of the minimum outline point set of the current figure and the minimum outline point set of the previous figure, unionPoints1=(shapeOutLinePointsA).Union(shapeOutLinePointsB); then, as Fig. 9 As shown, determine the highest point (A_top) and lowest point (A_bottom) of the previous figure, and determine the highest point (B_top) and lowest point (B_bottom) of the current figure; then, as Fig.10As shown, A_top, A_bottom, B_top and B_bottom are combined into a trapezoidal region, the position points in the trapezoidal region in unionPoints1 are removed, and the position points in the updated unionPoints1 are arranged clockwise with A_top as the starting point to obtain the overall contour point set outLinePoints. Fig.10 For example, outLinePoints = [A_top, B_top, B1, B2, B3, B4, B_bottom, A_bottom, A5, A6, A7, A8].
[0096] It should be noted that due to the different angles of the vector vector from touch point A to touch point B, the drawn graphics corresponding to touch point A and the drawn graphics corresponding to touch point B may obtain half of the point set in other ranges. For example, when the vector is 45 degrees, the partial point set corresponding to touch point B is B3, B4, B5 and B6.
[0097] Specifically, A_top and A_bottom can be determined by the touch coordinates of the touch point A (ie, the previous touch coordinates) and the vector angle, and the calculation formulas can be shown as formula (3) and formula (4):
[0098]
[0099]
[0100] Among them, x_A_top and y_A_top represent the coordinates of A_top, angle represents the angle of the vector vector from touch point A to touch point B, and x_A_bottom and y_A_bottom represent the coordinates of A_bottom.
[0101] The angle of the vector vector from touch point A to touch point B is angle = vector.Angle. In the above example where the touch coordinates of touch point A are (100d, 100d) and the touch coordinates of touch point B are (500d, 100d), the vector vector from touch point A to touch point B is vector = BA = (400d, 0d).
[0102] Specifically, B_top and B_bottom may be determined by the touch coordinates of the touch point B (ie, the current touch coordinates) and the vector angle, and the calculation method is similar to the above formula (3) and formula (4).
[0103] Step S504: Draw a handwriting line segment from the last touch point to the current touch point based on the curve generated by the overall contour point set.
[0104] Specifically, after determining the overall contour point set outLinePoints, outLinePoints can be connected into a curve (such as a Bezier curve or other curve) to obtain the complete shape path of the previous touch point (such as touch point A) and the current touch point (such as touch point B), and then fill the corresponding color in the middle to obtain the handwriting line segment from the previous touch point to the current touch point.
[0105] For example, a Bezier curve is a parametric curve widely used in computer graphics, which defines a shape through a set of control points. The most common ones are quadratic Bezier curves and cubic Bezier curves. A quadratic Bezier curve is defined by three control points, a starting point (the last touch point in this application), an end point (the current touch point in this application), and an intermediate control point, while a cubic Bezier curve is defined by four control points, including a starting point, an end point, and two intermediate control points.
[0106] The parameter method of the quadratic Bezier curve can be shown as formula (5):
[0107] B(t)=(1-t) 2 P 0 +2t(1-t)P 1 +t 2 P 2 (5)
[0108] In formula (5), t∈[0,1], P 0 Indicates the starting point, P 1 represents the intermediate control point, P 2 Indicates the end point.
[0109] The parameterization of the cubic Bezier curve can be shown as formula (6):
[0110] B(t)=P 0 (1-t) 3 +3P 1 t(1-t) 2 +3P 2 t 2 (1-t)+P 3 t 3 (6)
[0111] In formula (6), P 2 It does not represent the end point, but the second intermediate control point, P 3 Indicates the end point.
[0112] In this embodiment, the method of forming at least one intermediate control point of the Bezier curve is the same as the conventional method of determining the intermediate control point in the art, which is not explained here.
[0113] The realization of the pen tip is related to the pressure value. Drawing the pen line segment based on the above method can achieve the effect of dynamic change of line width based on the simulated pressure value. In the electronic whiteboard, an ellipse is used as the drawing shape. The pen line segment drawn by the above method can be as follows Fig.11 shown.
[0114] The method for drawing handwriting provided in this embodiment determines the current graphic size according to the simulated pressure value of the current touch point after determining the simulated pressure value of the current touch point, and then determines the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates, and finally draws the handwriting line segment from the previous touch point to the current touch point based on the curve generated by the overall contour point set. In this embodiment, by drawing the contour boundary points of the shape, calculating the contour boundary point set of the drawing path, and drawing the handwriting line segment with the point set, compared with the method of filling and drawing with multiple pictures, it can greatly reduce jaggedness, reduce CPU / GPU performance consumption, and reduce latency during drawing.
[0115] In this embodiment, a method for drawing handwriting is provided, which can be used in electronic devices. Fig.12 FIG. 1 is a flow chart of another method for drawing handwriting according to an embodiment of the present invention. Fig.12 As shown, the method comprises the following steps:
[0116] Step S1201: determining a simulated pressure value of a current touch point based on a first distance and a first corresponding relationship.
[0117] The first distance is the distance between the current touch point and the previous touch point, and the first corresponding relationship represents the corresponding relationship between the distance between the two touch points and the pressure sensitivity coefficient.
[0118] Specifically, when writing calligraphy with a fountain pen or brush on a real paper notebook, there are operations of lifting, hooking, and slashing, which are actually the control of pressing and speed. When writing on a touch screen, the position of the touch point determined by the touch screen has a certain regularity, such as Fig.13 As shown, if the initial writing speed is slow, the touch points will be denser, and the handwriting will also be denser when turning. If the writing speed is fast, the touch points will be spaced farther apart.
[0119] During touch-move operations, the time for touch point reporting is basically fixed, that is, it is triggered once every 7ms-8ms. It should be understood that different touch screen manufacturers and software versions may have different reporting rates. When the touch screen firmware version is determined, the reporting rate is the same. The simulated pressure value can be adjusted by the interval between touch points, and the thickness of the handwriting can be dynamically adjusted. Among them, even if the reporting rate is different, different touch screens can be adapted.
[0120] Specifically, after determining the current touch coordinates and the previous touch coordinates, the vector vector=point1-Point2 from the previous touch point to the current touch point can be determined, and then the first spacing length=vector.Length can be determined based on the vector from the previous touch point to the current touch point. Wherein point1 represents the touch coordinates of the current touch point (i.e., the current touch coordinates), and Point2 represents the touch coordinates of the previous touch point (i.e., the previous touch coordinates).
[0121] After the first distance is determined, the first distance can be brought into the first corresponding relationship as an independent variable (the distance between two touch points), and the dependent variable (pressure sensitivity coefficient) corresponding to the first distance can be determined as a simulated pressure sensitivity value.
[0122] Specifically, when the current touch point is the first touch point and there is no previous touch point, the preset pressure sensitivity value may be determined as a simulated pressure sensitivity value, wherein the preset pressure sensitivity value may be determined by a designer according to a reporting rate.
[0123] In some optional implementations, the first corresponding relationship represents that the pressure sensitivity coefficient and the distance between the two touch points are in an exponential relationship.
[0124] Specifically, Fig.14 As shown, when the minimum preset spacing minLength≤first spacing≤maximum preset spacing maxLength, the pressure sensitivity coefficient and the spacing between the two touch points are exponentially related, that is, as the first spacing increases, the simulated pressure sensitivity value decays exponentially. When the first spacing is less than the minimum preset spacing, the simulated pressure sensitivity value may be a first preset value, such as 1.0, and when the first spacing is greater than the maximum preset spacing, the simulated pressure sensitivity value may be a second preset value, such as 0.1, etc.
[0125] In this embodiment, the first corresponding relationship is defined as an exponential function, so that when writing is slow (that is, the distance between the two touch points is short), there can also be an obvious drop in the simulated pressure value, reflecting the change in handwriting thickness.
[0126] It should be noted that the minLength and maxLength of different touch screens are different. The designer can define the minLength and maxLength according to the touch screen reporting rate.
[0127] Exemplarily, the above step S1201 includes step S12011 to step S12012:
[0128] Step S12011, determining an effective spacing based on the first spacing, the minimum preset spacing, and the maximum preset spacing.
[0129] Among them, when the first spacing is greater than or equal to the maximum preset spacing, the effective spacing is the maximum preset spacing, when the first spacing is less than or equal to the minimum preset spacing, the effective spacing is the minimum preset spacing, and when the first spacing is greater than the minimum preset spacing and the first spacing is less than the maximum preset spacing, the effective spacing is the first spacing.
[0130] That is, the effective spacing newLength = Math.Max(Math.Min((float)length, maxLength), minLength).
[0131] Step S12012: determining the simulated pressure value of the current touch point based on the ratio of the effective distance to the difference between the maximum preset distance and the minimum preset distance, the pressure increase coefficient and the first corresponding relationship.
[0132] The pressure increase coefficient exRatio may be a preset value, which is used to increase the ratio of the effective spacing to the difference between the maximum preset spacing and the minimum preset spacing, and to reduce the problem of the expansion point that varies from one point to another, that is, the shorter the spacing of the touch point, the smaller the change in the simulated pressure value. The pressure increase coefficient may be determined by the designer, for example, the pressure increase coefficient may be 5. The simulated pressure value within the threshold range (minLength and maxLength) may be expanded by multiple powers of the exponential function e.
[0133] Exemplarily, the first corresponding relationship may be ratio=(float)Math.Exp(-Math.Log(exRatio)×lengthRatio), that is, the first corresponding relationship may be as shown in formula (7):
[0134] ratio = e -ln(exRatio)×lengthRatio (7)
[0135] In formula (7), ratio represents the pressure sensitivity coefficient, exRatio represents the pressure sensitivity increase coefficient, and lengthRatio represents the ratio of the effective spacing to the difference between the maximum preset spacing and the minimum preset spacing.
[0136] Specifically, after determining the effective spacing, the ratio of the effective spacing to the difference between the maximum preset spacing and the minimum preset spacing can be determined as lengthRatio=newLength / (maxLength-minLength), and then the lengthRatio is substituted into the above formula (7) to determine the pressure sensitivity coefficient, and the pressure sensitivity coefficient obtained is then determined as the simulated pressure sensitivity value of the current touch point. In this embodiment, the final writing effect can be as follows Fig.15 shown.
[0137] In some other optional implementations, the first corresponding relationship is a corresponding relationship between a plurality of preset intervals between two touch points and a plurality of preset pressure sensitivity coefficients.
[0138] There is a one-to-one correspondence between the plurality of preset intervals between two touch points and the plurality of preset pressure sensitivity coefficients, and the plurality of preset intervals between two touch points and the plurality of preset pressure sensitivity coefficients can be determined by designers based on experience.
[0139] Exemplarily, the first corresponding relationship may include: when the first spacing is less than or equal to 2 pixels, the simulated pressure sensitivity value of the current touch point is 1; when the first spacing is greater than 2 pixels and the first spacing is less than or equal to 3 pixels, the simulated pressure sensitivity value of the current touch point is 1 / 1.1; when the first spacing is greater than 3 pixels and the first spacing is less than or equal to 5 pixels, the simulated pressure sensitivity value of the current touch point is 1 / 1.4; when the first spacing is greater than 5 pixels and the first spacing is less than or equal to 8 pixels, the simulated pressure sensitivity value of the current touch point is 1 / 2; when the first spacing is greater than 8 pixels and the first spacing is less than or equal to 12 pixels, the simulated pressure sensitivity value of the current touch point is 1 / 3; when the first spacing is greater than 12 pixels, the simulated pressure sensitivity value of the current touch point is 1 / 6.
[0140] That is, if the distance between two touch points is within 2 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 1; if the distance between two touch points is more than 2 pixels and less than 3 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 1.1; if the distance between two touch points is more than 3 pixels and less than 5 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 1.4; if the distance between two touch points is more than 5 pixels and less than 8 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 2; if the distance between two touch points is more than 8 pixels and less than 12 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 3; if the distance between two touch points is more than 12 pixels, the pressure sensitivity coefficient PressureFactor is 1 / 6. That is, in this embodiment, the distance between two touch points is negatively correlated with the pressure sensitivity coefficient.
[0141] In this embodiment, the pressure sensitivity coefficient is adjusted step by step according to the distance between two touch points, which is suitable for scenes with a relatively straight line, such as writing a vertical line (the direction of the vector after connecting multiple touch points is a vertical angle). The pressure sensitivity coefficient is adjusted step by step according to the distance between two touch points. When the simulated pressure sensitivity value reaches the minimum pressure sensitivity coefficient value, the simulated pressure sensitivity value can be readjusted, such as Fig.16 As shown in the figure, after the handwriting converges, the pressure sensitivity coefficient does not continue to decrease but increases slightly with the same spacing.
[0142] Step S1202, determining the current graphic size according to the simulated pressure value of the current touch point.
[0143] For details, please see Figure 5 Step S502 of the illustrated embodiment will not be described in detail here.
[0144] Step S1203, determining the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates.
[0145] For details, please see Figure 5 Step S503 of the illustrated embodiment will not be described in detail here.
[0146] Step S1204: Draw a handwriting line segment from the last touch point to the current touch point based on the curve generated by the overall contour point set.
[0147] For details, please see Figure 5 Step S504 of the illustrated embodiment will not be described in detail here.
[0148] This embodiment adjusts the simulated pressure value by the touch point spacing, which can be called a touch speed gesture simulation scheme, which is suitable for the writing effect similar to regular script. The writing effect obtained by the above method can be as follows: Fig.17 shown.
[0149] The method for drawing handwriting provided in this embodiment recognizes the distance between the current touch point and the previous touch point, dynamically adjusts the simulated pressure value, and then simulates the pen tip according to the relationship between the simulated pressure value and the change in pen gesture, so that non-capacitive screens, electromagnetic screens and other pressure-free touch screens can also simulate similar pressure-sensitive writing effects.
[0150] In this embodiment, a method for drawing handwriting is provided, which can be used in the above-mentioned mobile terminals, such as mobile phones, tablet computers, etc. Fig.18 FIG. 1 is a flow chart of another method for drawing handwriting according to an embodiment of the present invention. Fig.18 As shown, the method comprises the following steps:
[0151] Step S1801, obtaining a pressure sensitivity value data set.
[0152] Among them, the pressure sensitivity value data set includes n preset pressure sensitivity values, where n is an integer greater than 1. The n preset pressure sensitivity values can be determined by the designer based on the reporting rate and configured in advance in the memory of the touch screen. The number n of preset pressure sensitivity values can be determined based on the reporting rate, that is, the number n of preset pressure sensitivity values adapted to the reporting rates of different touch screens can be different.
[0153] Step S1802: determining the first preset pressure sensitivity value among the n preset pressure sensitivity values as the simulated pressure sensitivity value of the current touch point.
[0154] Among them, when 1<N≤n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the first touch point are updated to the second preset pressure sensitivity value to the Nth preset pressure sensitivity value in sequence; when n<N<2n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the N-n+1th touch point are updated to the second preset pressure sensitivity value to the nth preset pressure sensitivity value in sequence; when N=2n, N is updated to Nn, N represents the order of the current touch points, and N is an integer greater than or equal to 1.
[0155] Specifically, when writing, the touch data is monitored, the touch point set is recorded, and the most recent touch point is stored in the list strokeTipQueue, and the number of touch points stored in the list strokeTipQueue is less than or equal to 2n. When a new touch point (current touch point) is added to the list strokeTipQueue, the first preset pressure value of the n preset pressure values is determined as the simulated pressure value of the current touch point, wherein the order of the current touch point is N. At the same time, if 1<N≤n, the simulated pressure value of the N-1th touch point to the simulated pressure value of the first touch point is updated to the second preset pressure value to the Nth preset pressure value in sequence; if n<N<2n, the simulated pressure value of the N-1th touch point to the simulated pressure value of the N-n+1th touch point is updated to the second preset pressure value to the nth preset pressure value in sequence; if N=2n, the first n touch point sets are removed and drawn separately as a handwriting line segment, and N is updated to Nn, and the remaining touch point sets in the strokeTipQueue continue to be drawn.
[0156] In an example, n can be 6, and the n preset pressure values are 1 / 6, 1 / 4, 1 / 3, 1 / 1.5, 1 / 1.2 and 1, that is, pressure1=1 / 6, pressure2=1 / 4, pressure3=1 / 3, pressure4=1 / 1.5, pressure5=1 / 1.2, pressure6=1.
[0157] The following is an example of a process for determining the pressure sense value of a touch point in this embodiment.
[0158] Specifically, when writing, after the first touch point is added to the strokeTipQueue list, the simulated pressure value of the first touch point is set to 1 / 6, and the first touch point is now the current touch point. After the second touch point is added to the strokeTipQueue list, the simulated pressure value of the second touch point is set to 1 / 6, and the simulated pressure value of the first touch point is updated to 1 / 4, and the second touch point is now the current touch point, and the first touch point is now the previous touch point. The handwriting line segment is determined based on the updated simulated pressure value of the first touch point and the simulated pressure value of the second touch point.
[0159] The program code for resetting the pressure coefficient of the previous touch point strokeTipQueue[n-2] may be: strokeTipQueue[n-2].PressureFactor / =pressure1;
[0160] strokeTipQueue[n-2].PressureFactor*=pressure2.
[0161] By analogy, after the seventh touch point is added to the strokeTipQueue list, the simulated pressure value of the seventh touch point is set to 1 / 6, and the simulated pressure values of the sixth touch point to the second touch point are set to 1 / 4, 1 / 3, 1 / 1.5, 1 / 1.2 and 1 respectively, and the simulated pressure value of the first touch point remains 1. At this point, the seventh touch point is the current touch point, and the sixth touch point is the previous touch point.
[0162] After that, after the twelfth touch point is added to the strokeTipQueue list, the simulated pressure value of the twelfth touch point is set to 1 / 6, the first 6 touch points in the strokeTipQueue list are removed from the list, and are drawn separately as a handwriting line segment.
[0163] Then N is updated to Nn and drawing continues until a lift action is detected. The strokeTipQueue list ends and a new strokeTipQueue list is regenerated. The handwriting line segments obtained through the above process can be Fig.19 shown.
[0164] Step S1803, determining the current graphic size according to the simulated pressure value of the current touch point.
[0165] For details, please see Figure 5 Step S502 of the illustrated embodiment will not be described in detail here.
[0166] Step S1804, determining the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates.
[0167] For details, please see Figure 5 Step S503 of the illustrated embodiment will not be described in detail here.
[0168] Step S1805: Draw a handwriting line segment from the last touch point to the current touch point based on the curve generated by the overall contour point set.
[0169] For details, please see Figure 5Step S504 of the illustrated embodiment will not be described in detail here.
[0170] In this embodiment, the simulated pressure value corresponding to the same touch point changes dynamically with the writing time, and the final writing effect can be as follows: Fig. 20 As shown, it is suitable for the effect similar to running script.
[0171] The method for drawing handwriting provided in this embodiment, after obtaining the pressure sensitivity value data set, changes the simulated pressure sensitivity coefficient of each touch point in real time according to the pressure sensitivity value data set during the writing process, and then realizes the simulation of the pen tip according to the relationship between the simulated pressure sensitivity value and the pen gesture change. It can not only make non-capacitive screens, electromagnetic screens and other non-pressure-sensitive touch screens simulate similar pressure-sensitive writing effects, but also realize the writing function of running script.
[0172] In the present embodiment, a device for drawing handwriting is also provided, which is used to implement the above-mentioned embodiments and preferred embodiments, and the descriptions thereof will not be repeated. As used below, the term "module" can implement a combination of software and / or hardware of a predetermined function. Although the devices described in the following embodiments are preferably implemented in software, the implementation of hardware, or a combination of software and hardware, is also possible and contemplated.
[0173] This embodiment provides a device for drawing handwriting, such as Fig.21 As shown, including:
[0174] A first determination module 2101 is used to determine the simulated pressure value of the current touch point;
[0175] The second determining module 2102 is used to determine the current graphic size according to the simulated pressure value of the current touch point, wherein the current graphic size is the graphic size of the drawing area corresponding to the current touch point;
[0176] The third determining module 2103 is used to determine the overall contour point set of the previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size and the previous touch coordinates, wherein the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, and the previous touch coordinates are the coordinates of the previous touch point;
[0177] The drawing module 2104 is used to draw a handwriting line segment from the last touch point to the current touch point based on the curve generated by the overall contour point set.
[0178] In some optional implementations, the first determining module 2101 includes:
[0179] The first determination unit is used to determine the simulated pressure value of the current touch point based on a first distance and a first corresponding relationship, wherein the first distance is the distance between the current touch point and the previous touch point, and the first corresponding relationship represents the corresponding relationship between the distance between the two touch points and the pressure coefficient.
[0180] In some optional implementations, the first corresponding relationship represents that the pressure sensitivity coefficient and the distance between the two touch points are in an exponential relationship.
[0181] In some optional implementations, the first determining unit includes:
[0182] A first determining subunit is used to determine an effective spacing based on a first spacing, a minimum preset spacing, and a maximum preset spacing, wherein when the first spacing is greater than or equal to the maximum preset spacing, the effective spacing is the maximum preset spacing, when the first spacing is less than or equal to the minimum preset spacing, the effective spacing is the minimum preset spacing, and when the first spacing is greater than the minimum preset spacing and the first spacing is less than the maximum preset spacing, the effective spacing is the first spacing;
[0183] The second determining subunit is used to determine the simulated pressure value of the current touch point based on the ratio of the effective distance to the difference between the maximum preset distance and the minimum preset distance, the pressure increase coefficient and the first corresponding relationship.
[0184] In some optional implementations, the first corresponding relationship is a corresponding relationship between a plurality of preset intervals between two touch points and a plurality of preset pressure sensitivity coefficients.
[0185] In some optional implementations, the first correspondence includes:
[0186] When the first spacing is less than or equal to 2 pixels, the simulated pressure value of the current touch point is 1;
[0187] When the first spacing is greater than 2 pixels and less than or equal to 3 pixels, the simulated pressure value of the current touch point is 1 / 1.1;
[0188] When the first spacing is greater than 3 pixels and less than or equal to 5 pixels, the simulated pressure value of the current touch point is 1 / 1.4;
[0189] When the first spacing is greater than 5 pixels and less than or equal to 8 pixels, the simulated pressure value of the current touch point is 1 / 2;
[0190] When the first spacing is greater than 8 pixels and less than or equal to 12 pixels, the simulated pressure value of the current touch point is 1 / 3;
[0191] When the first spacing is greater than 12 pixels, the simulated pressure value of the current touch point is 1 / 6.
[0192] In some optional embodiments, the device further comprises:
[0193] An acquisition module, used to acquire a pressure sensitivity value data set, wherein the pressure sensitivity value data set includes n preset pressure sensitivity values, where n is an integer greater than 1;
[0194] The first determination module 2101 includes:
[0195] The second determination unit is used to determine the first preset pressure sensitivity value among n preset pressure sensitivity values as the analog pressure sensitivity value of the current touch point, wherein, when 1<N≤n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the first touch point are updated to the second preset pressure sensitivity value to the Nth preset pressure sensitivity value in sequence; when n<N<2n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the N-n+1th touch point are updated to the second preset pressure sensitivity value to the nth preset pressure sensitivity value in sequence; when N=2n, N is updated to Nn, N represents the order of the current touch points, and N is an integer greater than or equal to 1.
[0196] In some optional implementations, n is 6, and the n preset pressure sensitivity values are 1 / 6, 1 / 4, 1 / 3, 1 / 1.5, 1 / 1.2 and 1, respectively.
[0197] The further functional description of each of the above modules and units is the same as that of the above corresponding embodiments and will not be repeated here.
[0198] The device for drawing handwriting in this embodiment is presented in the form of a functional unit, where the unit refers to an application specific integrated circuit (ASIC), a processor and memory that executes one or more software or fixed programs, and / or other devices that can provide the above functions.
[0199] The embodiment of the present invention further provides an electronic device, such as Fig. 22 As shown, the electronic device includes: one or more processors 2210, a memory 2220, and interfaces for connecting various components, including high-speed interfaces and low-speed interfaces. The various components are connected to each other using different buses for communication, and can be installed on a common mainboard or installed in other ways as needed. The processor can process instructions executed in the electronic device, including instructions stored in or on the memory to display graphical information of the GUI on an external input / output device (such as a display device coupled to the interface). In some optional embodiments, if necessary, multiple processors and / or multiple buses can be used together with multiple memories and multiple memories. Similarly, multiple electronic devices can be connected, and each device provides some necessary operations (for example, as a server array, a group of blade servers, or a multi-processor system). Fig. 22 A processor 2210 is taken as an example.
[0200] The processor 2210 may be a central processing unit, a network processor or a combination thereof. The processor 2210 may further include a hardware chip. The hardware chip may be a dedicated integrated circuit, a programmable logic device or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general purpose array logic or any combination thereof.
[0201] The memory 2220 stores instructions executable by at least one processor 2210 so as to enable at least one processor 2210 to implement the method shown in the above embodiment.
[0202] The memory 2220 may include a program storage area and a data storage area, wherein the program storage area may store an operating system, an application required for at least one function; the data storage area may store data created according to the use of the electronic device, etc. In addition, the memory 2220 may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some optional embodiments, the memory 2220 may optionally include a memory remotely arranged relative to the processor 2210, and these remote memories may be connected to the electronic device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0203] The memory 2220 may include a volatile memory, such as a random access memory; the memory may also include a non-volatile memory, such as a flash memory, a hard disk or a solid state drive; the memory 2220 may also include a combination of the above types of memory.
[0204] The electronic device also includes an input device 2230 and an output device 2240. The processor 2210, the memory 2220, the input device 2230 and the output device 2240 may be connected via a bus or other means. Fig. 22 The example of connecting through bus is taken in the following.
[0205] The input device 2230 can receive input digital or character information, and generate key signal input related to the user settings and function control of the electronic device, such as a touch screen, a keypad, a mouse, a track pad, a touch pad, an indicator bar, one or more mouse buttons, a trackball, a joystick, etc. The output device 2240 may include a display device, an auxiliary lighting device (e.g., an LED), and a tactile feedback device (e.g., a vibration motor), etc. The above-mentioned display device includes but is not limited to a liquid crystal display, a light emitting diode, a display, and a plasma display. In some optional embodiments, the display device may be a touch screen.
[0206] The embodiment of the present invention also provides a computer-readable storage medium. The method according to the embodiment of the present invention can be implemented in hardware, firmware, or can be implemented as a computer code that can be recorded in a storage medium, or can be implemented as a computer code that is originally stored in a remote storage medium or a non-temporary machine-readable storage medium and will be stored in a local storage medium through a network download, so that the method described herein can be stored in such software processing on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. Among them, the storage medium can be a magnetic disk, an optical disk, a read-only storage memory, a random access memory, a flash memory, a hard disk or a solid-state hard disk, etc.; further, the storage medium can also include a combination of the above types of memories. It can be understood that a computer, a processor, a microprocessor controller, or programmable hardware includes a storage component that can store or receive software or computer code. When the software or computer code is accessed and executed by a computer, a processor, or hardware, the method shown in the above embodiment is implemented.
[0207] A part of the present invention may be applied as a computer program product, such as a computer program instruction, which, when executed by a computer, can call or provide the method and / or technical solution according to the present invention through the operation of the computer. Those skilled in the art should understand that the existence of the computer program instruction in a computer-readable medium includes, but is not limited to, a source file, an executable file, an installation package file, etc., and accordingly, the way in which the computer program instruction is executed by the computer includes, but is not limited to: the computer directly executes the instruction, or the computer compiles the instruction and then executes the corresponding compiled program, or the computer reads and executes the instruction, or the computer reads and installs the instruction and then executes the corresponding installed program. Here, the computer-readable medium may be any available computer-readable storage medium or communication medium accessible to the computer.
[0208] It should be understood that the various parts of the present invention can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, a plurality of steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0209] In the description of this specification, the description with reference to the terms "this embodiment", "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner. In addition, those skilled in the art may combine and combine the different embodiments or examples described in this specification and the features of the different embodiments or examples, unless they are contradictory.
[0210] In addition, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of the indicated technical features. Therefore, the features defined as "first" and "second" may explicitly or implicitly include at least one of the features. In the description of the present invention, the meaning of "plurality" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.
[0211] Although the embodiments of the present invention have been described in conjunction with the accompanying drawings, those skilled in the art may make various modifications and variations without departing from the spirit and scope of the present invention, and such modifications and variations are all within the scope defined by the present invention.
Claims
1. A method for drawing handwriting, characterized in that: The method comprises: Determine the simulated pressure value of the current touch point; Determine a current graphic size according to the simulated pressure value of the current touch point, wherein the current graphic size is a graphic size of a drawing area corresponding to the current touch point; Determining an overall contour point set of a previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size, and the previous touch coordinates, wherein the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, and the previous touch coordinates are the coordinates of the previous touch point; Based on the curve generated by the overall contour point set, a handwriting line segment from the previous touch point to the current touch point is drawn.
2. The method according to claim 1, characterized in that The step of determining the simulated pressure value of the current touch point includes: Based on a first distance and a first corresponding relationship, the simulated pressure value of the current touch point is determined, wherein the first distance is the distance between the current touch point and the previous touch point, and the first corresponding relationship represents the corresponding relationship between the distance between two touch points and the pressure coefficient.
3. The method according to claim 2, characterized in that The first corresponding relationship indicates that the pressure sensitivity coefficient and the distance between the two touch points are in an exponential relationship.
4. The method according to claim 2 or 3, characterized in that: The determining, based on the first distance and the first corresponding relationship, the simulated pressure value of the current touch point includes: An effective spacing is determined based on the first spacing, the minimum preset spacing, and the maximum preset spacing, wherein when the first spacing is greater than or equal to the maximum preset spacing, the effective spacing is the maximum preset spacing, when the first spacing is less than or equal to the minimum preset spacing, the effective spacing is the minimum preset spacing, and when the first spacing is greater than the minimum preset spacing and the first spacing is less than the maximum preset spacing, the effective spacing is the first spacing; The simulated pressure value of the current touch point is determined based on the ratio of the effective distance to the difference between the maximum preset distance and the minimum preset distance, the pressure increase coefficient, and the first corresponding relationship.
5. The method according to claim 2, characterized in that: The first corresponding relationship is a corresponding relationship between a plurality of preset intervals between two touch points and a plurality of preset pressure sensitivity coefficients.
6. The method according to claim 1, characterized in that The method further comprises: Acquire a pressure sensitivity value data set, wherein the pressure sensitivity value data set includes n preset pressure sensitivity values, where n is an integer greater than 1; The step of determining the simulated pressure value of the current touch point includes: The first preset pressure sensitivity value among the n preset pressure sensitivity values is determined as the analog pressure sensitivity value of the current touch point, wherein, when 1<N≤n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the first touch point are updated to the second preset pressure sensitivity value to the Nth preset pressure sensitivity value in sequence; when n<N<2n, the analog pressure sensitivity value of the N-1th touch point to the analog pressure sensitivity value of the N-n+1th touch point are updated to the second preset pressure sensitivity value to the nth preset pressure sensitivity value in sequence; when N=2n, N is updated to Nn, N represents the order of the current touch points, and N is an integer greater than or equal to 1.
7. A device for drawing handwriting, characterized in that: The device comprises: A first determination module, used to determine the simulated pressure value of the current touch point; A second determination module, configured to determine a current graphic size according to the simulated pressure value of the current touch point, wherein the current graphic size is a graphic size of a drawing area corresponding to the current touch point; a third determining module, configured to determine an overall contour point set of a previous touch point and the current touch point according to the current graphic size, the current touch coordinates, the previous graphic size, and the previous touch coordinates, wherein the current touch coordinates are the coordinates of the current touch point, the previous graphic size is the graphic size of the drawing area corresponding to the previous touch point, and the previous touch coordinates are the coordinates of the previous touch point; A drawing module is used to draw a handwriting line segment from the previous touch point to the current touch point based on a curve generated by the overall contour point set.
8. An electronic device, characterized in that: include: A memory and a processor, wherein the memory and the processor are communicatively connected to each other, the memory stores computer instructions, and the processor executes the method according to any one of claims 1 to 6 by executing the computer instructions.
9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer instructions, and the computer instructions are used to enable a computer to execute the method according to any one of claims 1 to 6.
10. A computer program product, characterized in that The method comprises computer instructions for causing a computer to execute the method according to any one of claims 1 to 6.