SVG fill animation cycle broken - svg

i am looking to simply animate two fill colors of an SVG. ping pong, loop, however you want to call it. the pieces work on their own, but put together into a recursive function to form the loop breaks it.
here's what i have (using jQuery):
$(document).ready( function() {
var items = $('.st1');
items.css('fill', '#ff3600');
bl-colorCycle();
function bl-colorCycle() {
console.log('color cycle called');
items.animate({fill: '#00ffcc'}, 5000, 'linear', bl-colorCycle);
}
});
for some reason, this throws this error:
SyntaxError: missing ( before formal parameters
what the heck am i missing? i've torn this apart several times and for the life of me, i cannot spot where the hell the missing '(' is! i've read all that i can find here, and found nothing that helps in this scenario. i've even tried putting the function call at the very end, just to see if some weird web-voodoo was at play...bupkiss. :(
i'm hoping someone out there has sharper eyes... :P
TIA.
WR!

Hyphen ("-") is not a legal identifier character. Try underscore ("_") instead. Ie. bl_colorCycle().

Related

Adding integers with the eval function is returning an error. (Nodejs)

Please don't ask me not to use eval, this isn't going to be public anyways.
I've made a chatting website, and I have implemented a "!eval" command (admin only), whatever is after it is run. I can use "!eval '2'+'2'" (Strings added), but not "!eval 2+2." The error returned is .
I've console.logged the input to the eval, and it returned exactly what I wanted: "1+1." I've looked around for this, but it seems like no one else had this problem before. A solution (more like a debugging one) is that I tried "eval('1+1')" and returned the same error. Any thoughts? Thanks in advance.
(I forgot to add what I was expecting)
I was expecting this.
VLAZ pointed out in the comments that it must be another piece of code, which he is correct. I was encrypting the messages so it can be sent securely to the client, and it only takes a string. I added
if (typeof(results) != 'string'){
results = String(results)
}
and it seemed to work, Thanks!

How can I split my code, and keep it all asynchronous?

I've been coding just as a side project for a bit, piecing together bits that other people have written (it's for a simple discord bot). I want to split my code to make it easier to problem solve and read, however whenever I try to use the code it comes up with an error saying 'SyntaxError: await is only valid in async function'.
I've tried supposedly loading the code asynchronously, loading it with require() and then making a single command asynchronous, making the entire code in the file asynchronous (it's not just one command I want to load, but a whole file. Also I'm not sure if I tried it correctly or not), using the npm async-require, and maybe some others that have been around on the internet.
//one of the solutions I've tried. This is just copy pasted from the
//answer
//file2.js
var fs = require('fs');
module.exports = function (callback) {
fs.readFile('/etc/passwd', function (err, data) {
callback(err, data);
});
};
//file1.js
require('./passwords')(function (err, passwords) {
// This code runs once the passwords have been loaded.
});
In the first file before I split it, I started it with client.on('message', async message => { and it made me able to use the await function in every command. I want to still be able to do that, but just have it a bit neater and easier to use by splitting it.
I'm trying to get this done so I can move on to a different question I asked and give one of the answers a tick. Any help would be greatly appreciated <3
Fix those awaits so that they are not inside async functions. This is a lexical issue that can be solved just by looking at the location were the error occurs. Just look for the nearest containing function to where the await is and mark it async. Repeat until the error goes away.

ExtendScript: 'Undefined is not an object' error everywhere?

So I just checked out some ExtendScript code I wrote a few weeks back to finish the After Effects script I was working on.
I tried to compile, and now I get these 'Undefined is not an object' errors at various points in my code.
I won't post the full script now. Don't think that'd help the situation. Just why are these errors happening at all anyway? I didn't have them when I wrote the script, and now that I open it back up they're there. I really don't get it.
Anyway, let's take a look at e.g. this part of my code:
var projectCompNames = new Array ();
var projectCompObjects = new Array ();
var scriptPath = ((new File($.fileName)).parent).toString();
var i;
// get a list of all compositions in the project and write them into an array
for (i = 1; i <= app.project.numItems; i++) {
if (app.project.item(i) instanceof CompItem) {
projectCompNames.push(app.project.item(i).name);
projectCompObjects.push(app.project.item(i));
}
}
So as the comment suggests, this gets all the compositions in the project and writes them into an array. Worked fine when I worked on the script, now it doesn't.
This part:
app.project.numItems
Apparently produces the error 'Undefined is not object.' because if I change the code to this:
for (i = 1; i <= 5; i++) {
if (app.project.item(i) instanceof CompItem) {
projectCompNames.push(app.project.item(i).name);
projectCompObjects.push(app.project.item(i));
}
}
The error is gone. In the first line. Same error in the second line. Then I can fix it by using some random integers for the if condition and the error continues to be there. In any line of my code. All over it. I'm quite desperate here. No idea where this is coming from. Is there something wrong with the compiler? Should I reinstall the ExtendScript Toolkit? I mean, this is really odd.
If anyone knows why this is happening, I'd much appreciate the help. If I don't figure this out, I'm going to have to start over again with the script. I can't possibly debug that error at like 50 different places in my code, especially because it's so random.
Edit: Because I started the ExtendScript Editor individually and not from AE I had to link the editor to AE myself. I just didn't do that. If you launch it from the AE UI it does that automatically.
This is what I'm talking about. It was the only reason the compiler was freaking out. Quite obvious when all After Effects specific variables and functions weren't loaded.

Grab an image from willOutputSampleBuffer or related?

So, Brad Larson is awesome. I'm using his GPUImage library since he optimized the CGContextCreateImage for video output to instead render straight into OpenGL. Then he rewrote it to be even more amazing, and half the questions are outdated. The other half have the new callbacks, Like this question, but for the life of me, I can't get the video frames callback to not be nil. (the CMSampleBuffer to CIImage functions)
I know I have to "tag the next frame" to be kept in memory, thanks to his blog. I also know I process it (but GPUImageVideo also does that), then I grab from the framebuffer. Still nill.
The capture command that's supposed to auto-filter it into a CGImage, from the CGImagePicture's processImageUpToFilter function seems to be what I want, and I've seen it mentioned, but I am lost as to how to hook up the output to its frameBuffer.
Or should I use GPUImageRawDataOutput, and how to hook up? I've been copying and pasting, editing, experimenting, but unsure if it's just the fact I don't know openGL enough to hook up the right stuff or?
Any help is appreciated. I wouldn't ask, since so many related questions are up here, but I use them and still get nil on the output.
Here is my current try:
func willOutputSampleBuffer(sampleBuffer: CMSampleBuffer!) {
gpuImageVideoCamera.useNextFrameForImageCapture()
//Next line seems like a waste, as this func is called in GPUImageVideoCamera already.
gpuImageVideoCamera.processVideoSampleBuffer(sampleBuffer);
if let image = gpuImageVideoCamera.imageFromCurrentFramebuffer()
{
//it's nil
}
}
It seems to use the filter instead, and useNextFrame should be AFTER processing to not go super-slow.
Inside of willOutputSampleBuffer, this is it.
if let image = transformFilter.imageFromCurrentFramebuffer()
{
// image not nil now.
}
transformFilter.useNextFrameForImageCapture(); //enusre this comes after
This has given us stunning speeds that beat Google's p2p library. Brad, thanks, everyone should support your efforts.

Can not find line break setting after opening curly brace in resharper

When I create a new javascript constructor I want to do this:
var PersonViewModel = function(){};
Then I press return after the semicolon and get this:
var PersonViewModel = function()
{
};
But what I want is this:
var PersonViewModel = function()
{
// so I can immediately continue writing code here
};
I want that line break after the opening curly brace.
I can not find the settings in the javascript options, anyone knows please?
ReSharper tries very hard not to mess with user typing (at least when it is correct). It can help you not to touch very much, but if you want to type something fully, it tries to allow you to do it. But the feature that you want breaks this principle: when user would type to function statement side-by-side, the second one would be inside the first one instead.
What I suggest instead is just typing ...function(){ and pressing Enter. ReSharper would add } for you automatically, so you can just continue to write function body. You would get syntactically correct code, because ; could be omitted in JavaScript. ReSharper would highlight missing ; anyway and would suggest to add all missing ; in the whole file. Just use this feature from time to time to make your code beautiful.

Resources