rich Posted January 20, 2016 Share Posted January 20, 2016 Ok so this should look a lot better now (installed the CodeSnippet plugin into CKEditor, which the forum uses) import Effect from 'sound/sfxr/effects/Effect.js'; import GetShape, * as SHAPE from 'sound/sfxr/Shapes.js'; export default function Random (rnd, frnd) { let fx = Effect(); fx.waveType = GetShape(frnd); fx.tone.frequency = Math.pow(frnd(2) - 1, 2); if (rnd(1)) { fx.tone.frequency = Math.pow(frnd(2) - 1, 3) + 0.5; } fx.tone.limit = 0.0; fx.tone.ramp = Math.pow(frnd(2) - 1, 5); if (fx.tone.frequency > 0.7 && fx.tone.ramp > 0.2) { fx.tone.ramp = -fx.tone.ramp; } if (fx.tone.frequency < 0.2 && fx.tone.ramp < -0.05) { fx.tone.ramp = -fx.tone.ramp; } fx.tone.deltaRamp = Math.pow(frnd(2) - 1, 3); fx.duty.value = frnd(2) - 1; fx.duty.ramp = Math.pow(frnd(2) - 1, 3); fx.vibrato.strength = Math.pow(frnd(2) - 1, 3); fx.vibrato.speed = frnd(2) - 1; fx.envelope.attack = Math.pow(frnd(2) - 1, 3); fx.envelope.sustain = Math.pow(frnd(2) - 1, 2); fx.envelope.decay = frnd(2) - 1; fx.envelope.punch = Math.pow(frnd(0.8), 2); if (fx.envelope.attack + fx.envelope.sustain + fx.envelope.decay < 0.2) { fx.envelope.sustain += 0.2 + frnd(0.3); fx.envelope.decay += 0.2 + frnd(0.3); } fx.lpf.resonance = frnd(2) - 1; fx.lpf.frequency = 1 - Math.pow(frnd(1), 3); fx.lpf.ramp = Math.pow(frnd(2) - 1, 3); if (fx.lpf.freq < 0.1 && fx.lpf.ramp < -0.05) { fx.lpf.ramp = -fx.lpf.ramp; } fx.hpf.frequency = Math.pow(frnd(1), 5); fx.hpf.ramp = Math.pow(frnd(2) - 1, 5); fx.phaser.offset = Math.pow(frnd(2) - 1, 3); fx.phaser.ramp = Math.pow(frnd(2) - 1, 3); fx.repeat.speed = frnd(2) - 1; fx.tonal.speed = frnd(2) - 1; fx.tonal.mod = frnd(2) - 1; return fx; } Ahh, sweet! Sadly it doesn't support line numbers, but at least it looks a butt-load better. WombatTurkey, GSquadron and ekeimaja 3 Quote Link to comment Share on other sites More sharing options...
ekeimaja Posted January 20, 2016 Share Posted January 20, 2016 Much better! Now code snippets are readable again Quote Link to comment Share on other sites More sharing options...
WombatTurkey Posted January 20, 2016 Share Posted January 20, 2016 function n(n) {z=i(n)?n:0 for(x=y=n;!z;x--,y++)z=i(x)?x:i(y)?y:0 for(a=b=1;b<n;c=a+b,a=b,b=c); return(n+n*n+(2*n-a-b<0?a:b)+z)/4} function i(n) {for(j=2;j<n;j++) if(!(n%j))return 0 return 1} Yep, works nice. Is that a sneak peak of Lazer? Quote Link to comment Share on other sites More sharing options...
rich Posted January 20, 2016 Author Share Posted January 20, 2016 39 minutes ago, WombatTurkey said: Is that a sneak peak of Lazer? Hah it's just what I had open in Sublime at the time, but yes I guess so. In as much as a 'sneak' of a public and open codebase can be (For anyone wondering it's one of the sfxr functions for dynamic sound effect generation) WombatTurkey 1 Quote Link to comment Share on other sites More sharing options...
staff0rd Posted January 21, 2016 Share Posted January 21, 2016 var MyClass = (function () { function MyClass() { this.d = new Phaser.Sprite(new Phaser.Game, 10, 10); } MyClass.prototype.win = function () { return true; }; return MyClass; })(); exports.MyClass = MyClass; Certainly pops up quicker than the old one. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.