123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115 |
- Flame torch;
- void setup()
- {
- torch = new Flame(
- 220 //xPos
- , 200 //yPos
- , 10 //width flux
- , 4 //tail length flux
- , 200 //torch thickness
- , 150 //torch source curve
- , 100 //torch tail slope
- , 200 //torch tail length
- , 8 //inner flame offset
- , 100 //inner flame tail difference
- , 160 //inner flame thickness difference
- , 0.8 //inner flame flux strength
- );
- size(640, 480);
- }
- void draw()
- {
- background(0,0,0);
- torch.draw();
- }
- class Flame
- {
-
- float positionX = 320;
- float positionY = 240;
-
- int fluxRange = 10;
- int fluxLength = 4;
-
- float torchThickness = 100;
- float torchSourceCurve = 60;
- float torchTailSlope = 50;
- float torchTailLength = 80;
-
- float innerFlameOffset = 2;
- float innerFlameTailDifference = 40;
- float innerFlameThicknessDifference = 60;
- float innerFlameFluxEffect = 0.5;
-
- Flame(
- float inPositionX
- , float inPositionY
- , int inFluxRange
- , int inFluxLength
- , float inTorchThickness
- , float inTorchSourceCurve
- , float inTorchTailSlope
- , float inTorchTailLength
- , float inInnerFlameOffset
- , float inInnerFlameTailDifference
- , float inInnerFlameThicknessDifference
- , float inInnerFlameFluxEffect
- ) {
- positionX = inPositionX;
- positionY = inPositionY;
-
- fluxRange = inFluxRange;
- fluxLength = inFluxLength;
-
- torchThickness = inTorchThickness;
- torchSourceCurve = inTorchSourceCurve;
- torchTailSlope = inTorchTailSlope;
- torchTailLength = inTorchTailLength;
-
- innerFlameOffset = inInnerFlameOffset;
- innerFlameTailDifference = inInnerFlameTailDifference;
- innerFlameThicknessDifference = inInnerFlameThicknessDifference;
- innerFlameFluxEffect = inInnerFlameFluxEffect;
- }
- void draw()
- {
- stroke(64,0,128);
- fill(32, 0, 64);
- float randomFlux = random(-fluxRange, fluxRange);
- float randomLength = random(-fluxLength, fluxLength);
- curve(
- positionX + torchSourceCurve, positionY + torchThickness + randomFlux
- , positionX, positionY
- , positionX + torchTailLength + randomLength, positionY
- , positionX + torchTailLength, positionY + torchTailSlope
- );
- curve(
- positionX + torchSourceCurve, positionY - torchThickness - randomFlux
- , positionX, positionY
- , positionX + torchTailLength + randomLength, positionY
- , positionX + torchTailLength, positionY - torchTailSlope
- );
- stroke(128, 64, 212);
- fill(128, 64, 212);
- curve(
- positionX + torchSourceCurve, positionY + (torchThickness - innerFlameThicknessDifference) + (randomFlux * innerFlameFluxEffect)
- , positionX + innerFlameOffset, positionY
- , positionX + (torchTailLength - innerFlameTailDifference) + (randomLength * innerFlameFluxEffect) + innerFlameOffset, positionY
- , positionX + torchTailLength, positionY + torchTailSlope
- );
- curve(
- positionX + torchSourceCurve, positionY - (torchThickness - innerFlameThicknessDifference) - (randomFlux * innerFlameFluxEffect)
- , positionX + innerFlameOffset, positionY
- , positionX + (torchTailLength - innerFlameTailDifference) + (randomLength * innerFlameFluxEffect) + innerFlameOffset, positionY
- , positionX + torchTailLength, positionY - torchTailSlope
- );
- }
- }
|