CN109101171B - Method for generating sliding track in touch screen equipment - Google Patents

Method for generating sliding track in touch screen equipment Download PDF

Info

Publication number
CN109101171B
CN109101171B CN201710478895.3A CN201710478895A CN109101171B CN 109101171 B CN109101171 B CN 109101171B CN 201710478895 A CN201710478895 A CN 201710478895A CN 109101171 B CN109101171 B CN 109101171B
Authority
CN
China
Prior art keywords
points
touch
point
track
adjacent
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201710478895.3A
Other languages
Chinese (zh)
Other versions
CN109101171A (en
Inventor
李飞
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Yizhen Xuesi Education Technology Co Ltd
Original Assignee
Beijing Yizhen Xuesi Education Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Yizhen Xuesi Education Technology Co Ltd filed Critical Beijing Yizhen Xuesi Education Technology Co Ltd
Priority to CN201710478895.3A priority Critical patent/CN109101171B/en
Publication of CN109101171A publication Critical patent/CN109101171A/en
Application granted granted Critical
Publication of CN109101171B publication Critical patent/CN109101171B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0487Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser
    • G06F3/0488Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures
    • G06F3/04883Interaction techniques based on graphical user interfaces [GUI] using specific features provided by the input device, e.g. functions controlled by the rotation of a mouse with dual sensing arrangements, or of the nature of the input device, e.g. tap gestures based on pressure sensed by a digitiser using a touch-screen or digitiser, e.g. input of commands through traced gestures for inputting data by handwriting, e.g. gesture or text

Abstract

The embodiment of the invention provides a method for generating a sliding track in touch screen equipment, which comprises the steps of receiving a contact track sent by the touch screen equipment, and sequentially acquiring two adjacent touch points on the contact track according to the time sequence of touch occurrence corresponding to the contact; randomly selecting two points on a contact track between every two adjacent touch points which are acquired in sequence; obtaining two control points of the Bezier curve according to the position relation between the two selected points and the two adjacent touch points which are sequentially obtained; and performing Bezier curve fitting between each two adjacent touch points acquired in sequence based on the two acquired control points to generate a sliding track. According to the method for generating the sliding track in the touch screen device, the control points of the Bezier curve are calculated according to the positions of the touch points on the touch point track, so that curve fitting is performed on the touch point track according to the direction information provided by the control points to generate the smooth sliding track.

Description

Method for generating sliding track in touch screen equipment
Technical Field
The invention relates to the field of computer graphic processing, in particular to a method for generating a sliding track in touch screen equipment.
Background
The current electronic products generally have handwriting functions, such as handwriting signing, handwriting annotation, handwriting signature, handwriting recognition, handwriting note taking and the like.
When the stylus or human finger is moved across the screen of the device, the device typically notifies the corresponding process software of the current location of the stylus or human finger in the form of a touch event. Since the processing capability of the device and the event notification mechanism have certain limitations (for example, the time interval for notifying the touch event is not uniform), and the user may shake during the handwriting operation with a finger or a touch pen, the touch trajectory formed on the screen of the device by the handwriting operation has wrinkles and insufficient smoothness.
Disclosure of Invention
The embodiment of the invention provides a method for generating a sliding track in touch screen equipment, which can form a smooth sliding track when handwriting operation is executed on electronic equipment with a handwriting function, and solves the problem of insufficient smoothness of the sliding track formed on an equipment screen by the handwriting operation in the prior art. To achieve the above object, an embodiment of the present invention provides a method for generating a sliding track in a touch screen device, including the steps of: receiving a touch point track sent by the touch screen equipment, and sequentially acquiring two adjacent touch points on the touch point track according to the time sequence of touch occurrence corresponding to the touch points; randomly selecting two points on a contact track between every two adjacent touch points which are acquired in sequence; obtaining two control points of the Bezier curve according to the position relation between the two selected points and the two adjacent touch points which are sequentially obtained;
and performing Bezier curve fitting between each two adjacent touch points acquired in sequence based on the two acquired control points to generate a sliding track.
In the above step, after the control point between two adjacent touch points is obtained, a bezier curve may be fitted between the two touch points, so that a bezier curve corresponding to the entire touch point trajectory may be obtained by continuously fitting a bezier curve between two adjacent touch points on the touch point trajectory according to the touch sequence of the user.
Optionally, the step of correcting the two selected points to obtain the control points of the bezier curve is to calculate a midpoint between every two adjacent points of four points of the two adjacent touch points and the two selected points; calculating the length of a connecting line between the midpoints, and calculating the ratio of the lengths; and correcting the positions of the two selected points according to the ratio and the midpoint, and respectively translating the two selected points to the positions or drawing the two points on the positions to obtain control points of the Bezier curve.
Optionally, the step of calculating a midpoint between two adjacent touch points and two selected points among four points in total, includes: calculating a starting midpoint between the starting points of two adjacent touch points and a selected point near the starting points, a transition midpoint between the selected two points, and an ending midpoint between the selected other point and the end points of the two adjacent touch points.
The step of calculating the middle point takes one of two adjacent touch points as a starting point of a bezier curve between the two touch points, and the other touch point as an end point of the bezier curve, and respectively calculates the middle point between the starting point and a selected point close to the starting point, the middle point between the two selected points, and the middle point between the other selected point and the end point.
Optionally, the step of calculating the length of the connecting line between the midpoints includes: a first length of a line connecting the start midpoint and the transition midpoint, a second length of the transition midpoint and the termination midpoint, and a third length of the start midpoint and the termination midpoint are calculated.
Optionally, the step of calculating the ratio between the lengths is: calculating a ratio of the first length to a sum of the first length and the second length; a ratio of the second length to a sum of the second length and the third length is calculated.
Optionally, before curve fitting the touch point trajectory based on the obtained control points to generate the sliding trajectory, a step of adjusting a distance between the control point and two adjacent touch points is further included.
Optionally, before generating the sliding track, the method further includes: calculating the length of a curve of a sliding track to be generated, and calculating the number of coordinate points between two adjacent touch points on the curve according to the calculated length; determining a diameter of the coordinate point based on the number and diameters of the two adjacent touch points; and performing Bezier curve fitting between the two adjacent touch points according to the diameters of the coordinate points to generate a sliding track with variable width.
Optionally, the obtaining of the number of coordinate points includes: establishing a coordinate system, and mapping the curve of the sliding track to be generated to the coordinate system; and obtaining the number of the coordinate points on the curve according to the length of the sliding track to be generated and the distance between the preset coordinate points.
The calculation steps of the diameter of the touch point are as follows: acquiring touch time of a touch point; calculating the touch time difference of two adjacent touch points; obtaining the touch speed between the two adjacent touch points according to the distance between the two adjacent touch points and the touch time difference; and determining the diameter of the touch point with the later touch time in the two adjacent touch points according to the touch speed.
Optionally, obtaining the touch speed between the current two touch points further includes: and adjusting the obtained touch speed between the two adjacent touch points at present according to the touch speed between the two adjacent touch points at the last time and the set weight value.
Optionally, obtaining the control point of the bezier curve further includes: drawing a curve between two adjacent touch points based on the obtained control points, and storing the curve in a bitmap file; the bitmap file described above is invoked when drawing the curve between the next pair of adjacent touch points.
Optionally, the step of generating the sliding track is: and performing curve fitting on the contact point track in the drawing buffer area, and sending the drawn Bezier curve to the display buffer area for displaying.
Optionally, the step of acquiring two adjacent touch points on the touch trajectory includes: obtaining coordinates of touch points sent by a touch track; acquiring coordinates of touch points on a touch point track sent by the touch screen equipment; calculating the distance between two adjacent touch points on the touch point track according to the acquired coordinates of the touch points; if the distance is less than a predetermined threshold, one of the two adjacent touch points is discarded such that the distance between the unrecessed touch point and the next touch point is equal to or greater than the predetermined threshold.
Optionally, the setting process of the predetermined threshold is: acquiring the screen density of the touch screen equipment; obtaining the number of touch points to be discarded according to the acquired screen density and a set screen density threshold; obtaining the average distance between two adjacent touch points on the touch track according to the number of the touch points to be discarded; the average distance is taken as a predetermined threshold.
To sum up, the embodiment of the present invention provides a method for generating a sliding trajectory in a touch screen device, the method randomly selects two points between two adjacent touch points on a touch trajectory, corrects the positions of the two randomly selected points by solving the middle point between four points of the two adjacent touch points and the two randomly selected points, and the length and the ratio of the connection line between the middle points, so that the two randomly selected points approach the control point infinitely, and finally draws a bezier curve between the two adjacent touch points based on the control point obtained through correction, or directly draws two control points according to the calculated coordinate values of the control point, and draws a bezier curve between the two adjacent touch points according to the drawn control point. And finally obtaining a smooth sliding track corresponding to the contact point track by connecting Bezier curves between a plurality of pairs of adjacent touch points on the contact point track. As can be seen from the above description, in the embodiment of the present invention, the control points of the bezier curve are obtained through calculation according to the touch points, so that the shape of the curve between two adjacent touch points on the touch point trajectory is accurately determined according to the control points, and the touch screen device can fit a smooth sliding trajectory according to the direction information provided by the control points between every two adjacent touch points, unlike the prior art, in which the touch points are directly connected, so that a hard angle is generated between the connecting lines, and the connecting lines are not smooth.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings needed to be used in the description of the embodiments or the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art that other drawings can be obtained according to these drawings without creative efforts.
Fig. 1 is a flowchart of a method for generating a sliding track in a touch screen device according to an embodiment of the present invention;
fig. 2 is a schematic diagram of plotting bezier curves according to control points according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
As shown in fig. 1, an embodiment of the present application provides a method for generating a sliding track in a touch screen device, including the steps of:
s100: and receiving a touch point track sent by the touch screen equipment, and sequentially acquiring two adjacent touch points on the touch point track according to the time sequence of touch occurrence corresponding to the touch points.
In step S100, since the update speed of the touch screen device is fast, a large number of touch screen devices with different resolutions and different sizes are caused, the device fragmentation degree is high, and for the touch screen device with high resolution, when a touch point is obtained, more touch points are obtained, and the point fetching density is dense, so as to affect the response speed of the touch screen device. In the embodiment of the application, when step S100 is executed, first, the screen density of the touch screen device is obtained, then, the ratio of the obtained screen density to the set screen density threshold is calculated, and a remainder of the obtained screen density to the set screen density threshold is obtained, where the remainder is the number of points that need to be discarded when the touch point is obtained, the number of touch points actually used for drawing the bezier curve is obtained according to the total number of touch points and the number of discarded points sent on the touch point trajectory, the average distance between two adjacent touch points on the touch point trajectory is obtained by combining the length of the touch point trajectory, and the obtained average distance is used as a predetermined threshold of the distance between two adjacent touch points.
It should be noted that, in the embodiment of the present application, a smooth touch trajectory is drawn in response to a touch action of a user while the user touches the touch trajectory, and therefore, the number of touch points cannot be acquired before a final slide trajectory is generated. In the implementation process, the obtained touch point track can be mapped into a coordinate system, so that the coordinate values of all touch points on the touch point track can be obtained, and further, the distance between the two points and the midpoint between the two points are calculated according to the coordinate values.
Optionally, after determining the predetermined threshold of the distance between two adjacent touch points, when step S100 is executed, an actual distance between two adjacent touch points is calculated according to the obtained coordinate values of the touch points on the touch point trajectory, the actual distance is compared with the predetermined threshold, and if the actual distance is smaller than the predetermined threshold, one of the two adjacent touch points is discarded, so that the distance between the unredisposed touch point and the next touch point is equal to or greater than the predetermined threshold. Of two adjacent touch points on the touch trajectory, a point with a later touch time may be discarded, or a point with a earlier touch time may be discarded. For example, assuming that two adjacent acquired touch points are Q1, Q2, Q1, Q2, Q2, and Q1 and Q2 are points at the front of the touch time, respectively, and the distance between the touch points is smaller than a predetermined threshold L, if the touch point Q2 is discarded, it is determined whether the distance between the touch point Q1 and the next touch point Q3 which are not discarded is smaller than the predetermined threshold L, and if the distance is equal to or greater than the predetermined threshold L, the touch point Q3 is retained; if still less than the predetermined threshold L, point Q3 is discarded and the determination of the distance between the next touch point of Q1 and Q3 continues. If the touch point Q1 is discarded, since a determination has been made as to the distance between Q1 and the adjacent touch point Q0 in front thereof, the distance between Q0 and the unremoved touch point Q2 after discarding the touch point Q1 must be greater than the predetermined threshold value L. The comparison between the distance between the touch point Q2 and the touch point Q3 and the predetermined threshold L is continued.
It should be noted that, calculating the length of the contact trace is prior art, and is not described herein again. Moreover, in general, the touch points at the back of the direction from the starting point to the ending point of the touch point track are discarded in the embodiments of the present application, because the touch points at the front are determined when the trade-off between the two adjacent touch points is determined.
According to the embodiment of the application, the preset threshold value between two adjacent touch points is set, so that when the handwriting operation is executed on the touch screen equipment with the larger screen density, a plurality of touch points do not need to be taken, the smooth sliding track is drawn, the response speed of the equipment is not influenced, the average distance between the touch points is taken as the preset threshold value, generally, the distance is not too large, the number of the touch points used for generating the sliding track can be ensured even when the handwriting operation is executed on the touch screen equipment with the lower screen density, and the quality of the drawn sliding track is further ensured.
As shown in fig. 2, after two adjacent touch points are acquired, step S200 is executed: and randomly selecting two points on the contact point track between every two adjacent touch points acquired in sequence. As shown in the figure, the two adjacent touch points are P0 and P3, respectively, i.e., the starting point of the bezier curve between the two adjacent touch points is P0, and the ending point is P3. The starting point and the ending point are determined according to the sliding direction of the contact point track, wherein the sliding direction can be determined according to the time when the touch action corresponding to the contact point on the contact point track occurs.
Note that the touch points P0 and P3 are two adjacent touch points, and for clarity of description, the distance between the touch points is enlarged as shown in fig. 2.
According to the method, curve fitting can be performed between adjacent touch points by using a cubic Bessel interpolation algorithm, so two control points need to be calculated according to coordinates of the touch points P0 and P3, the two control points of the Bessel curve between the touch points P0 and P3 are set as P1 and P2, two points a1 and a2 are randomly selected between P0 and P3, and the position relations between the two points a1 and a2 and the control points P1 and P2 can be preset for convenience of calculation. A1 may be set, a2 between P1 and P2, P1 may be set, P2 between a1 and a2, P1, a1 between P2 and a2, and so on. The present embodiment is explained by taking an example in which two points a1 and a2 are assumed to be between control points P1 and P2. Then, in step S300, the step of obtaining two control points of the bezier curve according to the position relationship between the two selected points and the two adjacent touch points sequentially obtained includes: the midpoint between P0 and the selected point a1 near P0 is calculated and may be referred to as the starting midpoint, the midpoint between a1 and a2 may be referred to as the transition midpoint, and the midpoint between a2 and P3 may be referred to as the ending midpoint.
In actually performing the above operation, assuming that a1(x1, y1) and a2(x2, y2) are between two control points, the midpoint between P0(x0, y0) and a1(x1, y1) is calculated as M1(x 1)c1,yc1) The midpoint between a1(x1, y1) and a2(x2, y2) was calculated as M2(x 2)c2,yc2) And the midpoint between a2(x2, y2) and P3(x3, y3) is M3(x 3832, y3)c3,yc3)。
The length len1 of the line between midpoints M1 and M2, the length len2 of the line between midpoints M2 and M3, and the length len3 of the line between midpoints M1 and M3 are then calculated, and the ratios between these three lengths are calculated as follows:
k1=len1/(len1+len2);
k2=len2/(len2+len3);
the positions of a1 and a2 are corrected by the following equations according to the ratios k1, k2 and the above-mentioned midpoints M1, M2 and M3:
xm1=xc1+(xc2-xc1)*k1;
ym1=yc1+(yc2-yc1)*k1;
xm2=xc2+(xc3-xc2)*k2;
ym2=yc2+(yc3-yc2)*k2;
wherein (x)m1,ym1) Is at M1 (x)c1,yc1) In combination with M2 (x)c2,yc2) And the value of k1, the coordinates of control point P1 obtained by translating M1. (x)m2,ym2) Is at M2 (x)c2,yc2) In combination with P3 ((x)c3,yc3) And k2, for M2The coordinates of the control point P2 are obtained.
Through the steps, Bezier curve control points between every two adjacent touch points on the touch point track can be obtained. It should be noted that, after the positions of the control points are obtained, the two selected points may be moved to the calculated position of the control point, or the control points may be redrawn at the calculated position of the control point, so that a bezier curve starting from one of the two adjacent touch points and approaching to the other touch point is drawn according to the curve direction information provided by the control points obtained after the movement or the control points obtained after the redrawing. Therefore, after Bezier curves are drawn between each pair of adjacent touch points on the touch point track, the Bezier curves are connected in pairs, and a smooth sliding track can be presented on the touch screen device. In the implementation process, a canvas technology can also be used for drawing the sliding track, the canvas technology can draw the touch sliding track according to the starting point, the control point and the end point which are selected by each section of the cubic Bezier curve, and then the smooth sliding track is formed through further drawing and filling and is displayed on the touch screen. Compared with a curve drawing method for directly connecting adjacent touch points in the prior art, the curve drawing method provided by the embodiment of the application reduces the generation of hard angles in the curve and can obtain the curve with higher smoothness.
Optionally, before generating the sliding track, adjusting the distance between the control point and two adjacent touch points is further included, and specifically, the adjustment may be implemented by adjusting coordinates of the control points P1 and P2. In the implementation process, the coordinates of the control points P1 and P2 can be adjusted by a smoothness parameter smoothjvalue between 0 and 1, and the adjustment process is as follows:
ctrl1_x=xm1+(xc2-xm1)*smooth_value+x1-xm1
ctrl1_y=ym1+(yc2-ym1)*smooth_value+y1-ym1
ctrl2_x=xm2+(xc2-xm2)*smooth_value+x2-xm2
ctrl2_y=ym2+(yc2-ym2)*smooth_value+y2-ym2
where ctrl1_ x and ctrl1_ y are respectively the abscissa and ordinate of adjusted control point P1, and ctrl2_ x and ctrl2_ y are respectively the abscissa and ordinate of adjusted control point P2.
It should be noted that, it is verified that the larger the value of the smoothness smooth _ value is, the smoother the obtained sliding track is, and therefore, the smoothness can be appropriately adjusted to be within an allowable range in combination with the actual situation to further enhance the smoothness of the generated sliding track.
In order to better present the sliding track, the embodiment of the present application further provides a method for drawing a bezier curve with varying thickness, that is, the diameter size of a touch point is determined by calculating the drawing speed between two adjacent touch points. According to the embodiment of the application, when the touch points are collected, the touch time of the collected touch points is read, and the touch time difference between two adjacent touch points is calculated according to the touch time.
In the actual implementation of the scheme, the diameter of the first touch point on the bezier curve path is generally preset, so that when the diameter of the touch point is determined according to the touch speed between the first touch point and the second touch point on the bezier curve path, the diameter of the second touch point is determined. And the like, in two adjacent touch points, the diameter of the touch point which is close to the end point of the Bezier curve and is behind the touch time is determined according to the touch speed.
It should be noted that the touch speed and the diameter of the touch point may be in a direct proportion relationship or an inverse proportion relationship, as long as the diameter of the touch point can be changed regularly according to the touch speed.
In order to avoid that the difference between the touch speed of the previous pair of adjacent two touch points and the touch speed of the next pair of adjacent two touch points is too large, so that the width of the plotted curve has abrupt change, in the embodiment of the present application, a weight value between 0 and 1 is set, and the touch speed between the current two adjacent touch points is adjusted by using the weight value, and specifically, the touch speed between the current two adjacent touch points can be calculated by (a weight value between 0 and 1) + (1-weight value) (speed of the previous two points).
In order to further avoid the situation that the width of the bezier curve changes too fast, the embodiment of the present application further presets a maximum diameter and a minimum diameter of a touch point, where the maximum diameter and the minimum diameter may be preset according to an empirical value by counting the diameters of the touch points. And taking the larger value by comparing the maximum diameter/(velocity +1) with the minimum diameter, taking the maximum diameter if the larger value exceeds the set maximum diameter, and taking the minimum diameter if the larger value is smaller than the set minimum diameter. By adjusting the calculated diameter of the touch point in the manner, the Bezier curve can show different widths according to different touch speeds, and meanwhile, the Bezier curve does not exceed the maximum diameter or is smaller than the minimum diameter, namely, the width does not change too fast, and the smoothness of the sliding track is further ensured.
Optionally, the method for drawing the bezier curve with the varying width is as follows: calculating the length of a curve of a sliding track to be generated; as mentioned above, the touch point trace transmitted by the touch screen device can be mapped into a coordinate system, where we can map the curve of the sliding trace to be generated into the corresponding coordinate system, and calculate the number of coordinate points on the curve according to the calculated length and the preset distance between the coordinate points. For example, if the calculated length of the curve is 10 and the distance between the coordinate points is set to 1, the number of coordinate points on the curve is 11. It should be noted that, the coordinate points and the touch points are referred to herein respectively because some coordinate points may not be touch points, but in order to draw a sliding track with a varying thickness and avoid a discontinuous curve after enlarging the sliding track, the present solution draws both coordinate points between two adjacent touch points when drawing the curve. That is, the coordinate points may include two adjacent touch points, that is, in the example where the number of coordinate points calculated is 11, two adjacent touch points are already included in the 11 points. Of course, two adjacent touch points may not be included, for example, the distance between the first coordinate point and the start point of the two adjacent touch points and the distance between the last coordinate point and the end point of the two adjacent touch points may be set, and the two distances may be subtracted from the total length of the curve, so that the number of coordinate points may also be calculated. It should be noted that the smaller the distance between the coordinate points, or the greater the number of coordinate points between two adjacent touch points, the smoother the obtained variable-width sliding trajectory.
Based on the above number, and the previously determined diameter between two adjacent touch points, the diameter of each coordinate point can be determined. For example, if the diameter of the starting point of two adjacent touch points is set to be 1, or the diameter of the starting point determined according to the touch speed is 1, the diameter of the end point of two adjacent touch points determined according to the touch speed is 11, and there are 9 coordinate points between the two adjacent touch points, then in this embodiment, the diameter of the first coordinate point is 2, the diameter of the second coordinate point is 3, the diameter of the third coordinate point is 4, and the diameter of the 9 th coordinate point … … is 10, i.e., the diameters are arranged in an equal-difference array between 11 points of 2 touch points and 9 coordinate points. Of course, the touch points and the coordinate points are arranged in an arithmetic progression, or only the coordinate points are arranged in an arithmetic progression, which is only one of the ways to make the sliding track smoother, and may also be arranged in an arithmetic progression or other arrangements when specifically implemented.
When the width of the curve is variable, if the touch speed between the two touch points in the previous pair and the touch speed between the two touch points in the next pair are in an ascending trend, the width of the curve is in a thickening trend, and if the touch speed is in a descending trend, the width of the curve is in a narrowing trend.
It should be noted that, if the adjacent touch points are obtained on the touch point trajectory, the touch points are discarded, and the touch points mentioned in the present embodiment are discarded touch points; if the touch points are not discarded, the touch points mentioned in the scheme are all touch points on the touch point track sent by the touch screen device.
In executing step S400, the obtained control points generally only provide direction information, and as shown in fig. 2, the drawn bezier curve generally does not pass through two control points, P1 and P2. After the Bezier curve is drawn between each pair of adjacent touch points on the touch point track, the drawing of the sliding track corresponding to the whole touch point track is completed.
It should be further noted that all the steps in steps S100, S200, S300, and S400, or a combination of one or more steps may be completed by the touch screen device itself, for example, the steps may be completed by a processor in the touch screen device or a separate graphics processor, or a sliding track after the steps are completed by a third-party device other than the touch screen device is sent to the touch screen device for display.
In the touch screen device, the current position of the touch pen or the finger of a person is generally notified to corresponding processing software in a touch event manner, and then the processing software responds according to the position. The delay in the touch screen device's response from the time the stylus or human finger begins to perform a touch operation to the time the graphics are displayed on the touch screen device is inevitable. In order to shorten the time interval between the sliding of a touch pen or a finger of a person on a screen and the display of a graph, the drawn graph is stored in a bitmap file, namely the bitmap file. When the graph is drawn, the graph is directly called from the bitmap file, so that the drawing algorithm of the Bezier curve does not need to be repeatedly operated on each graph, and the delay feeling from touch to display is weakened.
Furthermore, two buffer areas, namely a drawing buffer area and a display buffer area are opened up in the embodiment of the application, and after the drawing buffer area finishes the operation of curve fitting on the contact track, the sliding track generated after fitting is sent to the display buffer area to be displayed. In this way, when the main thread of the touch screen device receives other requests, the main thread can still respond, and the main thread does not respond to other requests because of curve drawing.
The embodiment of the application also provides a method for generating a sliding track in the touch screen device, which is different from the embodiment of the application, and the method comprises the steps of receiving a contact point track sent by the touch screen device, and sequentially acquiring four adjacent touch points on the contact point track according to the time sequence of touch actions corresponding to the contact points; then, obtaining control points of the Bezier curve according to the position relation among the four selected points; and finally, fitting a Bezier curve between every four adjacent touch points which are sequentially selected based on the obtained control points to generate a sliding track.
The above embodiment first obtains four points adjacent in time, for example, the four points are T0, T1, T2, and T3, respectively. The four points are respectively connected to obtain line segments T0T1, T1T2 and T2T3, the midpoint of the line segment T0T1 is calculated to be M0', the midpoint of the line segment T1T2 is M1', the midpoint of the line segment T2T3 is M2', then the lengths of connecting lines between the midpoints M0' and M1', M1' and M2', and M2' and M0' are respectively calculated, and the ratios of the lengths of the three connecting lines are respectively calculated. The formula for calculating the ratio may be:
k1=len1/(len1+len2);
k2=len2/(len2+len3);
from the ratios k1, k2 and the above mentioned midpoints M0', M1' and M2', the coordinates of the control points Q1 and Q2 are calculated by the following formula:
xq1=xm0+(xm1-xm0)*k1;
yq1=ym0+(ym1-ym0)*k1;
xq2=xm1+(xm2-xm1)*k2;
yq2=ym1+(ym2-ym1)*k2;
(xq1,yq1) The coordinate value of the control point Q1 may be obtained by translating the touch point T1 or by plotting a coordinate point corresponding to the coordinate value. (x)q2,yq2) The coordinate value of the control point Q2 may be obtained by translating the touch point T2 or by plotting a coordinate point corresponding to the coordinate value.
Based on the same inventive concept, the application also provides a device for generating a sliding track in the touch screen equipment, which comprises a receiving and acquiring unit, a processing unit and a display unit, wherein the receiving and acquiring unit is used for receiving the touch track sent by the touch screen equipment and sequentially acquiring two adjacent touch points on the touch track according to the time sequence of touch occurrence corresponding to the touch points; the selection unit is used for randomly selecting two points on a contact track between every two adjacent touch points which are selected in sequence; the control point acquisition unit is used for obtaining two control points of the Bezier curve according to the position relationship between the two points selected by the selection unit and the position relationship between the two selected points and two adjacent touch points sequentially selected on the contact point track; and the generating unit is used for performing curve fitting between every two adjacent touch points which are sequentially selected based on the obtained two control points so as to generate a sliding track.
Based on the same inventive concept, the embodiment of the present application further provides another apparatus for generating a sliding track in a touch screen device, including a receiving unit for receiving a touch point track sent by the touch screen device, where the receiving unit sequentially obtains four adjacent touch points on the touch point track according to a time sequence of touch occurrence corresponding to the touch point; the control point acquisition unit is used for acquiring control points of the Bezier curve according to the position relation among the selected four points; and the generating unit is used for carrying out Bezier curve fitting on every four adjacent touch points which are sequentially selected based on the obtained control points so as to generate a sliding track.
In the several embodiments provided in the present application, it should be understood that the disclosed system, apparatus and method may be implemented in other manners. For example, the above-described apparatus embodiments are merely illustrative, and for example, a division of a unit is merely a logical division, and an actual implementation may have another division, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
Units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the solution of the embodiment.
In addition, each functional unit in the embodiments of the present invention may be integrated into one processing unit, or each unit may be separately processed, or two or more units may be integrated into one unit. The integrated unit can be realized in a form of hardware, or in a form of hardware plus a software functional unit.
The integrated unit implemented in the form of a software functional unit may be stored in a computer readable storage medium. The software functional unit is stored in a storage medium and includes several instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute some steps of the methods according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (14)

1. A method of generating a sliding trajectory in a touch screen device, comprising the steps of:
receiving a touch point track sent by the touch screen equipment, and sequentially acquiring two adjacent touch points on the touch point track according to the time sequence of touch occurrence corresponding to the touch points;
randomly selecting two points on a contact track between every two adjacent touch points which are acquired in sequence;
obtaining two control points of the Bezier curve according to the position relation between the two selected points and the two adjacent touch points which are sequentially obtained;
performing Bezier curve fitting between each two adjacent touch points acquired in sequence based on the two acquired control points to generate a sliding track,
the step of correcting the two selected points to obtain the control points of the bezier curve comprises the following steps:
calculating the middle point between every two adjacent points in four points of the two adjacent touch points and the two selected points;
calculating the lengths of the connecting lines between the midpoints and calculating the ratio of the lengths;
and calculating the position of a control point of the Bezier curve according to the ratio and the midpoint, and respectively translating the two selected points to the position or drawing the two points on the position to obtain the control point of the Bezier curve.
2. The method for generating a sliding track according to claim 1, wherein the step of calculating a midpoint between two adjacent touch points among the four points of the two adjacent touch points and the two selected points is specifically:
and calculating the starting midpoint between the starting points of the two adjacent touch points and the selected point close to the starting points, the transition midpoint between the two selected points and the ending midpoint between the other selected point and the end points of the two adjacent touch points according to the sliding direction of the touch point track.
3. The method for generating a sliding trajectory according to claim 2, wherein the step of calculating the length of the connecting line between the midpoints is as follows:
calculating a first length of a line connecting the starting midpoint and the transition midpoint, a second length of the transition midpoint and the ending midpoint, and a third length of the starting midpoint and the ending midpoint.
4. A method for generating a sliding trajectory according to claim 3, wherein the step of calculating the ratio between the lengths is specifically:
calculating a ratio of the first length to a sum of the first length and the second length, and calculating a ratio of the second length to a sum of the second length and the third length.
5. The method of generating a sliding trajectory according to claim 1, wherein before performing a bezier curve fit between the two adjacent touch points based on the obtained control points to generate the sliding trajectory, further comprising:
and adjusting the distance between the control point and the two adjacent touch points.
6. The method of generating a sliding trajectory according to claim 1, wherein generating a sliding trajectory further comprises:
calculating the length of a curve of a sliding track to be generated;
calculating the number of coordinate points between two adjacent touch points on the curve according to the length;
determining a diameter of the coordinate point based on the number and diameters of the two adjacent touch points;
and performing Bezier curve fitting between the two adjacent touch points according to the diameters of the coordinate points to generate a sliding track with variable width.
7. The method of generating a sliding trajectory according to claim 6, wherein the step of obtaining the number of coordinate points comprises:
establishing a coordinate system, and mapping the curve of the sliding track to be generated to the coordinate system;
and obtaining the number of the coordinate points on the curve according to the length of the sliding track to be generated and the distance between the preset coordinate points.
8. The method for generating a sliding track according to claim 6 or 7, wherein the step of calculating the touch point diameter is:
acquiring touch time of a touch point;
calculating the touch time difference of two adjacent touch points;
obtaining the touch speed between the two adjacent touch points according to the distance between the two adjacent touch points and the touch time difference;
and determining the diameter of the touch point with the later touch time in the two adjacent touch points according to the touch speed.
9. The method of generating a sliding trajectory according to claim 8, wherein obtaining the touch speed between the two touch points further comprises:
and adjusting the obtained touch speed between the two adjacent touch points at present according to the touch speed between the two adjacent touch points of the previous pair and the set weight value.
10. The method of generating a sliding trajectory according to claim 1, wherein the generating a sliding trajectory by performing Bezier curve fitting between the two adjacent touch points based on the obtained control points further comprises:
storing the generated sliding track in a bitmap file;
and calling the bitmap file when drawing a sliding track between the next pair of adjacent touch points.
11. The method for generating a sliding track according to claim 1, wherein the step of generating a sliding track is:
performing curve fitting on the contact point track in a drawing buffer area;
and sending the sliding track generated after curve fitting to a display buffer area for display.
12. The method for generating a sliding track according to claim 1, wherein the step of acquiring two adjacent touch points on the touch track is:
acquiring coordinates of touch points on a touch point track sent by the touch screen equipment;
calculating the distance between two adjacent touch points on the touch point track according to the acquired coordinates of the touch points;
if the distance is less than a predetermined threshold, one of the two adjacent touch points is discarded such that the distance between the unrecessed touch point and the next touch point is equal to or greater than the predetermined threshold.
13. The method for generating a sliding trajectory according to claim 12, wherein the predetermined threshold is set by:
acquiring the screen density of the touch screen equipment;
obtaining the number of touch points to be discarded according to the acquired screen density and a set screen density threshold;
obtaining the average distance between two adjacent touch points on the contact point track according to the number of the touch points to be discarded and the number of the touch points on the contact point track; taking the average distance as the predetermined threshold.
14. A method of generating a sliding trajectory in a touch screen device, comprising the steps of:
receiving a touch point track sent by the touch screen equipment, and sequentially acquiring four adjacent touch points on the touch point track according to the time sequence of touch occurrence corresponding to the touch points;
obtaining control points of the Bezier curve according to the position relation among the four selected points;
and performing Bezier curve fitting between every four adjacent touch points which are sequentially selected based on the obtained control points to generate a sliding track.
CN201710478895.3A 2017-06-21 2017-06-21 Method for generating sliding track in touch screen equipment Active CN109101171B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201710478895.3A CN109101171B (en) 2017-06-21 2017-06-21 Method for generating sliding track in touch screen equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201710478895.3A CN109101171B (en) 2017-06-21 2017-06-21 Method for generating sliding track in touch screen equipment

Publications (2)

Publication Number Publication Date
CN109101171A CN109101171A (en) 2018-12-28
CN109101171B true CN109101171B (en) 2020-12-11

Family

ID=64796291

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201710478895.3A Active CN109101171B (en) 2017-06-21 2017-06-21 Method for generating sliding track in touch screen equipment

Country Status (1)

Country Link
CN (1) CN109101171B (en)

Families Citing this family (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112346581A (en) * 2019-08-07 2021-02-09 南京中兴新软件有限责任公司 Method and device for drawing movement track and computer readable storage medium
CN111078106A (en) * 2020-02-26 2020-04-28 紫光云(南京)数字技术有限公司 Curve generation method and device applied to touch screen equipment and computer storage medium
CN111443864B (en) * 2020-04-14 2023-03-07 重庆赋比兴科技有限公司 iOS-based curve drawing method
CN111949157A (en) * 2020-07-30 2020-11-17 通彩视听科技(上海)有限公司 Simulated writing handwriting processing method, computer equipment and storage medium
CN112091436A (en) * 2020-08-27 2020-12-18 深圳市昆业激光设备科技有限公司 Laser marking method
CN114967972A (en) * 2022-04-27 2022-08-30 华南理工大学 Method, system and device for adjusting sampling rate of touch screen and storage medium
CN115079924A (en) * 2022-06-29 2022-09-20 广东明创软件科技有限公司 Screen display method, device, terminal, storage medium and product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102998684A (en) * 2012-11-21 2013-03-27 厦门雅迅网络股份有限公司 Terminal positioning track fitting method based on Bezier curve
CN103500037A (en) * 2013-09-11 2014-01-08 天脉聚源(北京)传媒科技有限公司 Track smoothing method and device
CN105190697A (en) * 2012-12-21 2015-12-23 思杰系统有限公司 Systems and methods for presenting a free-form drawing
CN105335069A (en) * 2014-07-09 2016-02-17 阿里巴巴集团控股有限公司 Method and device for generating sliding track in touch screen equipment
CN105354870A (en) * 2015-10-21 2016-02-24 新奥特(北京)视频技术有限公司 Restoration method and apparatus for drawn track

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102998684A (en) * 2012-11-21 2013-03-27 厦门雅迅网络股份有限公司 Terminal positioning track fitting method based on Bezier curve
CN105190697A (en) * 2012-12-21 2015-12-23 思杰系统有限公司 Systems and methods for presenting a free-form drawing
CN103500037A (en) * 2013-09-11 2014-01-08 天脉聚源(北京)传媒科技有限公司 Track smoothing method and device
CN105335069A (en) * 2014-07-09 2016-02-17 阿里巴巴集团控股有限公司 Method and device for generating sliding track in touch screen equipment
CN105354870A (en) * 2015-10-21 2016-02-24 新奥特(北京)视频技术有限公司 Restoration method and apparatus for drawn track

Also Published As

Publication number Publication date
CN109101171A (en) 2018-12-28

Similar Documents

Publication Publication Date Title
CN109101171B (en) Method for generating sliding track in touch screen equipment
JP6869249B2 (en) Methods and systems for generating and selectively outputting two types of ink vector data
US11842438B2 (en) Method and terminal device for determining occluded area of virtual object
US8154544B1 (en) User specified contact deformations for computer graphics
US9207858B2 (en) Method and apparatus for drawing and erasing calligraphic ink objects on a display surface
US9020266B2 (en) Methods and devices for processing handwriting input
JP2017529623A (en) Wet ink predictor
US20120324332A1 (en) Using Gestures to Generate Code, Including for Text Flow
CN112905102B (en) Method and device for realizing writing tip, electronic equipment and readable storage medium
JP2014182638A (en) Display control unit, display control method and computer program
US9792517B2 (en) Method and system for generating and selectively outputting two types of ink vector data
WO2022033009A1 (en) Rendering processing method and apparatus, electronic device and storage medium
CN114494046A (en) Touch trajectory processing method, device, terminal, storage medium and program product
CN106201314B (en) A kind of display methods and display device for realizing handwriting input on touch screen
CN112148199A (en) Handwriting implementation method and device in electronic equipment
CN108876704A (en) The method, apparatus and computer storage medium of facial image deformation
CN111402366A (en) Character rendering method and device, electronic equipment and storage medium
CN112817465B (en) Screen stroke self-adaptive adjustment method and device, display terminal and storage medium
CN115311386A (en) Fillet drawing method and device, electronic equipment and storage medium
TW201911235A (en) Method and system for smoothing a line segment, and a non-transitory computer-readable medium
JP4273219B2 (en) Modified curved surface display device
US20120223949A1 (en) Systems and methods for interactive vectorization
CN110363832A (en) Method for generating captions and device
US9189872B2 (en) Bezier arc approximation spring system
US11687176B2 (en) Methods and apparatuses for producing smooth representations of input motion in time and space

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant