Specific embodiment
In order to make the object, technical scheme and advantages of the embodiment of the invention clearer, below in conjunction with the embodiment of the present invention
In attached drawing, technical scheme in the embodiment of the invention is clearly and completely described, it is clear that described embodiment is
A part of the embodiment of the present invention, instead of all the embodiments.Based on the embodiments of the present invention, those of ordinary skill in the art
Every other embodiment obtained without making creative work, shall fall within the protection scope of the present invention.
Fig. 1 is the flow chart for the electronic brush pen pen shape processing method that the embodiment of the present invention one provides, provided in this embodiment
The method can be executed by a processing unit, which is integrally disposed in the electronic equipment of user.Such as Fig. 1 institute
Show, this method comprises:
Step 101, acquisition obtain the seat of the current touch point for the writing brush pen shape that user operates on electronic device touchscreen
The coordinate of mark and touch point before, it is described before touch point include the current touch point previous touch point and the current touching
Touch the first two touch point a little.
Specifically, when user needs to write out on the touch screen of electronic equipment the font of writing brush pen shape, user can be with
Touch operation is carried out on the touchscreen, is operated on the touch screen correspondingly, processing unit such as processor can detecte user
Touch point position.
The present embodiment does not limit the specific algorithm for detecting the touch point position, and those skilled in the art can according to need
Voluntarily select or design the detection algorithm of the required accuracy.
It will form touch point coordinate sequence in the present embodiment, in user operation process, successively connected by these touch point coordinates
It connects, constitutes handwriting trace.Assuming that current touch point is n-th of touch point, wherein n is the integer more than or equal to 1.Successively
Acquisition obtains each touch point formed in user operation process, and carries out subsequent deformation characteristics parameter meter to each touch point
Calculation and pen shape profile calculating process.
Wherein, for current touch point, need to use the touch point before it in above two calculating process
Coordinate information.It is worth noting that if calculation will be below when current touch point is first or second touch point
It is explained, and for other touch points in addition to this two o'clock, it can be using at the present embodiment subsequent step
Reason.
Step 102, according to the distance between the coordinate of the current touch point and coordinate of the previous touch point, and
The distance between coordinate and the coordinate of the first two touch point of the previous touch point, determine the deformation of the current touch point
Characteristic parameter.
The first two touch point of current touch point, the previous touch point of current touch point and current touch point are three successively phases
Adjacent touch point.Assuming that: the coordinate of current touch point is Pn=(xn,yn,tn), the coordinate of the previous touch point of current touch point
For Pn-1=(xn-1,yn-1,tn-1), the coordinate of the first two touch point of current touch point is Pn-2=(xn-2,yn-2,tn-2).Wherein,
tn、tn-1And tn-2Respectively correspond to the touch time of touch point.
Specifically, according to the distance between the coordinate of the coordinate of the current touch point and the previous touch point, with
And the coordinate and the distance between the coordinate of the first two touch point of the previous touch point, determine the shape of the current touch point
Become characteristic parameter, comprising:
According to formula
Determine that the deformation of current touch point is special
Levy parameter w
n, wherein W is pen shape width a reference value, can be preset as a constant, and e is the nature truth of a matter, a
sAnd b
sIt is mobile
Distribution coefficient, value range be [0 ,+∞), Δ t be adjacent touch point touch time interval.
It is worth noting that for the case where current touch point is first touch point, at this point, first touch point
Deformation characteristics parameter setting is equal to W.The case where being second touch point for current touch point, at this point, second touch
The deformation characteristics parameter of point is such as according to formula
It determines, i.e., according to second touch point and first
Distance between a touch point determines.
Step 103, according to the coordinate of the current touch point and the deformation characteristics parameter of the current touch point, determine
The pen shape profile of the current touch point.
When carrying out brush writing, the person's handwriting of writing has an one fixed width, it is corresponding with for certain unicursal, the stroke
It include multiple touch points, each touch point has the profile size of a bit, and the profile of all touch points is fused together simultaneously
It carries out rendering to show, then constitutes the pen shape effect of the stroke.
Therefore, the profile to each touch point is needed to calculate in the present embodiment.Specifically, according to the current touching
The deformation characteristics parameter for touching coordinate and the current touch point a little, determines the pen shape profile of the current touch point, comprising:
Firstly, determining the corresponding pen shape boundary curve equation group of current touch point according to the coordinate of current touch point are as follows:
Wherein, described a, b and c are preset constant, yOnCorresponding pen shape upper bound curvilinear equation, yUnderCorresponding pen shape lower bound curve side
Journey, yIt is rightThe corresponding right boundary's curvilinear equation of pen shape.
For each touch point, pen shape profile can be determined according to pen shape boundary curve, firstly, each touch
The pen shape boundary curve of point includes upper and lower, right three boundary curves.
Secondly, solving above-mentioned pen shape boundary curve equation group, the point on the surrounded Close edges of pen shape boundary curve is obtained
Set M, wherein assuming that N (x'i,y'i) be set M in any point coordinate.
Again, using formula
To the point N (x' on set M
i,y'
i) carry out
Scaling obtains the set M for constituting the point of the pen shape profile of current touch point
w.To by the point of the pen shape profile of current touch point
Set M
wConstitute the pen shape profile of current touch point.Wherein,
For with coordinate points N
(x'
i,y'
i) corresponding set M
wIn point coordinate.
Every bit and set M in the set M of boundarywIn each point correspond, also, set MwIn certain point be set M
In corresponding points zoomed in and out according to the deformation characteristics parameter of the coordinate of the point and the point after obtain.
The pen shape profile area defined of step 104, the rendering current touch point.
After the profile of touch point determines, can with will the profile area defined rendered, than
Black ink effect is such as filled, real-time display is carried out.
In the present embodiment, by using the distance between adjacent multiple writing brush pen shapes touch point as foundation, to determine current touching
Deformation characteristics parameter a little is touched, and then current touch point is determined according to the coordinate of the deformation characteristics parameter and current touch point
Pen shape profile, and so on, with user little by little describe, the pen shape profile of each touch point can be formed in real time, from
And the pen shape profile overlay area of each touch point is filled rendering step by step, to show discribed person's handwriting pen shape.
It, can in a manner of the pen shape profile in the technical program by the deformation characteristics parameter of each touch point to calculate each touch point
Effectively to simulate writing brush on an electronic device in writing process because of the pen shape effect that deformation generates, so that the writing brush pen shape of simulation
It is greatly improved with the similarity of brush writing effect, the writing that can be more truly reflected writer is intended to, brush writing sense
By force, stroke simulation degree is higher.
Fig. 2 is the flow chart of electronic brush pen pen shape processing method provided by Embodiment 2 of the present invention, as shown in Fig. 2, in Fig. 1
On the basis of illustrated embodiment, after step 103, it can also include the following steps:
Whether the distance between coordinate of step 201, the coordinate for judging the current touch point and the previous touch point
Greater than preset threshold, if more than thening follow the steps 202-205, otherwise executing above-mentioned steps 104.
If the distance between the coordinate of current touch point and the coordinate of its previous touch point are greater than preset threshold, illustrate this
There is very big gap between the profile of two touch points, in order to guarantee that the pen shape of pen shape effect and true brush writing process has more
Good similarity needs to carry out auxiliary point insertion between this two touch point.
Step 202 is inserted at least one auxiliary point between the current touch point and the previous touch point, and according to
The coordinate of the current touch point and the coordinate of the previous touch point determine the coordinate of the auxiliary point.
Assuming that: N is the number of the auxiliary point of insertion, and N is the integer more than or equal to 1.Wherein, N can be preset constant,
It can also be determined by the negatively correlated function of distance between current touch point and previous touch point.
Specifically, the coordinate of auxiliary point is determined according to the coordinate of the coordinate of current touch point and previous touch point, comprising:
Determine the coordinate of each auxiliary point are as follows:
Step 203 is joined according to the deformation characteristics parameter of the current touch point and the deformation characteristics of the previous touch point
Number, determines the deformation characteristics parameter of the auxiliary point.
Specifically, it according to the deformation characteristics parameter of the deformation characteristics parameter of current touch point and previous touch point, determines
The deformation characteristics parameter of auxiliary point, comprising: determine the deformation characteristics parameter of each auxiliary point are as follows:
Wherein, w
n-1For the deformation characteristics parameter of previous touch point;w
nFor current touch
The deformation characteristics parameter of point.
Step 204 determines the auxiliary point according to the coordinate of the auxiliary point and the deformation characteristics parameter of the auxiliary point
Pen shape profile.
Specifically, the pen shape profile of auxiliary point is determined according to the deformation characteristics parameter of the coordinate of auxiliary point and auxiliary point,
Include:
The point for constituting the pen shape profile of each auxiliary point is determined using formula
Set M'
w;Wherein,
For with Q
j(x
j,y
j) corresponding set M'
wIn point coordinate.By each auxiliary point
Pen shape profile point set M'
wConstitute the pen shape profile of each auxiliary point.In turn, all auxiliary points as above calculate,
Obtain the pen shape profile of each auxiliary point.
What the pen shape profile of step 205, the pen shape profile of the rendering current touch point and the auxiliary point was surrounded
Region.
By all touch points, and the profile fusion of the auxiliary point that is inserted between two adjacent touch points, that is, it constitutes and uses
The profile of the person's handwriting pen shape of family operation, carries out rendering filling in the region that the pen shape profile surrounds, can show final
Pen shape effect.
In the present embodiment, when distance is larger between two adjacent touch points, the insertion of auxiliary point is carried out, and pass through meter
The insertion coordinate position and deformation characteristics parameter for calculating each auxiliary point, calculate the pen shape profile of each auxiliary point, so that two
Pen shape between farther away touch point also can be more life-like in true brush writing effect so that the writing brush pen shape of simulation with
The similarity of brush writing effect greatly improves, and the writing that can be more truly reflected writer is intended to, and brush writing sense is strong,
Stroke simulation degree is higher.
Fig. 3 is the structural schematic diagram for the electronic brush pen pen shape processing unit that the embodiment of the present invention three provides, as shown in figure 3,
The device includes:
Acquisition module 11, for acquiring the current touch for obtaining the writing brush pen shape that user operates on electronic device touchscreen
The coordinate and the coordinate of touch point before of point, the touch point before include the previous touch point of the current touch point and described
The first two touch point of current touch point;
First deformation characteristics computing module 12, for according to the coordinate of the current touch point and the previous touch point
The distance between the coordinate and the coordinate of the first two touch point of the distance between coordinate and the previous touch point determine
The deformation characteristics parameter of the current touch point;
First pen shape profile processing module 13, for the coordinate and the current touch point according to the current touch point
Deformation characteristics parameter, determine the pen shape profile of the current touch point;
Rendering module 14, for rendering the pen shape profile area defined of the current touch point.
Further, the first deformation characteristics computing module 12 is also used to:
According to formulaDetermine the current touch point
Deformation characteristics parameter wn, wherein the coordinate of the current touch point is Pn=(xn,yn,tn), the coordinate of the previous touch point is
Pn-1=(xn-1,yn-1,tn-1), the coordinate of the first two touch point is Pn-2=(xn-2,yn-2,tn-2), W is pen shape width benchmark
Value, e are the nature truth of a matter, asAnd bsFor shifted matching coefficient, value range be [0 ,+∞), when Δ t is the touch of adjacent touch point
Between be spaced, tn、tn-1And tn-2Respectively to the touch time of corresponding touch point.
Further, the first pen shape profile processing module 13 is also used to:
According to the coordinate of the current touch point, the corresponding pen shape boundary curve equation group of the current touch point is determined
Are as follows:
Wherein, described a, b and c are preset constant, yOnCorresponding pen shape upper bound curvilinear equation, yUnderCorresponding pen shape lower bound curve side
Journey, yIt is rightThe corresponding right boundary's curvilinear equation of pen shape;
The pen shape boundary curve equation group is solved, the point on the surrounded Close edges of pen shape boundary curve is obtained
Set M;
Using formula
To the point N (x' on the set M
i,y'
i) contract
It puts, obtains the set M of the point for the pen shape profile for constituting the current touch point
w;By the pen shape profile of the current touch point
The set M of point
wConstitute the pen shape profile of the current touch point.
Wherein, N (x'
i,y'
i) be the set M in any point coordinate,
For with the N (x'
i,y'
i) the corresponding set M
wIn point coordinate.
The electronic brush pen pen shape processing unit of the present embodiment can be used for executing the technical side of embodiment of the method shown in Fig. 1
Case, it is similar that the realization principle and technical effect are similar, and details are not described herein again.
Fig. 4 is the structural schematic diagram for the electronic brush pen pen shape processing unit that the embodiment of the present invention four provides, as shown in figure 4,
On the basis of embodiment shown in Fig. 3, the device further include:
Judgment module 21, for judge between the coordinate of the current touch point and the coordinate of the previous touch point away from
From whether greater than preset threshold;
Auxiliary point processing module 22, for the judgment module determine the distance be greater than preset threshold when, described
Be inserted at least one auxiliary point between current touch point and the previous touch point, and according to the coordinate of the current touch point and
The coordinate of the previous touch point determines the coordinate of the auxiliary point;
Second deformation characteristics computing module 23, for according to the deformation characteristics parameter of the current touch point and described previous
The deformation characteristics parameter of touch point determines the deformation characteristics parameter of the auxiliary point;
Second pen shape profile processing module 24, for according to the coordinate of the auxiliary point and the deformation characteristics of the auxiliary point
Parameter determines the pen shape profile of the auxiliary point;
The rendering module 14 is also used to render the pen shape profile of the current touch point and the pen shape of the auxiliary point
Profile area defined.
Further, the auxiliary point processing module 22 is also used to: determining the coordinate of the auxiliary point are as follows:
Wherein, j=1,2, N, N are the supplement of insertion
The number of point, N are the integer more than or equal to 1;
The second deformation characteristics computing module 23 is also used to: determining the deformation characteristics parameter of the auxiliary point are as follows:
Wherein, w
n-1For the deformation characteristics parameter of the previous touch point;
The second pen shape profile processing module 24 is also used to: using formula
Determine the set M' for constituting the point of pen shape profile of the auxiliary pointw;Wherein,For with Qj(xj,
yj) the corresponding set M'wIn point coordinate;By the set M' of the point of the pen shape profile of the auxiliary pointwConstitute the benefit
Fill pen shape profile a little.
The electronic brush pen pen shape processing unit of the present embodiment can be used for executing the technical side of embodiment of the method shown in Fig. 2
Case, it is similar that the realization principle and technical effect are similar, and details are not described herein again.
Those of ordinary skill in the art will appreciate that: realize that all or part of the steps of above method embodiment can pass through
The relevant hardware of program instruction is completed, and program above-mentioned can be stored in a computer readable storage medium, the program
When being executed, step including the steps of the foregoing method embodiments is executed;And storage medium above-mentioned includes: ROM, RAM, magnetic disk or light
The various media that can store program code such as disk.
Finally, it should be noted that the above embodiments are merely illustrative of the technical solutions of the present invention, rather than its limitations;Although
Present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that: it still may be used
To modify the technical solutions described in the foregoing embodiments or equivalent replacement of some of the technical features;
And these are modified or replaceed, technical solution of various embodiments of the present invention that it does not separate the essence of the corresponding technical solution spirit and
Range.