Skip to content

Instantly share code, notes, and snippets.

View dokluch's full-sized avatar

Nik Ska dokluch

View GitHub Profile
@dokluch
dokluch / Coursera_Assignment1.pde
Last active August 29, 2015 13:56
The First Assignment in "Introduction to Computational Arts: Processing" on coursera.org
/*
Instead of creating 20 shapes on 2 types, I have created 20 distinctive
random dynamic shapes to show the beauty and diversity of randomness
Each circle contains a shape with random amount of vertices
generated on the circle's edge in random places and moving with
random speed in random direction.
Click anywhere to get completely different picture
Main idea is redrawing all circles on each step
through the .update() chain
@dokluch
dokluch / gist:8929977
Created February 11, 2014 06:08
Get vertices and tangents info for a selected layer's first mask in AE
//get all first mas vertices info
//Nik Ska, 2014
//CC-BY
var maskVertex = function(v, inT, outT){
this.vertex = v;
this.inTangent = inT;
this.outTangent = outT;
//CC-BY Nik Ska, 2014
var sel = app.project.selection; //selected
var used = []; //these were used
app.beginUndoGroup("Precomping as hell");
var precompFolder = app.project.items.addFolder("Precomps");
@dokluch
dokluch / CreateSmartNull.jsx
Last active August 29, 2015 14:10
Creates a null object parented to all selected layers in Adobe After Effects
function createNull(){
var activeComp = app.project.activeItem;
if(!activeComp instanceof CompItem || !activeComp){
alert("No comp selected");
return null;
}
app.beginUndoGroup("Creatin a null");
if(activeComp.selectedLayers.length != 0){//и если на композиции выделены какие-то слои
var sel = activeComp.selectedLayers;
var getTrueValues = function(layer, position, anchor, scale, rotation){
if(layer.parent != null){
var l = layer.parent.property("ADBE Transform Group");
getTrueValues(layer.parent, position+l.property("ADBE Position").value, anchor+l.property("ADBE Anchor Point").value, [scale[0]*l.property("ADBE Scale").value[0], scale[1]*l.property("ADBE Scale").value[1]]/100, rotation+l.property("ADBE Rotate Z").value*Math.PI/180);
}
else{
var obj = {pos: position, ap: anchor, sc: scale, rot: rotation};
return(obj);
}
}
/*
*Snippet to change target name project-wise.
*Comp names and layer names are going to be affected.
*I believe there are going to be problems with expressions.
*Though I'm not sure
*
*CC-BY, Nik Ska, 2015
*/
var wrongName = "СС";
@dokluch
dokluch / keyframeAccum.jsx
Last active August 29, 2015 14:23
Keyframe accumulator for After Effects
var audioSource = thisComp.layer("Audio Amplitude").effect("Both Channels")("Slider");
var step = 1; // step in frames
var accum = 0;
if(audioSource.numKeys > 0){
var k = 0;
if(time >= step*2){
@dokluch
dokluch / findCompByName.jsx
Last active November 23, 2023 15:39
Finds a composition by a given name in Adobe After Effects
findCompByName=function(_name){
for(var i=1;i<=app.project.numItems;i++)
{
var curItem=app.project.item(i);
if (curItem.name==_name && curItem instanceof CompItem) return curItem;
}
return null;
}
@dokluch
dokluch / connectWithShape.jsx
Created October 23, 2015 10:20
Скрипт для статичного соединения объектов шейпом
/*
Скрипт создает шейп, проходящий через position всех выбранных слоев
Не будет работать, если:
-слои прикреплены к другим слоям
-на позиции есть ключевые кадры/выражения
-Все в 3д и есть камеры
Все эти пункты легко исправляются по необходимости
Nik Ska, 2015
@dokluch
dokluch / interpolateHold.jsx
Created February 17, 2016 15:00
Interpolates hold keyframes in After Effects
n = 0;
t = 0;
if (thisProperty.numKeys > 0){
n = thisProperty.nearestKey(time).index;
if (thisProperty.key(n).time > time) n--;
}
if(n < thisProperty.numKeys){
linear(time, thisProperty.key(n).time, thisProperty.key(n+1).time, thisProperty.key(n).value, thisProperty.key(n+1).value)
}