Monthly Archives: June 2014
awol
Currently away, doing a MOOG MIT course on Python programming, or to give it its proper title; Computer Science and Programming using Python.
emulate hand drawn line experiment 5
emulate hand drawn line experiment 4
A random line, a struggle to script in Bézier notation. Points p2 and p3 are fixed on the x axis. I can make them flexible, but it will mean the random variable must be included in the adjacent handle positions, because they are mirrors. It is easier to leave them fixe but I may try a fluid version tomorrow. Had a guts full of this for today. I am not even sure I like the result.
emulate hand drawn line experiment 3
The principle is established points 1 and 2, together with control points 1, 2 and 3 have random elements added with control 3, mirroring control 2. Strictly speaking control 3 is control 1 of segment 2; so I should have said points; po, p1, and p2 and controls p1_ctrl1, p1_ctrl_2 and p2_ctrl_1. The random range has been exaggerated to make the variants more visible. I know have to re-write the code for p1, p1_ctrl_2, and p2 ctrl_1 such that the take the same random value applied to p1. Although this may not be strictly necessary, it will ensure any random values added to the controls are based on this value. This probably means a re-write so that all the base values are in relative values. In addition, I have to free the handles from so that the may alternate above or below the imaginary x axis.
emulate hand drawn line experiment 2
There is an issue to resolve regarding declaring values, calling and applying the random function. I have written a function to return the coordinate values for points at intervals of 1/3 and 2/3. These must be defined before applying the random call. E.g. line(x1, y1, x2, y2) becomes line(x1, y1, x2, y2), line(x2, y2, x3, y3), line(x3, y3, x4, y4). So, rather than simply return the interval coordinates, we might return the original coordinates together with the intervals.
In the above (left), the ctrl points used are the same as the start/end points for each segment. I shall need to take a closer more detailed look, at how setting a separate random call for each control points affects the output. To avoid ‘kinks’ the ctrl pts may need to be mirrored.
The above, illustrate a rhythm, and a relationship between the x and y values used for each control and the resulting deformation. A random value adjustment to the x, y point must be added to its corresponding ctrl, together with any random ctrl value. Where one Bézier segment joins another, the random x, y adjustments must be reversed (*-1).
In addition, I may decide to randomise the line segment lengths.
emulate hand drawn line experiment 1
This is the first test (v2.0). The red line and markers represent a straight line segment and the end points, standard, against which the line segment drawn with Bézier curve segment may be compared. The Bézier segment, uses random calls ±2.0 for x1, y1, ctrl1.x, ctrl1.y, x2, y2, ctrl2.x ctrl2.y.
The next test may be to divide the line(s) into three sections, and to apply the same random calls to the points and control points.
hachures
A function that fills rectangles with hachures. The hachure colour and strokewidth may be set from the function call independently of the stroke and/or fill state settings. There is a conflict of sorts, where the hachure strokes are drawn over the outline stoke. I have a work around, which I do not like as it requires a rect to be drawn twice. However, a refinement means drawing it once with no fill and once with no stroke.
Although this works fine, it does not offer a solution to the problem set, which is to emulate hand drawn hachures.