I am writing a program that distributes .svg's around a circle and am having a problem with a transformation i want to apply. I have simulated the problem with a triangle in the code below.
Basically i want to change the vertical scale of a shape independently of the horizontal scale and then distribute shapes evenly around a circle. When i apply the transformation the circle warps. I understand why this is happening as I am doing scale > rotate > draw but can't find a way around the issue. Have tried draw > scale > rotate which also doesn't work for obvious reasons...
I am trying to write a program which can find random points within a given shape and then draw shapes to them. Eventually, this is with a view to creating print pieces so the final resolution will be quite high.
I have written the program below which uses a black and white .jpeg (in this case a letter A) as the shape template. The program identifies black pixels in the image, stores the X and Y co-ordinates to separate arrays which i then access randomly to find points.
It works fine but quite slowly at size(300, 300). bearing in mind i am eventually aiming to output 300dpi A3 images i was wondering whether there is a more efficient way to achieve the same result.
hope this makes sense.
thanks
PImage A; int[] xPos = new int[0]; int[] yPos = new int[0];
void setup() {
size(300,300); A = loadImage("A.jpg"); A.loadPixels(); rectMode(CENTER); noLoop();
} void draw() {
for (int x= 0; x< A.width; x++) { for (int y = 0; y < A.height; y++) { if (A.pixels[(A.width*y)+x] == color(0,0,0)) { xPos = append(xPos, x); yPos = append(yPos, y); } } }
for (int i = 0; i <200; i++) { int myNum = int(random(xPos.length)); rect(xPos[myNum], yPos[myNum], 20, 20); } }
i am having a problem when trying to draw to an off-screen buffer and save as a .tiff. the code i am using is taken directly from the 'processing' book but am getting the error 'the function beginDraw() does not exist'
code:
PGraphics big;
int numWires = 3; //number of wires
void setup() {
smooth();
noLoop();
big = createGraphics(4000, 1000, JAVA2D);
beginDraw();
for (int i = 0; i < numWires; i++) {
int lineSpace = 1000/numWires;
int lineHeight = 100+(i*lineSpace)+int(random(-30, 30));