Fractal Diagram Drawing Method, Device, Storage Medium and Electronic Device

By judging the change in the number of pixels before and after the fractal iteration, the problem of fractal clarity relying on naked eye observation is solved, and scientific clarity evaluation and resource optimization are achieved.

CN120032022BActive Publication Date: 2025-07-11WUHAN POLYTECHNIC UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202510498085.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-04-21
Publication Date
2025-07-11
Estimated Expiration
2045-04-21

AI Technical Summary

Technical Problem

In the prior art, the judgment of the clarity of fractal charts depends on naked eye observation, lacks scientificity, and when the number of iterations increases, iterating still needs to continue when the clarity is no longer improved, resulting in waste of computing resources and time consumption.

Method used

By judging the change in the number of pixels before and after the fractal chart iteration, continue iteration if it changes, otherwise stop to ensure that the fractal chart achieves optimal clarity.

Benefits of technology

A more objective fractal chart clarity judgment is achieved, avoiding unnecessary waste of computing resources and time consumption.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120032022B_ABST
    Figure CN120032022B_ABST
Patent Text Reader

Abstract

The present application provides a fractal graph drawing method, apparatus, storage medium and electronic device, which relates to the field of computer graphics. Among them, the electronic device iterates the current basic fractal graph for a preset number of times to obtain a derivative fractal graph; determines whether the number of pixels required to display the derivative fractal graph will change compared with the current basic fractal graph; if it will change, then uses the derivative fractal graph as the new basic fractal graph and returns to the step of iterating the current basic fractal graph for a preset number of times to obtain the derivative fractal graph; if it will not change, then uses the derivative fractal graph as the target fractal graph. In this way, by judging whether the number of pixels before and after iteration changes, it is judged whether the fractal graph reaches the best clarity. Compared with visual observation, the clarity of the fractal graph can be judged more objectively.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of computer graphics, and more particularly, to a method, apparatus, storage medium, and electronic device for fractal graph drawing. Background Art

[0002] A fractal graph is a graph generated by an iterative algorithm in mathematics. In the process of generating a fractal graph, by repeatedly applying simple rules or formulas, each iteration adds details on the basis of the previous one, thus creating a complex pattern with self-similar characteristics. These patterns can see a structure similar to the whole when any part is magnified.

[0003] In order to draw a clearer fractal graph, more function iterations are usually required. In theory, the more iterations, the higher the clarity of the fractal graph. However, at present, the judgment of the clarity of the fractal graph mainly depends on visual observation, which is obviously lacking in scientificity. Specifically, two fractal graphs that seemingly have the same clarity may actually have significant differences. Summary of the Invention

[0004] In order to overcome at least one deficiency in the prior art, this application provides a method, apparatus, storage medium, and electronic device for fractal graph drawing, specifically including:

[0005] In a first aspect, this application provides a method for fractal graph drawing, the method including:

[0006] Iterate the current basic fractal graph a preset number of times to obtain a derivative fractal graph;

[0007] Judge whether the number of pixels required to display the derivative fractal graph will change compared with the current basic fractal graph;

[0008] If it will change, use the derivative fractal graph as the new basic fractal graph, and return to the step of iterating the current basic fractal graph a preset number of times to obtain a derivative fractal graph;

[0009] If it will not change, use the derivative fractal graph as the target fractal graph.

[0010] In a second aspect, this application provides a device for fractal graph drawing, the device including:

[0011] A fractal graph module, configured to iterate the current basic fractal graph a preset number of times to obtain a derivative fractal graph;

[0012] A clarity module, configured to judge whether the number of pixels required to display the derivative fractal graph will change compared with the current basic fractal graph;

[0013] The clarity module is further configured to, if a change will occur, use the derived fractal graph as a new base fractal graph and return to the step of iterating the current base fractal graph a preset number of times to obtain the derived fractal graph for execution;

[0014] The clarity module is further configured to, if no change will occur, use the derived fractal graph as the target fractal graph.

[0015] In a third aspect, the present application provides a storage medium storing a computer program, which when executed by a processor, implements the fractal graph drawing method described above.

[0016] In a fourth aspect, the present application provides an electronic device including a processor and a memory, where the memory stores a computer program, which when executed by the processor, implements the fractal graph drawing method described above.

[0017] Compared with the prior art, the present application has the following beneficial effects:

[0018] The present application provides a fractal graph drawing method, device, storage medium and electronic device. Among them, the electronic device iterates the current base fractal graph a preset number of times to obtain a derived fractal graph; determines whether the number of pixels required to display the derived fractal graph will change compared with the current base fractal graph; if a change will occur, uses the derived fractal graph as a new base fractal graph and returns to the step of iterating the current base fractal graph a preset number of times to obtain the derived fractal graph for execution; if no change will occur, uses the derived fractal graph as the target fractal graph. In this way, by judging whether the number of pixels before and after iteration changes, it can be determined whether the fractal graph reaches the best clarity. Compared with visual observation, the clarity of the fractal graph can be judged more objectively. Description of the Drawings

[0019] To more clearly illustrate the technical solutions of the embodiments of the present application, the following will briefly introduce the drawings required for the embodiments. It should be understood that the following drawings only show some embodiments of the present application, and therefore should not be regarded as limiting the scope. For those of ordinary skill in the art, other related drawings can be obtained based on these drawings without creative efforts.

[0020] Figure 1 It is a schematic flowchart of the fractal graph drawing method provided by the embodiment of the present application;

[0021] Figure 2 It is one of the schematic detailed flowcharts of the fractal graph drawing method provided by the embodiment of the present application;

[0022] Figure 3Schematic diagram II of the process details of the fractal graph drawing method provided by the embodiment of the present application;

[0023] Figure 4 The first experimental fractal graph drawn by the two-dimensional matrix memo method with different step lengths provided by the embodiment of the present application;

[0024] Figure 5 The first experimental fractal graph drawn by the binary sorting tree memo method with different step length controls provided by the embodiment of the present application;

[0025] Figure 6 The first experimental fractal graph drawn by the random iteration method with different iteration times provided by the embodiment of the present application;

[0026] Figure 7 The second experimental fractal graph drawn by the two-dimensional matrix memo method with different step lengths provided by the embodiment of the present application;

[0027] Figure 8 The second experimental fractal graph drawn by the binary sorting tree memo method with different step length controls provided by the embodiment of the present application;

[0028] Figure 9 The second experimental fractal graph of the random iteration method with different iteration times provided by the embodiment of the present application;

[0029] Figure 10 Schematic diagram of the structure of the fractal graph drawing device provided by the embodiment of the present application;

[0030] Figure 11 Schematic diagram of the structure of the electronic device provided by the embodiment of the present application. Detailed implementation manners

[0031] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. Usually, the components of the embodiments of the present application described and illustrated herein can be arranged and designed in various different configurations.

[0032] Therefore, the following detailed description of the embodiments of the present application provided in the drawings is not intended to limit the scope of the present application claimed, but merely represents selected embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present application without creative efforts fall within the scope of protection of the present application.

[0033] It should be noted that similar reference numerals and letters denote similar items in the following drawings. Therefore, once an item is defined in one drawing, it does not need to be further defined and explained in subsequent drawings.

[0034] In the description of the present application, it should be noted that the terms "first", "second", "third", etc. are only used for distinguishing descriptions and cannot be construed as indicating or implying relative importance. In addition, the terms "comprising", "including" or any other variant thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device comprising a series of elements not only includes those elements but also includes other elements not expressly listed, or also includes elements inherent to such process, method, article or device. Without further limitation, an element defined by the statement "comprising one..." does not exclude the existence of additional identical elements in the process, method, article or device comprising the said element.

[0035] Based on the above statement, as introduced in the background art, at present, the judgment of the clarity of a fractal graph mainly relies on naked-eye observation, which is obviously lack of scientificity. Specifically, in order to draw a clearer fractal graph, usually more iterative operations need to be performed, and the iterated fractal graph is displayed in real time in the drawing area of the screen. After the user feels that it is clear enough with the naked eye, the iteration is stopped. This method not only lacks scientific basis, but also the real-time display of the iterated fractal graph requires repeated drawing, which will also lead to waste of computing resources and increase in time consumption.

[0036] Based on the discovery of the above technical problems, the inventor has proposed the following technical solutions through creative labor to solve or improve the above problems. It should be noted that the defects existing in the above solutions in the prior art are the results obtained by the inventor through practice and careful research. Therefore, the process of discovering the above problems and the solutions proposed by the embodiments of the present application below for the above problems should be the contributions made by the inventor to the present application during the invention creation process and should not be construed as the technical content known to those skilled in the art.

[0037] It is found that although theoretically the more the number of iterations, the higher the clarity of the fractal graph. However, in practical applications, due to the limitation of the display resolution, when the number of iterations reaches a certain threshold, the clarity of the fractal graph will reach the limit. At this time, further increasing the number of iterations will not increase the number of pixel points or visual effect of the image. Based on the above discovery, the embodiments of the present application (hereinafter simply referred to as the present embodiments) provide a method for drawing a fractal graph. As Figure 1 shown, the method includes:

[0038] S1, iterating the current basic fractal graph a preset number of times to obtain a derivative fractal graph.

[0039] S2. Determine whether the number of pixels required to display the derivative fractal graph will change compared to the current basic fractal graph. If so, execute S3; otherwise, execute S4.

[0040] S3. Take the derivative fractal graph as the new basic fractal graph and return to step S1.

[0041] S4. Take the derivative fractal graph as the target fractal graph.

[0042] In this way, by judging whether the number of pixels before and after iteration changes, it can be determined whether the fractal graph reaches a certain clarity. Compared with visual observation, the clarity of the fractal graph can be evaluated more objectively.

[0043] In addition, it should also be understood that the electronic device implementing the fractal graph drawing method in this embodiment may be, but is not limited to, a mobile terminal, a tablet computer, a laptop computer, a desktop computer, a server, etc. The server may be a single server or a server group. The server group may be centralized or distributed (for example, the server may be a distributed system). In some embodiments, the server may be local or remote relative to the user terminal. In some embodiments, the server may be implemented on a cloud platform; by way of example only, the cloud platform may include a private cloud, a public cloud, a hybrid cloud, a community cloud, a distributed cloud, an inter-cloud, a multi-cloud, etc., or any combination thereof. In some embodiments, the server may be implemented on an electronic device having one or more components.

[0044] To make the following-described solution easier to understand, the symbols that may be used in the following of this embodiment are explained as follows:

[0045]

[0046] Next, the concepts that may be involved in this embodiment are described in detail:

[0047] IFS code. The IFS code is a set of functions used to describe and generate fractal images. Each function has a corresponding probability weight, and these weights determine the probability of selecting different transformations during each iteration. In this way, the generation process and the final form of the fractal image can be precisely controlled. For example, when generating the famous Barnsley fern fractal, the IFS code usually contains four affine transformations, each with a different probability weight. Through specific combinations of parameters, these transformations can generate a very realistic fern pattern. In practical applications, the IFS code first defines the mathematical expressions of these transformations, and then through programming, the iterative application of these transformations is realized. During each iteration, one of the transformations is selected and applied to the current point to generate a new point. These new points gradually accumulate and finally present a complete fractal pattern.

[0048] The random iteration method is an important method for generating fractal images. Its core lies in the definition and application of the IFS code. The IFS code contains a set of affine transformation functions, and each function is equipped with a corresponding probability value. These probability values determine the possibility of selecting a certain transformation function during each iteration. Specifically, during each iteration, the electronic device will randomly select a transformation function from the IFS code according to these probability values and apply it to the current point to generate a new point. By continuously repeating this process, these new points gradually accumulate and finally present a complete fractal pattern. Taking the classic Barnsley fern as an example, its IFS code usually contains four affine transformation functions, each with a different probability weight. These transformation functions cooperate with each other through specific mathematical parameters (such as translation, rotation, and scaling) to gradually generate details such as the main stem, side branches, and leaves of the fern, and finally form a highly realistic fern shape.

[0049] The fractal points on the fractal image refer to the points generated based on the Iterated Function System (IFS) and are used to jointly form the complex original fractal image. These fractal points are located on a virtual two-dimensional plane, generated through multiple iterations, and finally presented on the screen. It can be understood as the original fractal image, whose clarity is greater than or equal to the fractal image displayed on the screen.

[0050] The fractal points in the drawing area refer to the fractal image pixels that are actually drawn in the user-specified drawing window after scaling and translation of the original fractal image. When generating a fractal image, the original fractal image may be very large or have infinite details, so it is necessary to map it to a specific sub-region, that is, the drawing area, through scaling and translation operations. This drawing area is determined according to the user's window settings to ensure that the fractal image can be adapted and clearly displayed in the limited screen space.

[0051] A point on a two-dimensional matrix refers to a point stored in computer memory for recording the drawing state. Essentially, a two-dimensional matrix is a two-dimensional array, and each element represents a pixel point in the drawing area. If the value of the element is 1, it means that the pixel point has been used; if it is 0, it means that it has not been used. The points on the two-dimensional matrix correspond one-to-one with the points in the drawing area, but are located in computer memory and can be used to improve the drawing speed and avoid repeated drawing.

[0052] Based on the above description, taking a desktop computer as the electronic device for implementing the fractal graph drawing method below, Figure 1 each step in it will be elaborated in detail. However, it should be understood that the operations in the flowchart can be implemented out of order, and steps without a logical context relationship can be reversed or implemented simultaneously. In addition, those skilled in the art can add one or more other operations to the flowchart or remove one or more operations from the flowchart under the guidance of the content of this application. Continuing to refer to Figure 1 , the method includes:

[0053] S1, Iterate the current basic fractal graph a preset number of times to obtain a derivative fractal graph.

[0054] It should be understood that the preset number of times can be 1 time or multiple times, and in this embodiment, it is called a step size. It can be understood that within each step size, the basic fractal graph will be iterated a preset number of times. For example, assuming the preset number of times is 100 times, 10 step sizes mean 100 * 10 = 1000 iterations have been performed.

[0055] Since the generation of a fractal graph is usually based on a simple initial graph or rule, and by repeatedly iterating this rule, more complex patterns are gradually generated. Therefore, the more iterations, the richer the details of the fractal graph. In this embodiment, for each step size, the fractal graph to be iterated is called the basic fractal graph, and the fractal graph iterated through one step size is called the derivative fractal graph. It can be understood that the basic fractal graph can be the fractal graph in the initial stage or the fractal graph iterated through a certain step size. After each iteration of a step size, the basic fractal graph will change.

[0056] In addition, within each step size, each iteration means generating new pixel points and geometric forms through specific mathematical rules and an Iterated Function System (IFS), thereby forming a new fractal graph.

[0057] It should also be understood that the derivative fractal graph can be obtained by growing from the current basic fractal graph, that is, the growth iteration drawing method. It can be understood that the growth iteration method constructs the fractal graph by gradually adding pixel points, usually starting from a simple initial shape, and by continuously applying transformation rules to increase details and complexity until the desired fractal structure is reached.

[0058] S2, determine whether the number of pixels required to display the derived fractal graph will change compared to the current base fractal graph.

[0059] If so, execute S3; otherwise, execute S4.

[0060] S3, use the derived fractal graph as the new base fractal graph and return to step S1.

[0061] S4, use the derived fractal graph as the target fractal graph.

[0062] It can be understood that as the number of iterations increases, the fractal graph becomes clearer, and the number of pixels required for display also increases synchronously. When a certain critical point is reached, the number of newly added pixels becomes extremely small and can even be ignored, indicating that the clarity of the fractal graph has reached the limit that the screen can display. Therefore, further iteration will not significantly increase the number of new pixels, ultimately resulting in no increase in the number of pixels in the drawing area.

[0063] Therefore, through the above implementation, in each iteration with a step size, if it is found that the pixels for displaying the current derived fractal graph no longer change, at this time, the derived fractal graph is recognized as the target fractal graph and the iteration stops. In this way, it is ensured that the fractal graph stops iterating when it reaches the optimal complexity, avoiding unnecessary waste of computing resources and ensuring the quality of the final fractal graph.

[0064] The above implementation introduces the principle of the growth iteration drawing method. As Figure 2 shown, when the derived fractal graph is obtained by growing from the current base fractal graph, Figure 1 step S2 in

[0065] can include:

[0066] S2-1, obtain the newly added fractal points generated by the derived fractal graph.

[0067] where the newly added fractal points represent the different parts between the derived fractal graph and the previous base fractal graph after one step of iteration.

[0068] S2-2, determine the target positions of the newly added fractal points in the memo.

[0069] As an alternative embodiment, the desktop computer can obtain the first mapping relationship between the derivative fractal graph and the two-dimensional matrix; use the first mapping relationship to map the position of the newly added fractal point in the derivative fractal graph to the array position in the two-dimensional matrix; and determine the array position as the target position of the newly added fractal point in the memorandum.

[0070] It can be understood that this memorandum actually implements a two-dimensional matrix through a two-dimensional array in the memory, and the usage statistics of each pixel point in the drawing area are recorded in the array. For example, when a pixel has been used, the corresponding position in the two-dimensional matrix is marked as 1, and conversely, it is marked as 0. By querying and updating this two-dimensional array, when drawing a fractal graph in the drawing area subsequently, each pixel point is drawn only once, thereby improving the drawing efficiency of the fractal graph.

[0071] It should also be understood that before querying the memorandum, it is necessary to map the newly added fractal points to the two-dimensional matrix. Therefore, it is necessary to obtain the mapping relationship between them, which is referred to as the first mapping relationship in this embodiment.

[0072] In this regard, in this embodiment, the desktop computer can first generate an exploration fractal graph, where the number of iterations of the exploration fractal graph is less than the number of iterations required to obtain the target fractal graph; obtain the scaling factor according to the size of the exploration fractal graph and the size of the drawing area; and obtain the first mapping relationship according to the scaling factor. The first mapping relationship is used to map the fractal points in the fractal graph to the two-dimensional matrix. In addition, the second mapping relationship can also be obtained through the scaling factor, and the second mapping relationship is used to map the fractal points in the fractal graph to the drawing area.

[0073] In this way, before formally performing iterations, this embodiment can first perform a small number of iterations to obtain the initial position of the fractal graph and the drawing area, thereby optimizing the subsequent calculation and drawing processes.

[0074] Exemplarily, the desktop computer first detects the width and height of the drawing window. As part of the drawing window, the drawing area cannot exceed the drawing window. If the user wants to draw a fractal graph in a rectangular area with a width of and a height of , then the initial space of this drawing area is represented as:

[0075]

[0076] The th iteration function in the fractal iteration function system is expressed as follows:

[0077] , ,

[0078] If the probability is set, then the iterative probability interval of the th function in the iterative function set of the fractal graph is calculated as follows:

[0079] ,

[0080] Therefore, if the point on the fractal graph is known, then the next point is determined by the following piecewise function:

[0081]

[0082] Considering that the fractal graph grows continuously in a specific direction during the iterative process, and different types of fractal graphs have different growth directions. Therefore, it is necessary to first obtain the approximate display range of the fractal graph in the drawing area. In addition, during the drawing process of the fractal graph, the selection of the initial point is very important. The initial point determines the direction of subsequent iterations and the distribution of the graph. Therefore, a reasonable initial point can help generate a more uniform and representative fractal graph. For this purpose, first set , and then the desktop computer randomly iterates 20 times using the above iterative formula to obtain the new initial point , and . With this new initial point, conditions are created for the subsequent estimation of the drawing area and the drawing of the fractal graph.

[0083] To obtain the , , and of the drawing area, it is possible to continue randomly iterating 500 times on the basis of the new initial point . In this way, the plane coordinates of each fractal point on the fractal graph in the drawing area are obtained. It can be understood that 500 times is a relatively reasonable number of iterations obtained after a large number of experiments. Of course, technicians can make appropriate adjustments when implementing this solution.

[0084] After iteration by the fractal iteration function system, the maximum value of the abscissa of the pixel point is calculated as follows:

[0085]

[0086] After iteration by the fractal iteration function system, the minimum value of the abscissa of the pixel point is calculated as follows:

[0087]

[0088] After iteration by the fractal iteration function system, the maximum value of the ordinate of the pixel point is calculated as follows:

[0089]

[0090] After iteration by the fractal iteration function system, the minimum value of the ordinate of the pixel point is calculated as follows:

[0091]

[0092] It should be noted that although the larger the number of iterations, the more accurate the obtained drawing area, the longer the time spent. Therefore, it is reasonable to set the number of iterations to 500. Of course, the inventors implementing this application can make adaptive adjustments to the number of iterations.

[0093] With the maximum value of the abscissa of the pixel point and the minimum value , the scaling factor of the abscissa in the drawing area can be obtained is calculated as follows:

[0094]

[0095] With the maximum value of the ordinate of the pixel point and the minimum value , the scaling ratio factor of the ordinate in the drawing area can be obtained is calculated as follows:

[0096]

[0097] To ensure that the fractal image has the same aspect ratio, the scaling factor of the image is calculated as follows:

[0098]

[0099] The width of the drawing area and the height are recalculated as follows:

[0100]

[0101] To center the fractal image horizontally in the drawing window, the abscissa offset of the points on the fractal image is calculated as follows:

[0102]

[0103] To center the fractal image vertically in the drawing window, the ordinate offset of the points on the fractal image The calculation is as follows:

[0104]

[0105] Fractal points on the fractal graph The abscissa in the two-dimensional matrix can be obtained by using the following first mapping relationship and :

[0106]

[0107] And the fractal points on the fractal graph The abscissa in the drawing area can be obtained by using the following second mapping relationship and the ordinate , so as to display the fractal point at the corresponding position in the drawing area:

[0108]

[0109]

[0110] Based on the above example, a new initial point, the first mapping relationship, and the second mapping relationship are obtained. After initializing the representing the number of iterations to 0, the desktop computer starts the iteration from the beginning to obtain the desired fractal graph.

[0111] In this way, a two-dimensional matrix with the same size as the drawing area is used to count whether each pixel point has been used. Whenever the desktop computer tries to draw a new pixel point, it will check the corresponding array position. If the array position has been marked as 1 (indicating that the pixel point has been used), then the desktop computer will skip this statistical operation. On the contrary, if the array position is not marked, the desktop computer will draw this pixel point and mark it as 1 at the corresponding two-dimensional matrix position. This method ensures that each pixel point is drawn only once, avoiding the additional overhead caused by repeated drawing.

[0112] In other alternative embodiments, it is found in the practice process that when drawing a large fractal graph, the two-dimensional matrix needs to occupy a large amount of continuous memory space. If the memory management system cannot provide a large enough continuous memory block, it will be impossible to count which pixels have been used through the two-dimensional matrix.

[0113] In this regard, the memo can also be a binary tree converted from a two-dimensional matrix with the same size as the drawing area. The desktop computer can map the position of the newly added fractal point in the derived fractal graph to the two-dimensional matrix to obtain the array position of the newly added fractal point in the two-dimensional matrix; convert the array position into the index value of the binary tree; and determine the index value as the target position of the newly added fractal point in the memo.

[0114] Exemplarily, the data structure of a binary tree can be defined as struct node{int key;struct node *lchild,*rchild}. From the data structure, it is not difficult to see that each node contains an integer key "key", and pointers to the left child node "lchild" and the right child node "rchild". Thus, this structure allows for efficient insertion and search of data through binary search.

[0115] According to the indexing principle of the binary tree, the indexing of the binary tree requires an index value. In this embodiment, the desktop computer can use the length or width of the drawing area as the weight; the coordinate values of the array positions are weighted according to the weight to obtain the index value of the binary tree.

[0116] Exemplarily, assume that the array position is represented as , the length of the drawing area is represented by , and the height of the drawing area is represented by , then the index value can be calculated by the following expression:

[0117]

[0118] Or

[0119]

[0120] Based on the above description of the drawing method of the derivative fractal graph, continue to refer to Figure 2 , step S2 further includes:

[0121] S2-3. Determine whether the record of the target position being marked as used. If not, it means that the number of pixels required to display the derivative fractal graph will change, so execute S3; otherwise, it means that the number of pixels required to display the derivative fractal graph will not change, so execute S4.

[0122] In this regard, the desktop computer can use a memo to count the pixel points that have been used by the fractal points in the fractal graph, so that the memo can be used to detect whether the addition of new fractal points will cause a change in the number of pixels required to display the derivative fractal graph. In addition, each pixel point can be drawn only once, thereby improving the drawing efficiency of the fractal graph.

[0123] It should also be understood that currently, when displaying the fractal graph in the drawing area of the screen, it is necessary to determine the pixel position of each fractal point on the fractal graph in the drawing area. Limited by the screen resolution, multiple fractal points in the fractal graph will be mapped to the same pixel, which means that for some pixels, they may be drawn multiple times repeatedly.

[0124] In view of this, since the memo has recorded the usage statistics of each pixel in the drawing area, therefore, as Figure 3 shown, on the basis of Figure 2 , the method further includes:

[0125] S5, display the target fractal graph in the drawing area according to the memo.

[0126] It can be understood that, according to the memo, determine which places in the memo are marked with used records, and then draw at the corresponding pixel positions. In this way, when displaying the target fractal graph in the drawing area, only each pixel needs to be drawn once. Since the number of repeated drawing operations is reduced, the drawing efficiency can be significantly improved.

[0127] In order to verify the technical effect of the fractal graph drawing method provided in this embodiment, the initial drawing area is set to pixels. The actual drawing area is calculated according to the width-to-height ratio factor of the fractal graph, which means that different fractal graphs will have their own unique drawing areas due to different ratio factors. At the same time, in order to ensure that the same random probability sequence is generated by different methods, the random seed is fixed at 100 in this test.

[0128] In order to better display the drawing effects of the two-dimensional matrix memo method and the binary sorting tree memo method, four parameters are selected to correspond to a fractal drawing result. These four parameters are: step size, random iteration times, number of pixel points, and drawing time. In this regard, as Figure 5 shown, (10, 8010, 6344, 0.082) corresponding to the first pattern in the figure respectively represent the step size, random iteration times, number of pixel points, and drawing time. Except that the step size is input by the user, other parameters are automatically counted by the desktop computer. This parameter setting can not only intuitively reflect the advantages and disadvantages of different methods, but also provide basic data for subsequent performance analysis.

[0129] In order to compare the drawing speed with the original random iteration method, the parameter settings of the original random iteration method are selected as two parameters, which are: random iteration times and drawing time. In this regard, as Figure 5 shown, (3670, 0.04) corresponding to the first pattern in the figure respectively represent the random iteration times and drawing time. In this case, the random iteration times are input by the user, and the drawing time is calculated and recorded by the desktop computer in real time. This design can clearly evaluate the differences in drawing speed and effect between the two methods. Through the above settings, various fractal graphs are used for verification. The fractal graphs used for verification here are called experimental fractal graphs.

[0130] (1) The IFS codes of the first experimental fractal graph are shown in the following table:

[0131]

[0132] For the above experimental fractal diagrams, as Figure 4 shown, the figure shows the fractal diagrams drawn by the two-dimensional matrix memo method at different step lengths.

[0133] As Figure 5 shown, the figure shows the fractal diagrams drawn by the binary sort tree memo method under different step length controls.

[0134] As Figure 6 shown, the figure shows the fractal diagrams drawn by the random iteration method at different numbers of iterations.

[0135] From Figure 4 , Figure 5 and Figure 6 it is not difficult to see that when the number of random iterations is the same, the drawing times of each drawing method are as shown in the following table:

[0136]

[0137] (2) The IFS codes of the second type of experimental fractal diagram are as shown in the following table:

[0138]

[0139] As Figure 7 shown, the figure shows the fractal diagrams drawn by the two-dimensional matrix memo method at different step lengths.

[0140] As Figure 8 shown, the figure shows the fractal diagrams drawn by the binary sort tree memo method under different step length controls.

[0141] As Figure 9 shown, the figure shows the fractal diagram drawing of the random iteration method at different numbers of iterations.

[0142] From Figure 7 , Figure 8 and Figure 9 it is not difficult to see that when using three different methods to draw the second type of experimental fractal diagram, the times of the three drawing methods under the same clarity are as shown in the following table:

[0143]

[0144] It is not difficult to see from the experimental results that with the increase of the step length, both the designed two-dimensional matrix memo method and the binary sort tree method have significantly improved in the speed of fractal drawing. Therefore, these two methods have good performance in optimizing the algorithm efficiency.

[0145] It is important to note that these three methods use the same random seed, which means that they will produce the same random sequence in the random number generation process. This consistency results in the same random probability sequence generated under the same number of random iterations. Therefore, the drawn fractal images also maintain consistency in clarity and detail. This feature is of great significance for studying and comparing the effects of different algorithms, because it eliminates the interference caused by randomness, making the results more comparable and reliable.

[0146] Based on the same inventive concept as the fractal image drawing method provided in this embodiment, this embodiment also provides a fractal image drawing device, which includes at least one software function module that can be stored in the memory 21 or fixed in the electronic device in the form of software. The processor in the electronic device is used to execute the executable module stored in the memory 21. For example, the software function module and computer program included in the device. Please refer to Figure 10 , functionally speaking, the device may include:

[0147] The fractal graph module 11 is used to iterate the current basic fractal graph for a preset number of times to obtain a derived fractal graph;

[0148] A clarity module 12, used to obtain a first number of pixels required for displaying the derived fractal image;

[0149] The clarity module 12 is further configured to use the derived fractal image as a new basic fractal image if the second number of pixels required to display the basic fractal image is less than the first number of pixels, and return to the step of iterating the current basic fractal image a preset number of times to obtain the derived fractal image;

[0150] The clarity module 12 is further configured to use the derived fractal image as the target fractal image if the second number of pixels is equal to the first number of pixels.

[0151] In this embodiment, the fractal image module 11 is used to implement Figure 1 In step S1, the definition module 12 is used to implement Figure 1 Therefore, for the detailed description of each of the above steps, please refer to the specific implementation of the corresponding step, and this implementation will not be repeated.

[0152] In addition, since the invention concept is the same as that of the fractal image drawing method, the fractal image drawing device can also implement other steps or sub-steps of the method through the above modules.

[0153] Optionally, the clarity module 12 is further specifically configured to:

[0154] Get the newly added fractal points from the basic fractal image to the derived fractal image;

[0155] If no record indicating that the fractal points have been displayed is found in the memorandum, the fractal points are displayed in the drawing area of the screen, where the memorandum records the fractal points for which the basic fractal graph has been displayed;

[0156] Based on the display pattern of the derivative fractal graph in the drawing area, obtain the number of first pixels required to display the derivative fractal graph.

[0157] Optionally, the memorandum is a two-dimensional matrix with the same size as the drawing area, and the clarity module 12 is further specifically configured to:

[0158] Map the fractal points into the two-dimensional matrix to obtain the array positions of the fractal points in the two-dimensional matrix;

[0159] If no preset display mark is recorded at the array positions, it is determined that no record indicating that the fractal points have been displayed is found.

[0160] Optionally, the clarity module 12 is further specifically configured to:

[0161] Map the fractal points into the two-dimensional matrix by using the first mapping relationship to obtain the array positions of the fractal points in the two-dimensional matrix.

[0162] Optionally, the clarity module 12 is further specifically configured to:

[0163] Generate an exploratory fractal graph, where the number of iterations of the exploratory fractal graph is less than the number of generations required to obtain the target fractal graph;

[0164] Based on the size of the exploratory fractal graph and the size of the drawing area, obtain a scaling factor;

[0165] Based on the scaling factor, obtain the first mapping relationship.

[0166] Optionally, the memorandum is a binary tree converted from a two-dimensional matrix with the same size as the drawing area, and the clarity module 12 is further specifically configured to:

[0167] Map the fractal points into the two-dimensional matrix to obtain the array positions of the fractal points in the two-dimensional matrix;

[0168] Convert the array positions into index values of the binary tree;

[0169] If the fractal points cannot be found in the binary tree through the index values, it is determined that no record indicating that the fractal points have been displayed is found.

[0170] Optionally, when converting the array positions into index values of the binary tree, the clarity module 12 is further specifically configured to:

[0171] Use the length or width of the drawing area as a weight;

[0172] According to the weight, weight the coordinate values of the array positions to obtain the index values of the binary tree.

[0173] Optionally, the clarity module is further configured to:

[0174] display the target fractal graph in the drawing area according to the memorandum.

[0175] In addition, each functional module in various embodiments of the present application may be integrated together to form an independent part, or each module may exist alone, or two or more modules may be integrated to form an independent part.

[0176] It should also be understood that if the above implementation manner is implemented in the form of a software functional module and sold or used as an independent product, it may be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, in essence, or the part that contributes to the prior art, or a part of this technical solution, may be embodied in the form of a software product. This computer software product 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, etc.) to execute all or part of the steps of the methods described in various embodiments of the present application.

[0177] Therefore, this embodiment also provides a storage medium, which is a computer-readable storage medium. This storage medium stores a computer program, and when the computer program is executed by a processor, it implements the fractal graph drawing method provided in this embodiment. Among them, the storage medium may be various media such as a USB flash drive, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk, or an optical disc that can store program codes.

[0178] An electronic device for implementing the fractal graph drawing method provided in this embodiment. As Figure 11 shown, the electronic device may include a processor 22 and a memory 21. Moreover, the memory 21 stores a computer program, and the processor realizes the fractal graph drawing method provided in this embodiment by reading and executing the computer program corresponding to the above implementation manner in the memory 21.

[0179] Continuing to refer to Figure 11 , the electronic device further includes a communication unit 23. Each element of the memory 21, the processor 22, and the communication unit 23 is directly or indirectly electrically connected through a system bus 24 to realize data transmission or interaction.

[0180] Among them, the memory 21 can be an information recording device based on any electronic, magnetic, optical or other physical principles, and is used to record execution instructions, data, etc. In some embodiments, the memory 21 can be, but is not limited to, a volatile memory, a non-volatile memory, a storage drive, etc.

[0181] In some embodiments, the volatile memory can be a Random Access Memory (RAM); in some embodiments, the non-volatile memory can be a Read Only Memory (ROM), a Programmable Read-Only Memory (PROM), an Erasable Programmable Read-Only Memory (EPROM), an Electric Erasable Programmable Read-Only Memory (EEPROM), a flash memory, etc.; in some embodiments, the storage drive can be a disk drive, a solid state drive, any type of storage disk (such as an optical disk, a DVD, etc.), or a similar storage medium, or a combination thereof, etc.

[0182] The communication unit 23 is used to transmit and receive data through a network. In some embodiments, the network can include a wired network, a wireless network, an optical fiber network, a telecommunication network, an intranet, the Internet, a Local Area Network (LAN), a Wide Area Network (WAN), a Wireless Local Area Networks (WLAN), a Metropolitan Area Network (MAN), a Wide Area Network (WAN), a Public Switched Telephone Network (PSTN), a Bluetooth network, a ZigBee network, or a Near Field Communication (NFC) network, etc., or any combination thereof. In some embodiments, the network can include one or more network access points. For example, the network can include a wired or wireless network access point, such as a base station and / or a network switching node, and one or more components of the service request processing system can be connected to the network through the access point to exchange data and / or information.

[0183] The processor 22 may be an integrated circuit chip with signal processing capabilities, and the processor may include one or more processing cores (e.g., a single-core processor or a multi-core processor). By way of example only, the above-mentioned processor may include a Central Processing Unit (CPU), an Application Specific Integrated Circuit (ASIC), an Application Specific Instruction-set Processor (ASIP), a Graphics Processing Unit (GPU), a Physics Processing Unit (PPU), a Digital Signal Processor (DSP), a Field Programmable Gate Array (FPGA), a Programmable Logic Device (PLD), a controller, a microcontroller unit, a Reduced Instruction Set Computing (RISC), or a microprocessor, etc., or any combination thereof.

[0184] It can be understood that Figure 11 The structure shown is only illustrative. The electronic device may also have more or fewer components than Figure 11 shown, or have a different configuration from Figure 11 that shown. Figure 11 Each of the components shown may be implemented in hardware, software, or a combination thereof.

[0185] It should be understood that the devices and methods disclosed in the above embodiments can also be implemented in other ways. The device embodiments described above are merely illustrative. For example, the flowcharts and block diagrams in the accompanying drawings show the possible architectures, functions, and operations of devices, methods, and computer program products according to multiple embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a program segment, or a part of code, and the module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than that marked in the accompanying drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and the combination of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.

[0186] As described above, these are only various embodiments of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art within the technical scope disclosed in the present application can easily think of changes or substitutions, which should all be covered within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.

Claims

1. A method for drawing a fractal graph, characterized in that, The method includes: Iterating the current base fractal graph a preset number of times to obtain a derived fractal graph, where the derived fractal graph is obtained by growing the current base fractal graph; Determining whether the number of pixels required to display the derived fractal graph will change compared to the current base fractal graph, including: Obtaining the newly generated fractal points of the derived fractal graph; Determining the target position of the newly generated fractal points in the memo, where the memo is used to record the usage statistics of each pixel in the drawing area; If the target position is not marked as a used record, it is determined that the number of pixels required to display the derived fractal graph will change; If the target position is marked as a used record, it is determined that the number of pixels required to display the derived fractal graph will not change; If it will change, taking the derived fractal graph as the new base fractal graph and returning to the step of iterating the current base fractal graph a preset number of times to obtain the derived fractal graph for execution; If it will not change, taking the derived fractal graph as the target fractal graph.

2. The fractal graph drawing method according to claim 1, wherein The memo is a two-dimensional matrix of the same size as the drawing area. Determining the target position of the newly generated fractal points in the memo includes: Obtaining the first mapping relationship between the derived fractal graph and the two-dimensional matrix; Using the first mapping relationship to map the position of the newly generated fractal points in the derived fractal graph to the array position in the two-dimensional matrix; Determining the array position as the target position of the newly generated fractal points in the memo.

3. The fractal graph drawing method according to claim 2, characterized in that The obtaining the first mapping relationship between the derived fractal graph and the two-dimensional matrix: Generating an exploration fractal graph, where the number of iterations of the exploration fractal graph is less than the number of iterations required to obtain the target fractal graph; Obtaining a scaling factor according to the size of the exploration fractal graph and the size of the drawing area; Obtaining the first mapping relationship according to the scaling factor.

4. The fractal graph drawing method according to claim 1, characterized in that The memo is a binary tree converted from a two-dimensional matrix of the same size as the drawing area. Determining the target position of the newly generated fractal points in the memo includes: Mapping the position of the newly generated fractal points in the derived fractal graph to the two-dimensional matrix to obtain the array position of the newly generated fractal points in the two-dimensional matrix; Converting the array position into the index value of the binary tree; Determining the index value as the target position of the newly generated fractal points in the memo.

5. The fractal graph drawing method according to claim 4, characterized in that Converting the array position into the index value of the binary tree includes: Taking the length or width of the drawing area as the weight; Weighting the coordinate values of the array position according to the weight to obtain the index value of the binary tree.

6. The fractal graph drawing method according to claim 1, wherein The method further includes: Displaying the target fractal graph in the drawing area according to the memo.

7. A fractal graph drawing device, characterized in that, The device includes: A fractal graph module for iterating the current base fractal graph a preset number of times to obtain a derived fractal graph, where the derived fractal graph is obtained by growing the current base fractal graph; A clarity module for determining whether the number of pixels required to display the derived fractal graph will change compared to the current base fractal graph. The clarity module is further specifically used for: Obtain the newly generated fractal points produced by the derived fractal graph; Determine the target position of the newly generated fractal points in the memorandum, where the memorandum is used to record the usage statistics of each pixel in the drawing area; If the target position is not marked with a record of being used, determine that the number of pixels required to display the derived fractal graph will change; If the target position is marked with a record of being used, determine that the number of pixels required to display the derived fractal graph will not change; The clarity module is further configured to, if it will change, use the derived fractal graph as a new base fractal graph and return to the step of iterating the current base fractal graph a preset number of times to obtain the derived fractal graph; The clarity module is further configured to, if it will not change, use the derived fractal graph as the target fractal graph.

8. A storage medium, characterized in that, The storage medium stores a computer program, and when the computer program is executed by a processor, it implements the fractal graph drawing method according to any one of claims 1-6.

9. An electronic device, characterized in that, The electronic device includes a processor and a memory, the memory stores a computer program, and when the computer program is executed by the processor, it implements the fractal graph drawing method according to any one of claims 1-6.

Citation Information

Patent Citations

  • Rapid fractal graph drawing method and system, user equipment and storage medium

    CN108846883A