Line drawing methods, devices and storage media

By obtaining the coordinates of the line's starting point, creating line instance objects, and updating the pattern data in real time, the problem of fixed line styles was solved, enabling personalized line drawing and a good visual experience.

CN115526960BActive Publication Date: 2026-03-06CHENGDU XINCHAO MEDIA GRP CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211223585.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-08
Publication Date
2026-03-06
Estimated Expiration
2042-10-08

AI Technical Summary

Technical Problem

In existing technologies, line styles are fixed, making it difficult to meet people's personalized needs for diverse line styles.

Method used

By obtaining the starting coordinates of the line to be drawn, a target line instance object is created and its coordinate array is initialized. The line width and pattern array are recorded. The coordinates are updated in real time in response to the user's sliding operation. The view is traversed and the pattern data is displayed, ensuring that the coordinate spacing is sufficient to avoid overlap.

Benefits of technology

It enables personalized line drawing, meets people's diverse needs for line styles, and ensures a good visual experience in the drawing effect.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115526960B_ABST
    Figure CN115526960B_ABST
Patent Text Reader

Abstract

This invention discloses a line drawing method, apparatus, and storage medium, relating to the field of computer technology. The method includes creating a target line instance object and initializing a target coordinate array; storing the target line instance object in an array of lines to be drawn; determining a unique identifier corresponding to the target line instance object, and determining the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object; when the distance between the most recently slid-over coordinate and the most recently stored coordinate is greater than a preset threshold, storing the most recently slid-over coordinate in the target coordinate array; if there is a target view not added to the canvas among multiple views corresponding to coordinates in all coordinate arrays, determining the target coordinates corresponding to the target view and the target image data corresponding to the target coordinates, displaying the target image data in the target view, and then adding it to the canvas. The method, apparatus, and storage medium disclosed in this invention can realize personalized line drawing.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention belongs to the field of computer technology, and specifically relates to a line drawing method, apparatus and storage medium. Background Technology

[0002] Currently, when drawing lines using the brush tool, the common approach is to calculate the coordinates of the points on the canvas to obtain the drawing path, then fill the drawing path with lines of a certain width, and set different colors for the lines to achieve personalized customization.

[0003] However, this drawing method results in fixed line styles, and generally only basic parameters such as line width and color can be set, making it difficult to meet people's personalized needs for diverse line styles.

[0004] Therefore, how to provide an effective solution to meet people's personalized needs for drawing line styles has become an urgent problem to be solved in the existing technology. Summary of the Invention

[0005] The purpose of this invention is to provide a line drawing method, apparatus, and storage medium to solve the aforementioned problems existing in the prior art.

[0006] To achieve the above objectives, the present invention adopts the following technical solution:

[0007] In a first aspect, the present invention provides a line drawing method, the method comprising:

[0008] Responding to a user's single-finger touch on the canvas, obtain the starting coordinates of the line to be drawn;

[0009] Create a target line instance object, initialize the target coordinate array corresponding to the target line instance object and store the starting coordinates into the target coordinate array. The target line instance object records the line width of the line to be drawn and a pattern array for drawing the line. The pattern array includes an image data sequence composed of image data of at least one image.

[0010] The target line instance object is stored in the line array to be drawn, and the line array to be drawn is used to record the line instance objects corresponding to all the lines to be drawn;

[0011] Set a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and determine the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object;

[0012] In response to a user's single-finger swipe gesture on the canvas, the system obtains the latest coordinates of the swipe on the canvas in real time.

[0013] When the distance between the latest sliding coordinate and the most recently stored coordinate in the target coordinate array is greater than a preset threshold, the latest sliding coordinate is stored in the target coordinate array.

[0014] Iterate through all coordinate arrays in the array of lines to be drawn, and determine multiple views corresponding to the coordinates in all coordinate arrays. The views are used to display the corresponding image data in the pattern array at the corresponding coordinate positions on the canvas.

[0015] If there is a target view that has not been added to the canvas among the multiple views corresponding to the coordinates in all coordinate arrays, then the target coordinates corresponding to the target view are determined, and the target image data corresponding to the target coordinates is determined based on the subscript of the target coordinates. After the target coordinates are used as the vertex coordinates of the target view and the target image data is displayed in the target view, the target view is added to the canvas.

[0016] In one possible design, before obtaining the starting coordinates of the line to be drawn in response to a user's single-finger touch on the canvas, the method further includes:

[0017] Initialization requires drawing an array of lines and undoing an array of lines. The undoing array of lines is used to record the line instance objects corresponding to all undoing lines.

[0018] In response to the user's settings, set the line width of the line to be drawn and the array of patterns to be used to draw the line.

[0019] In one possible design, the unique identifier corresponding to the target line instance object is paths.count + cancelPaths.count, where paths.count represents the number of existing line instance objects in the array of lines to be drawn, excluding the target line instance object, and cancelPaths.count represents the number of canceled line instance objects recorded in the array of canceled lines.

[0020] In a possible design, the index of any coordinate in a coordinate array is tag1*100000+tag2, where tag2 is the position of the coordinate in the coordinate array and tag1 is the unique identifier of the line instance object corresponding to the coordinate array.

[0021] The index of the image data in the pattern array corresponding to any coordinate in a given coordinate array is index%images.count, where index is the total number of image data in the pattern array, and images.count is the index of any coordinate in a given coordinate array.

[0022] In one possible design, the method further includes:

[0023] In response to a user-initiated line undo operation, determine whether the number of line instance objects in the array of lines to be drawn is greater than 0;

[0024] If the number of line instance objects in the array of lines to be drawn is greater than 0, then the latest recorded line instance object in the array of lines to be drawn is added to the array of lines to be undone, and the latest recorded line instance object in the array of lines to be drawn is deleted, so that the line instance objects recorded in the array of lines to be drawn can be redrawn.

[0025] In one possible design, the method further includes:

[0026] In response to a user-initiated line restoration operation, determine whether the number of line instance objects in the undone line array is greater than 0;

[0027] If the number of line instance objects in the undone line array is greater than 0, then the latest recorded line instance object in the undone line array is added to the line array to be drawn, and the latest recorded line instance object in the undone line array is deleted, so that the line instance objects recorded in the line array to be drawn can be redrawn.

[0028] In one possible design, the distance between the coordinates of the latest slide and the most recently stored coordinate in the target coordinate array is... Where x2-x1 represents the difference in the x-axis direction between the latest coordinate traversed in the planar coordinate system and the most recently stored coordinate in the target coordinate array, and y2-y1 represents the difference in the y-axis direction between the latest coordinate traversed in the planar coordinate system and the most recently stored coordinate in the target coordinate array.

[0029] In a second aspect, the present invention provides a line drawing device, the line drawing device comprising:

[0030] The acquisition unit is used to respond to a user's single-finger touch operation on the canvas and acquire the starting coordinates of the line to be drawn;

[0031] An initialization unit is used to create a target line instance object, initialize a target coordinate array corresponding to the target line instance object, and store the starting point coordinates into the target coordinate array. The target line instance object records the line width of the line to be drawn and a pattern array for drawing the line. The pattern array includes an image data sequence composed of image data of at least one image.

[0032] The storage unit is used to store the target line instance object into the line array to be drawn, wherein the line array to be drawn is used to record the line instance objects corresponding to all the lines to be drawn;

[0033] The determining unit is used to set a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and to determine the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object;

[0034] The acquisition unit is also used to respond to the user's single-finger swipe operation on the canvas and acquire the latest coordinates of the swipe on the canvas in real time;

[0035] The storage unit is further configured to store the coordinates of the latest sliding over into the target coordinate array when the distance between the coordinates of the latest sliding over and the coordinates of the most recently stored coordinates in the target coordinate array is greater than a preset threshold.

[0036] The determining unit is also used to traverse all coordinate arrays in the array of lines to be drawn and determine multiple views corresponding to the coordinates in all coordinate arrays. The views are used to display the corresponding image data in the pattern array at the corresponding coordinate position on the canvas.

[0037] The judgment unit is used to determine whether there is a target view that has not been added to the canvas among multiple views corresponding to the coordinates in all coordinate arrays;

[0038] The determining unit is further configured to determine the target coordinates corresponding to the target view if there is a target view that has not been added to the canvas among the multiple views corresponding to the coordinates in all coordinate arrays, and determine the target image data corresponding to the target coordinates based on the subscript of the target coordinates;

[0039] The display unit is used to add the target view to the canvas after displaying the target image data in the target view, using the target coordinates as the vertex coordinates of the target view.

[0040] Thirdly, the present invention provides a line drawing apparatus, comprising a memory, a processor, and a transceiver connected in sequence and communication, wherein the memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program and execute the line drawing method as described in the first aspect above.

[0041] Fourthly, the present invention provides a computer-readable storage medium storing instructions that, when executed on a computer, perform the line drawing method described in the first aspect.

[0042] Fifthly, the present invention provides a computer program product containing instructions that, when executed on a computer, cause the computer to perform the line drawing method as described in the first aspect.

[0043] Beneficial effects:

[0044] The line drawing scheme provided by this invention involves: obtaining the starting coordinates of the line to be drawn; creating a target line instance object; initializing the target coordinate array corresponding to the target line instance object and storing the starting coordinates in the target coordinate array; the target line instance object recording the line width of the line to be drawn and a pattern array used for drawing the line; the pattern array including an image data sequence composed of image data of at least one image; storing the target line instance object in the line array to be drawn; setting a unique identifier corresponding to the target line instance object as an attribute of the target line instance object; and determining the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object; and responding to... The system continuously monitors the coordinates of the user's single-finger swipe on the canvas. When the distance between the latest swipe coordinate and the most recently stored coordinate in the target coordinate array exceeds a preset threshold, the latest swipe coordinate is stored in the target coordinate array. The system iterates through all coordinate arrays corresponding to the coordinates in each array to determine multiple views. If any of these views is not yet added to the canvas, the target coordinates are determined, and the corresponding target image data is identified based on the index of the target coordinates. The target image data is then displayed in the target view, which is used as the vertex coordinates of the target view before adding it to the canvas. In this way, each coordinate in the coordinate array corresponding to the line to be drawn can display its corresponding image data through a relevant view. This means that the position corresponding to each coordinate in the coordinate array is displayed as an image, allowing the drawn line to be composed of a series of images. This enables personalized line drawing and meets users' individual needs for line styles. Meanwhile, when the distance between the coordinates of the latest sliding over and the coordinates of the most recently stored coordinates in the target coordinate array is greater than a preset threshold, the coordinates of the latest sliding over are stored in the target coordinate array. This ensures that adjacent coordinates in the target coordinate array maintain sufficient distance, so that the images that make up the lines do not overlap, and that the drawn lines have a better visual experience. Attached Figure Description

[0045] Figure 1 A flowchart illustrating the line drawing method provided in this application embodiment.

[0046] Figure 2 This is a schematic diagram of the structure of the line drawing device provided in an embodiment of this application.

[0047] Figure 3 This is a schematic diagram of another line drawing device provided in an embodiment of this application. Detailed Implementation

[0048] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the present invention will be briefly introduced below in conjunction with the accompanying drawings and descriptions of the embodiments or the prior art. Obviously, the following description of the structure of the accompanying drawings is only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort. It should be noted that the description of these embodiments is for the purpose of helping to understand the present invention, but does not constitute a limitation of the present invention.

[0049] Example:

[0050] This embodiment provides a line drawing method, which can be executed by, but is not limited to, a user terminal. The user terminal can be, but is not limited to, a smartphone, tablet computer, personal digital assistant, etc., with a touchscreen display. The line drawing method provided in this embodiment enables personalized line drawing, satisfying people's personalized needs for line styles.

[0051] The line drawing method provided in the embodiments of this application will be described in detail below. It should be understood that the execution subject does not constitute a limitation on the embodiments of this application.

[0052] like Figure 1 The diagram shown is a flowchart of a line drawing method provided in an embodiment of this application. The line drawing method may include the following steps:

[0053] Step S101. Respond to the user's single-finger touch operation on the canvas and obtain the starting coordinates of the line to be drawn.

[0054] In this embodiment of the application, the drawing board can be an area on a touch screen used for drawing lines and pictures, and lines and pictures can be drawn on the drawing board.

[0055] When a user needs to draw lines, they can first create a canvas, and then draw lines by clicking and sliding on the canvas area. The user terminal's system includes a method, such as `touchBegan`, to detect single-finger touches. When the canvas is touched, this method can be called to determine if it's a single-finger touch; if so, subsequent steps are executed; otherwise, they are not.

[0056] In this embodiment of the application, when creating the canvas, the array of lines to be drawn and the array of lines to be undone can be initialized first. The array of lines to be drawn is used to record the line instance objects corresponding to all lines to be drawn, and the array of lines to be undone is used to record the line instance objects corresponding to all undone lines. The line instance objects are used to record data such as the line width of the drawn lines, the pattern array of the drawn lines, and the coordinate array. The pattern array includes an image data sequence composed of image data of at least one image, and the coordinate array includes multiple coordinates.

[0057] After creating a canvas, the user can initiate settings for the line width and pattern array of the line to be drawn. The user terminal responds to these settings, configuring the line width and the pattern array used for drawing the line. In this embodiment, when drawing the line, it can be composed of images from the pattern array; therefore, the line width can refer to the width and height of the images in the pattern array.

[0058] Step S102. Create a target line instance object, initialize the target coordinate array corresponding to the target line instance object, and store the starting coordinates into the target coordinate array.

[0059] The target line instance object records the line width of the line to be drawn and an array of patterns used to draw the line. The pattern array includes a sequence of image data consisting of image data of at least one image, which can be set according to the actual situation. For example, if the at least one image includes an apple image, a strawberry image, and a banana image, then the pattern array includes a sequence of image data consisting of image data of the apple image, image data of the strawberry image, and image data of the banana image. The number of data items in this sequence can be set according to the actual situation. The data in this sequence can be arranged in different orders as needed. For example, if the image data sequence includes image data of the apple image, image data of the strawberry image, and image data of the banana image, assuming the image data of the apple image is data a, the image data of the strawberry image is data b, and the image data of the banana image is data c, the image data sequence can be represented as (data a, data b, data c).

[0060] Upon detecting a user's single-finger touch on the canvas, a line instance object can be created. To distinguish it from other line instance objects, it is referred to as a target line instance object in this embodiment. Simultaneously, a target coordinate array corresponding to this target line instance object can be initialized to record the sliding coordinates during the sliding process on the canvas.

[0061] In this embodiment of the application, after creating the target line instance object, the parent view of the target line instance object can also be set to the canvas itself, so that the line corresponding to the target line instance object can be drawn on the canvas later.

[0062] Step S103. Store the target line instance object into the array of lines to be drawn.

[0063] The array of lines to be drawn is used to record the line instance objects corresponding to all the lines that need to be drawn.

[0064] Step S104. Set a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and determine the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object.

[0065] In this embodiment, all line instance objects are uniquely identified to facilitate differentiation between different line instance objects. The unique identifier corresponding to the target line instance object can be determined based on the number of existing line instance objects in the line array to be drawn and the number of canceled line instance objects recorded in the canceled line array. The unique identifier corresponding to the target line instance object can be represented as paths.count + cancelPaths.count, where paths.count represents the number of existing line instance objects in the line array to be drawn excluding the target line instance object, and cancelPaths.count represents the number of canceled line instance objects recorded in the canceled line array.

[0066] After setting a unique identifier for the target line instance object, the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object can be determined based on the index of each coordinate in the coordinate array of the target line instance object. The index of the image data in the pattern array can be a natural number starting from 0. For example, if the pattern array includes 3 image data, the indices of the 3 image data can be 0, 1, and 2 respectively. The index of any coordinate in a coordinate array can be represented as tag1*N+tag2, where tag2 is the position of the coordinate in the coordinate array, and tag1 is the unique identifier of the line instance object corresponding to the coordinate array. N is a positive integer and should not be too small. For example, the value of N can be 10000, 50000, or 100000, etc. In this way, the obtained coordinate index is a large value, and the index of the coordinate in different coordinate arrays will not be repeated.

[0067] For example, if the unique identifier corresponding to the target line instance object is 5, the value of N is 100000, and the position of a certain coordinate in the coordinate array is 10 (i.e., the 10th coordinate in the coordinate array), then the subscript of the coordinate can be 5*100000+10=500010.

[0068] The index of the image data in the pattern array corresponding to any coordinate in a coordinate array can be represented as index%images.count, where % represents the remainder, index is the total number of image data in the pattern array, and images.count is the index of any coordinate in a coordinate array.

[0069] Step S105. Respond to the user's single-finger swipe operation on the canvas and obtain the latest coordinates of the swipe on the canvas in real time.

[0070] As the user performs a single-finger swipe on the canvas, the user terminal can obtain the coordinates of the latest swipe on the canvas in real time, that is, obtain the coordinates of the latest touch position on the canvas in real time.

[0071] Understandably, during the swiping process, the system can also call a method written in the system to detect whether the user's swiping operation on the canvas is a single-finger swipe operation.

[0072] Step S106. When the distance between the latest sliding coordinate and the most recently stored coordinate in the target coordinate array is greater than a preset threshold, store the latest sliding coordinate in the target coordinate array.

[0073] To avoid overlap between the images that make up the lines during subsequent line drawing, in this embodiment, the preset threshold can be the diagonal length of the image corresponding to the image data, and the distance between the most recently slid-through coordinate and the most recently stored coordinate in the target coordinate array is... Where x2-x1 represents the difference in the x-axis direction between the most recently traversed coordinates in the planar coordinate system and the most recently stored coordinates in the target coordinate array, and y2-y1 represents the difference in the y-axis direction between the most recently traversed coordinates in the planar coordinate system and the most recently stored coordinates in the target coordinate array. In this way, adjacent coordinates in the target coordinate array maintain sufficient distance, preventing overlap between subsequent images that compose the line and ensuring a good visual experience for the drawn line.

[0074] Understandably, if the distance between the latest sliding coordinate and the most recently stored coordinate in the target coordinate array is less than or equal to a preset threshold, the latest sliding coordinate will not be stored in the target coordinate array.

[0075] Step S107. Iterate through all coordinate arrays in the array of lines to be drawn and determine multiple views corresponding to the coordinates in all coordinate arrays.

[0076] The view is used to display the corresponding image data in the pattern array at the corresponding coordinate position on the canvas.

[0077] In the embodiments of this application, a double traversal is adopted. The outer traversal requires drawing an array of lines, while the inner traversal involves traversing the coordinate array stored in a single line instance object, thereby determining multiple views corresponding to the coordinates in all coordinate arrays.

[0078] Step S108. If there is a target view that has not been added to the canvas among the multiple views corresponding to the coordinates in all coordinate arrays, determine the target coordinates corresponding to the target view, determine the target image data corresponding to the target coordinates based on the subscript of the target coordinates, use the target coordinates as the vertex coordinates of the target view, display the target image data in the target view, and then add the target view to the canvas.

[0079] Each coordinate in all coordinate arrays corresponds to a view, which is used to display the image data corresponding to that coordinate at that coordinate location. After determining the multiple views corresponding to the coordinates in all coordinate arrays, it can be determined whether there is a target view (i.e., a view that does not display image data on the canvas) among the multiple views corresponding to the coordinates in all coordinate arrays. If there is a target view that is not added to the canvas among the multiple views corresponding to the coordinates in all coordinate arrays, the target coordinates corresponding to the target view are determined. Then, the target image data corresponding to the target coordinates is determined based on the subscript of the target coordinates (which can be determined according to the formula index%images.count in step S104). Then, the target coordinates are used as the vertex coordinates of the target view, and the target image data is displayed in the target view before adding the target view to the canvas. When displaying the target image data, the line width recorded in the line instance object where the coordinate array corresponding to the target coordinates is located can also be used to display the target image data.

[0080] In summary, the line drawing method provided in this application involves: obtaining the starting coordinates of the line to be drawn; creating a target line instance object; initializing the target coordinate array corresponding to the target line instance object and storing the starting coordinates in the target coordinate array; the target line instance object recording the line width of the line to be drawn and a pattern array used for drawing the line, wherein the pattern array includes an image data sequence composed of image data of at least one image; storing the target line instance object in the line array to be drawn; setting a unique identifier corresponding to the target line instance object as an attribute of the target line instance object; and determining the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object. The system responds to a user's single-finger swipe on the canvas, acquiring the latest coordinates traversed by the swipe in real time. When the distance between the latest swipe coordinates and the most recently stored coordinates in the target coordinate array exceeds a preset threshold, the latest swipe coordinates are stored in the target coordinate array. The system iterates through all coordinate arrays in the line array to be drawn, identifying multiple views corresponding to the coordinates in all arrays. If any of the views corresponding to the coordinates in all arrays contains a target view not yet added to the canvas, the system determines the target coordinates corresponding to the target view, and based on the index of the target coordinates, determines the target image data corresponding to those coordinates. The target coordinates are then used as the vertex coordinates of the target view, and the target image data is displayed in the target view before adding the target view to the canvas. In this way, each coordinate in the coordinate array corresponding to the line to be drawn can display its corresponding image data through the corresponding view, allowing each position in the coordinate array to be displayed as an image. This means the drawn lines can be composed of a series of images, enabling personalized line drawing and meeting people's personalized needs for line styles. Meanwhile, when the distance between the coordinates of the latest sliding over and the coordinates of the most recently stored coordinates in the target coordinate array is greater than a preset threshold, the coordinates of the latest sliding over are stored in the target coordinate array. This ensures that adjacent coordinates in the target coordinate array maintain sufficient distance, so that the images that make up the lines do not overlap, and that the drawn lines have a better visual experience.

[0081] Based on the first aspect described above, this application embodiment also provides a possible design for canceling drawn lines, which includes, but is not limited to, the following steps S201-S202.

[0082] Step S201. In response to the user's line undo operation, determine whether the number of line instance objects in the line array to be drawn is greater than 0.

[0083] Step S202. If the number of line instance objects in the line array to be drawn is greater than 0, the latest recorded line instance object in the line array to be drawn is added to the undo line array, and the latest recorded line instance object in the line array to be drawn is deleted, so that the line instance objects recorded in the line array to be drawn can be redrawn.

[0084] In this embodiment of the application, after deleting the latest recorded line instance object in the line array to be drawn, the view corresponding to each coordinate in the coordinate array of the latest recorded line instance object can be removed from the canvas, thereby realizing the redrawing of the lines.

[0085] Therefore, through the aforementioned possible design one, by adding the latest recorded line instance object in the array of lines to be drawn to the array of lines to be undoed, and deleting the latest recorded line instance object in the array of lines to be drawn, the function of undoing drawn lines can be realized.

[0086] Based on the first aspect or possible design one described above, this application embodiment also provides a possible design two for restoring the revoked line, which includes, but is not limited to, the following steps S301-S302.

[0087] Step S301. In response to the line restoration operation initiated by the user, determine whether the number of line instance objects in the undone line array is greater than 0.

[0088] Step S302. If the number of line instance objects in the undoed line array is greater than 0, add the latest recorded line instance object in the undoed line array to the line array to be drawn, and delete the latest recorded line instance object in the undoed line array, so that the line instance objects recorded in the line array to be drawn can be redrawn.

[0089] In this embodiment of the application, the aforementioned steps S107-S108 can be repeated to redraw the latest recorded line instance object in the undone line array on the canvas.

[0090] Therefore, through the aforementioned possible design two, by adding the latest recorded line instance object from the undoed line array to the line array to be drawn, and deleting the latest recorded line instance object from the undoed line array, the function of restoring undone lines can be realized.

[0091] Secondly, please refer to Figure 2 This application provides a line drawing device, comprising:

[0092] The acquisition unit is used to respond to a user's single-finger touch operation on the canvas and acquire the starting coordinates of the line to be drawn;

[0093] An initialization unit is used to create a target line instance object, initialize a target coordinate array corresponding to the target line instance object, and store the starting point coordinates into the target coordinate array. The target line instance object records the line width of the line to be drawn and a pattern array for drawing the line. The pattern array includes an image data sequence composed of image data of at least one image.

[0094] The storage unit is used to store the target line instance object into the line array to be drawn, wherein the line array to be drawn is used to record the line instance objects corresponding to all the lines to be drawn;

[0095] The determining unit is used to set a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and to determine the index of the image data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object based on the index of each coordinate in the coordinate array of the target line instance object;

[0096] The acquisition unit is also used to respond to the user's single-finger swipe operation on the canvas and acquire the latest coordinates of the swipe on the canvas in real time;

[0097] The storage unit is further configured to store the coordinates of the latest sliding over into the target coordinate array when the distance between the coordinates of the latest sliding over and the coordinates of the most recently stored coordinates in the target coordinate array is greater than a preset threshold.

[0098] The determining unit is also used to traverse all coordinate arrays in the array of lines to be drawn and determine multiple views corresponding to the coordinates in all coordinate arrays. The views are used to display the corresponding image data in the pattern array at the corresponding coordinate position on the canvas.

[0099] The judgment unit is used to determine whether there is a target view that has not been added to the canvas among multiple views corresponding to the coordinates in all coordinate arrays;

[0100] The determining unit is further configured to determine the target coordinates corresponding to the target view if there is a target view that has not been added to the canvas among the multiple views corresponding to the coordinates in all coordinate arrays, and determine the target image data corresponding to the target coordinates based on the subscript of the target coordinates;

[0101] The display unit is used to add the target view to the canvas after displaying the target image data in the target view, using the target coordinates as the vertex coordinates of the target view.

[0102] The working process, working details and technical effects of the device provided in the second aspect of this embodiment can be found in the first aspect of the embodiment, and will not be repeated here.

[0103] like Figure 3 As shown, a third aspect of this application provides a line drawing apparatus, including a memory, a processor, and a transceiver that are sequentially and communicatively connected. The memory is used to store a computer program, the transceiver is used to send and receive messages, and the processor is used to read the computer program and execute the line drawing method as described in the first aspect of the embodiment.

[0104] Specifically, the memory may include, but is not limited to, random access memory (RAM), read-only memory (ROM), flash memory, first-in-first-out (FIFO) memory, and / or last-in-first-out (FILO) memory, etc.; the processor may not be limited to microprocessors of the STM32F105 series, ARM (Advanced RISC Machines), x86 architecture processors, or processors with integrated NPU (neural-network processing units); the transceiver may be, but is not limited to, WiFi (Wireless Fidelity) wireless transceivers, Bluetooth wireless transceivers, General Packet Radio Service (GPRS) wireless transceivers, ZigBee (a low-power LAN protocol based on the IEEE 802.15.4 standard), 3G transceivers, 4G transceivers, and / or 5G transceivers, etc.

[0105] The working process, working details and technical effects of the device provided in the third aspect of this embodiment can be found in the first aspect of the embodiment, and will not be repeated here.

[0106] This fourth aspect of the embodiment provides a computer-readable storage medium storing instructions containing the line drawing method described in the first aspect of the embodiment. Specifically, the computer-readable storage medium stores instructions that, when executed on a computer, perform the line drawing method as described in the first aspect. The computer-readable storage medium refers to a data storage medium, which may include, but is not limited to, floppy disks, optical disks, hard disks, flash memory, USB flash drives, and / or Memory Sticks. The computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices.

[0107] The working process, working details and technical effects of the computer-readable storage medium provided in the fourth aspect of this embodiment can be found in the first aspect of the embodiment, and will not be repeated here.

[0108] The fifth aspect of this embodiment provides a computer program product containing instructions that, when executed on a computer, cause the computer to perform the line drawing method as described in the first aspect of the embodiment, wherein the computer may be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device.

[0109] The embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.

[0110] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., including several instructions to cause a repository code merging device to execute the methods described in various embodiments or some parts of the embodiments.

[0111] Finally, it should be noted that the above description is merely a preferred embodiment of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.

Claims

1. A line drawing method characterized by, The method comprises: in response to a single-finger touch operation of a user on a drawing board, obtaining a starting point coordinate of a line to be drawn; creating a target line instance object, initializing a target coordinate array corresponding to the target line instance object, and storing the starting point coordinate in the target coordinate array, the target line instance object recording a line width of the line to be drawn and a pattern array used for drawing the line, the pattern array comprising a picture data sequence composed of picture data of at least one picture; storing the target line instance object in a line to be drawn array, the line to be drawn array being used to record line instance objects corresponding to all lines to be drawn; setting a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and determining, based on the index of each coordinate in the coordinate array of the target line instance object, the index of the picture data in the pattern array corresponding to each coordinate in the coordinate array of the target line instance object; in response to a single-finger sliding operation of a user on the drawing board, obtaining a latest sliding coordinate on the drawing board in real time; when the distance between the latest sliding coordinate and the most recently stored coordinate in the target coordinate array is greater than a preset threshold, storing the latest sliding coordinate in the target coordinate array; traversing all coordinate arrays in the line to be drawn array to determine a plurality of views corresponding to the coordinates in all coordinate arrays, the view being used to display corresponding picture data in the pattern array at a corresponding coordinate position on the drawing board; if there is a target view not added to the drawing board in the plurality of views corresponding to the coordinates in all coordinate arrays, determining a target coordinate corresponding to the target view, and determining a target picture data corresponding to the target coordinate based on the index of the target coordinate, adding the target view to the drawing board after taking the target coordinate as the vertex coordinate of the target view and displaying the target picture data in the target view.

2. The line drawing method according to claim 1, wherein Before obtaining the starting point coordinate of the line to be drawn in response to the single-finger touch operation of the user on the drawing board, the method further comprises: initializing the line to be drawn array and a canceled line array, the canceled line array being used to record line instance objects corresponding to all canceled lines; in response to a setting operation of the user, setting the line width of the line to be drawn and the pattern array used for drawing the line.

3. The line drawing method according to claim 2, wherein The unique identifier corresponding to the target line instance object is paths.count+cancelPaths.count, wherein paths.count represents the number of line instance objects stored in the line to be drawn array except the target line instance object, and cancelPaths.count represents the number of canceled line instance objects recorded in the canceled line array.

4. The line drawing method according to claim 3, wherein The index of any coordinate in a certain coordinate array is tag1*100000+tag2, wherein tag2 is the position of the any coordinate in the certain coordinate array, and tag1 is the unique identifier of the line instance object corresponding to the certain coordinate array. The index of the picture data in the pattern array corresponding to any coordinate in the coordinate array is index%images.count, where index is the total number of picture data in the pattern array, and images.count is the index of any coordinate in the coordinate array.

5. The line drawing method according to claim 2, wherein The method further comprises: in response to a user-initiated line undo operation, determining whether the number of line instance objects in the array of lines to be drawn is greater than 0; if the number of line instance objects in the array of lines to be drawn is greater than 0, adding the latest recorded line instance object in the array of lines to be drawn to the array of undone lines, and deleting the latest recorded line instance object in the array of lines to be drawn, so as to redraw the recorded line instance objects in the array of lines to be drawn.

6. The line drawing method according to claim 2, wherein The method further comprises: in response to a user-initiated line undo operation, determining whether the number of line instance objects in the array of lines to be drawn is greater than 0; if the number of line instance objects in the array of lines to be drawn is greater than 0, adding the latest recorded line instance object in the array of lines to be drawn to the array of undone lines, and deleting the latest recorded line instance object in the array of lines to be drawn, so as to redraw the recorded line instance objects in the array of lines to be drawn.

7. The line drawing method of claim 1, wherein, a distance between the latest sliding passed coordinate and the most recently stored coordinate in the target coordinate array wherein x2-x1 represents a coordinate difference in the x-axis direction between the latest sliding passed coordinate and the most recently stored coordinate in the target coordinate array in the plane coordinate system, and y2-y1 represents a coordinate difference in the y-axis direction between the latest sliding passed coordinate and the most recently stored coordinate in the target coordinate array in the plane coordinate system.

8. A line drawing device characterized by comprising: comprises: an acquisition unit configured to acquire a starting point coordinate of a line to be drawn in response to a single-finger touch operation of a user on a drawing board; an initialization unit configured to create a target line instance object, initialize a target coordinate array corresponding to the target line instance object, and store the starting point coordinate in the target coordinate array, the target line instance object recording a line width of the line to be drawn and a pattern array used for drawing the line, the pattern array comprising a picture data sequence composed of picture data of at least one picture; a storage unit configured to store the target line instance object in an array of lines to be drawn, the array of lines to be drawn being used to record line instance objects corresponding to all lines to be drawn; a determination unit configured to set a unique identifier corresponding to the target line instance object as an attribute of the target line instance object, and determine, based on indices of coordinates in the coordinate array of the target line instance object, indices of picture data in the pattern array corresponding to the coordinates in the coordinate array of the target line instance object; the acquisition unit is further configured to acquire, in real time, a latest coordinate slid through on the drawing board in response to a single-finger sliding operation of the user on the drawing board; the storage unit is further configured to store the latest coordinate slid through in the target coordinate array when a distance between the latest coordinate slid through and a most recently stored coordinate in the target coordinate array is greater than a preset threshold; the determination unit is further configured to traverse all coordinate arrays in the array of lines to be drawn, and determine a plurality of views corresponding to the coordinates in all the coordinate arrays, the views being used to display corresponding picture data in the pattern array at corresponding coordinate positions on the drawing board. A judging unit is configured to judge whether a target view corresponding to a coordinate in all coordinate arrays exists in multiple views and is not added to a palette; The determining unit is further configured to determine a target coordinate corresponding to the target view if the target view corresponding to the coordinate in all coordinate arrays exists in the multiple views and is not added to the palette, and determine target picture data corresponding to the target coordinate based on an index of the target coordinate; A display unit is configured to add the target view to the palette after taking the target coordinate as a vertex coordinate of the target view and displaying the target picture data in the target view.

9. A line drawing device characterized by comprising: The application further provides a device for implementing the line drawing method, comprising a memory, a processor and a transceiver connected in sequence, wherein the memory is configured to store a computer program, the transceiver is configured to receive and send messages, and the processor is configured to read the computer program and execute the line drawing method according to any one of claims 1-7.

10. A computer-readable storage medium, characterized in that, The computer readable storage medium stores instructions, and when the instructions run on the computer, the line drawing method according to any one of claims 1-7 is executed.

Citation Information

Patent Citations

  • Map drawing method and device

    CN110956673A

  • White board line drawing method and device and readable storage medium

    CN111913644A