Machine generation of art patterns in vector fields

Machine generation of art patterns in vector fields

Drawing with a code: for young admirers of modern art

Is it true that physics and lyrics are far apart? Is it possible to realize artistic fantasies using soulless machines while working in software? Programmers will answer positively: when creating unique graphic patterns, we are, in fact, drawing using programming. You can create exclusive drawings by algorithms using a vector field as a tool. It is built on a grid, which is a two-dimensional array of numbers covering the image.

The “language” of computer graphics

While any man-made drawing is based on lines, dots, spots, and strokes, in vector graphics, we use paths, boundaries, and pseudocodes.

A path is the distance between elements placed next to each other. High-resolution pictures with smooth lines and details are built on small paths. You should use integer numeric values when drawing.

The grid boundaries also need to be adjusted: they must be away from the edge of the image. Before creating a drawing, you will need to write the pseudocode. This opens up the working space. Let’s take a closer look at the algorithms for generating patterns.

You can draw a line on the created grid with paths in a certain direction from the starting point. The algorithm is cyclic:

  • determine the starting point;
  • select a grid node next to each other (each node has a specific angle);
  • make a path in this direction, drawing it out.

Lines are depicted based on the following parameters: starting position coordinates, length and number of paths. To remove the pixelate effect, the paths should be small. It matters if the drawing should be as close to the original as possible. Paths within 0.1-0.5% of the image width will allow you to create a high-quality drawing. For example, children and teens often change their avatars on social networks by drawing them with a neural network. Visualizing a portrait is a painstaking task: lines should not lose direction, and curves should remain smooth.

The number of paths parameter determines the texture. For example, an animal’s fur should be drawn with short lines, and the wind-blown hair with long curves. Visually, long curves add volume to the drawing, making it appear more natural to the eye. When short lines are used, the drawing is perceived as spotty, made up of strokes, and somewhat rough.

Secrets of an IT artist

If you want to paint in color online, you must also keep some aspects in mind. In case you need to create a watercolor picture with smooth transitions, long lines are used. But short lines are used to separate colors. The mix of short and medium lines allows you to reproduce a gorgeous palette, it reduces the length of the color transition. To recreate a gradient, you should use long curves. The main thing is to choose the right starting positions by defining starting points on a regular grid, using a pack of circles, or marking a set of random x, y.

Distortion of the vector field affects the shape of the curves. To achieve the distortion two opposite directions are used.

  1. Smooth distortions: the choice of technique depends on the smoothness of the required transitions, which allows to obtain both engraved and sculptural forms.
  2. Perlin noise provides continuous values on a 2D plane. It is suitable as a simple starting tool for starting work.

Ideas for images depend only on your imagination.

  • you can set a certain distance between the curves;
  • draw with points, in the pointillism technique;
  • combine curves next to each other, filling the space between them with color;
  • distort the angle grid;
  • put the objects in the frame, thus ensuring the grid distortion.

The techniques and ideas mentioned above will be helpful when learning how to machine generate artistic patterns. Programming and creativity go hand in hand to produce incredible images, from elaborate abstractions to realistic posters or portraits. Studying online programming at IT FUTURE school, young artists can present their masterpieces to the world and make the first step towards their future profession.