Posts: 6,396
Threads: 278
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
This processing.
Code isn't too complicated
Code:
[align=left]float startAngle=0;
void setup() {
size(800,800);
colorMode(HSB,360,100,100);
}
void drawSquare(float radius,float angle,float size) {
float squareX=width/2+radius*cos(angle);
float squareY=height/2+radius*sin(angle);
pushMatrix();
translate(squareX,squareY);
rotate(angle+radians(5)); // Compensate "slope"of log spiral
rect(0,0,size,size,size/8);
popMatrix();
}
void draw() {
noStroke();
background(255);
float radius=height/2-50.;
float size=radius/10;
float squareAngle=startAngle;
float shrink=.9975;
float shiftAngle=7;
float hue=360;
float brightness=100;
while (radius > 2) {
fill(hue,80,brightness);
drawSquare(radius,radians(squareAngle),size);
radius*=shrink;
size*=shrink;
squareAngle+=shiftAngle;
hue*=shrink;
brightness*=shrink;
}
startAngle-=.5; // For animation
}
Posts: 1,538
Threads: 71
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
Posts: 6,396
Threads: 278
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
(06-22-2024, 01:19 PM)PixLab Wrote: Nice!!!
You can do animations easily, the draw() function is called repetitively (hence the last line of the code).
Posts: 6,396
Threads: 278
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
06-22-2024, 07:29 PM
(This post was last modified: 06-22-2024, 09:20 PM by Ofnuts.)
Sharing via imgur since that one is big:
Posts: 1,167
Threads: 179
Joined: Sep 2018
Reputation:
115
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
Ofnuts, that's endless nice
Posts: 6,396
Threads: 278
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
Still in my log spiral binge, now with multiple spirals:
Code:
float startAngle=0; // degrees
void setup() {
size(800, 800);
//fullScreen(2);
colorMode(HSB, 360, 100, 100);
frameRate(20);
}
void drawSquare(float radius, float angle, float size, float pitch) {
float squareX=width/2+radius*cos(angle);
float squareY=height/2+radius*sin(angle);
pushMatrix();
translate(squareX, squareY);
rotate(angle+pitch); // Compensate "slope"of log spiral
rect(0, 0, size, size, size/3);
popMatrix();
}
float angleVariation(float baseValue, float angle, float frequency, float shift) {
return baseValue+(100-baseValue)*sin(frequency*angle+shift);
}
void drawSpiral(float baseRadius, float startAngle, float shrinkRate, float stepAngle) {
float baseSize=baseRadius/20;
float baseBrightness=85;
float baseSaturation=80;
float relativeAngle=0; // Degrees
float pitch=atan(shrinkRate); // radians
while (true) {
float shrink=exp(shrinkRate*radians(relativeAngle));
float radius=baseRadius*shrink;
float size=baseSize*shrink;
float absoluteAngle=radians(startAngle+relativeAngle); // radians
if (radius < 1) break;
float hue=(startAngle+(relativeAngle*1.35))%360;
fill(hue,
angleVariation(baseSaturation, absoluteAngle, 8, radians(0)),
angleVariation(baseBrightness, absoluteAngle, 8, radians(30))
);
drawSquare(radius, radians(startAngle+relativeAngle), size, -pitch);
relativeAngle+=stepAngle;
}
}
void draw() {
noLoop();
noStroke();
background(0, 0, 100);
float baseRadius=height/2-60.;
float shrinkRate=-.1;
float stepAngle=3.123; // degrees
float startAngle=1.*(frameCount-1); // degrees, For animation
int spirals=12;
for (int i=0; i<spirals;i++) {
drawSpiral(baseRadius,startAngle+i*(360/spirals),shrinkRate,stepAngle);
}
save("/tmp/Processing.png");
}
Posts: 1,538
Threads: 71
Joined: May 2021
Reputation:
167
Operating system(s):
Gimp version: 2.10
Ohhh. that last one Yeah even better! Great programing!
Patrice
Posts: 1,167
Threads: 179
Joined: Sep 2018
Reputation:
115
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
I couldn't resist
Posts: 6,396
Threads: 278
Joined: Oct 2016
Reputation:
566
Operating system(s):
Gimp version: 3.00RC1
(06-23-2024, 04:59 PM)denzjos Wrote: I couldn't resist
With processing you can do this and much more... (but I can't post the result here, a 1440px*1440px GIF animation is way over the limits).
This said, fun beginner language IMHO, because the IDE helps a lot dealing with the small syntax problems that usually hamper the first attempts at coding(*), and you don't get bored coding, you can always add a tweak somewhere that forces you to learn something new.
(*) For the current crop of snowflakes of course. My generation learned with punch cards and impenetrable error messages in languages nobody understood (english...). In fact I owe my early career in computing to my ability to understand that FORW189E EXTRANEOUS CLOSING PARENTHESIS ON LINE 8 is not there by accident and may point to some parenthesis balancing problem on line 8.
Posts: 1,167
Threads: 179
Joined: Sep 2018
Reputation:
115
Operating system(s):
- Windows (Vista and later)
Gimp version: 2.10
As a programmer you can always do more than a user. I started with basic on my commodore 64 and later on my IBM (mostly CAM related). In the evening, printing a program of several hundred lines on perforated paper with a (screeching) needle printer to detect errors such as an O (text) instead of a 0 (zero) was one of my tasks. Solutions to a problem were always a happy event (and sometimes caused another multiple problems). I stopped doing it at the time because it took too much time and programs kept floating around in your head. The special things you do with gimp and graphics deserve respect.
|