En ^ Ru

AVS by Nic01
 
http://avs.chat.ru/avsbynic01.htm
http://avs.chat.ru/avsbynic01dm.avs
http://avs.chat.ru/avsbynic01m.avs
 
Start Coding
 beginner tutorials by Nic01
 
Начнём с Trans \ Movements (user defined). Stiff, plain, no dynamics (Ugh, I hate to say that first 3 words of the list), but basic and easy to learn (or copy, actually).
 
I - First words
 
What things you could've done that makes you want to code?
 1. Staring in awe of a masterpiece from one of the better AVS artists, then having a brain overload after looking at the coding involved.
 2. Reviews of your presets said in one part, "Code!"
 3. You just want to.
 
II - Basic Coding
 
IIa - Variables
 
Несмотря на то, что Вы можете видеть до сотни переменных в одном пресете, большинство из них не идут с AVS, а являются пользовательскими.
Actual variables:
-D, для расстояния
-R, для вращения
-X, для оси X
-Y, для оси Y
- Остальные должны быть custom variables.
 
IIb - Basics
 
Начнём с zooming-in. Это просто, и легко заменяет Blitter Feedback. Выберите Render \ Moving Particle.
- Убедитесь, что Bilinear filtering включено.
- Отключите Clear Every Frame.
- код:
d=d/1.01;
Хотите быстрее? Установите более высокое число! Отметьте, что 1.02 изменит zooming speed вдвое от текущей. Можете заменить код на d=d-0.01; Получается много быстрее, и к сожалению добавляет пузырящийся эффект. Прямо сейчас мы говорим о plain zooming.
 
Теперь, когда Вы изменили zoomed in, давайте изменим zoom out!
- код:
d=d*1.01;
Не удивительно, - это простая противоположность zooming in, мы лишь изменили знак деления на умножения. Аналогично можем изменить знак минус на знак плюс d=d+0.01; Получим zooms out, но также с побочным эффектом.
 
Вы изменили zoomed in and out, а теперь rotate.
-R - вращение:
r=r+0.05;
или r=r-0.05; Где "+" против часовой стрелке, а "-" по часовой стрелке. R не достаточно хорошо справляется с "*" или "/", поэтому не используйте их. Используйте R в сочетании с D для zooming и rotating movement. Вы можете легко заменить "tunneling" movement комбинацией D и R.
 
Движение move left, move right, move up, move down.
Теперь x-y transition. Самая простая вещь в математических терминах.
- Отметьте чекбокс "Rect Coords", он должен использоваться для transition.
- X transition. x=x+0.01; или x=x-0.01;
- Y transition. y=y+0.01;
- Используйте комбинацию сразу двух переходов для диагонального движения.
Вы можете использовать x/y и d/r movement совместно, но это потребовало бы некоторого дополнительного кодирования. Пока Вы не сможете этого сделать.
 
III - Dynamics
 
IIIa - Simple dynamics
 
Теперь Вы добрались до Trans \ Dynamic Movement. It's not named Dynamic for nothing.
- Прежде всего, измените размер сетки (grid size). Если размер окна AVS есть "AxB", где A и B - размер в пикселях, то grid size должен быть A/10 и B/10. Сделайте подсчёты самостоятельно (64х48). Это делается, чтобы предотвратить тенденцию DM перемещать изображение немного вверх-влево.
- Бокс, который Вам необходим, - третий сверху, с пометкой "Pixel".
- Попробуйте базовые уравнения, которые были в предыдущей главе. Они работают так же как и typical movement.
Появляется ещё одна новая переменная: B. 1 on beat, 0 otherwise.
- Хочется динамики? Попробуйте beat-detection:
d=d/(1.01+b/10);
- Вы можете заменить black OnBeat clear, при использовании кода d=d+b;
- Повозитесь с числом после B, в знаменателе, - оно устанавливает скорость. Чем выше, тем меньше изменение (можете полностью замедлить движение).
- Также Вы можете использовать R, X, или Y вместо D.
 
IIIb - More dynamic
 
Вы добрались до реального дела. Это изменение каждого бита. Воспользуемся пользовательскими переменными и функциями. Для начала, коротко, с вращением.
 Beat:
t=rand(401)/1000-0.2;
 Pixel:
r=r+t;
 
Определение столь же просто, как r=r+0.01; но константа 0.01 заменена переменной, которая изменяется на каждом такте. Так, один бит может быть 0.2, другой 0.1, и даже 0. Функция rand выдаёт число в диапазоне от 0 до числа в pharantheses (от 0 до 400). Рэнд весьма случаен (linear-proof). Не забудьте включить ритмичную мелодию, чтобы увидеть различие.
 
Теперь x/y movement. Проверьте отметку "Rectangular coordinates".
 Beat:
tx=rand (401)/1000-0.2;
ty=rand (401)/1000-0.2;
 Pixel:
x=x+tx;
y=y+ty;
 
IV - More coding
 
Теперь перейдём к ещё более улучшенным и бит-зависимым вещам. Снова воспользуйтесь типовым эффектом trans/movement.
- код:
d=d-cos(r*2)*0.01;
Отметьте, что движение не является zooming in или zooming out.
- Можете заменить число после r любым другим числом. Это изменит количество "струй". Или же замените cos на sin. Различие будет только в местоположении.
- Хотите придать вращение? Добавьте внутри скобок, после r*2 "+" или "-" число.
- Если хотите наклонить фигуру на 90 градусов, то используйте "+acos(-1)/2". Удалите "/2" для поворота на 180 градусов. Acos(-1) (Arccosine) очень близок к пи. В AVS, r - это 2pi, таким образом 2pi - поворот на 360.
- Попробуйте
d=d-abs(cos(r*2.5)*0.01);
 
Снова вернёмся к X и Y. Сделаем swirly stuff.
- код:
x=x+cos(y*10)*0.01;
y=y+cos(x*10)*0.01;
 Число после x или y задаёт количество водоворотов.
 
"Type-away Coding" означает non-coding кодирование. Вы только пишите функции и операции, не зная, что они делают. Я использовал этот приём несколько раз. Две переменные - это уже другая история.

Перевод: А.Панов.
http://avs.chat.ru

counter
Panow©



En ^ Ru

Where to Start Coding for Dummies =)
 
http://forums.winamp.com/showthread.php?threadid=87661
 
First, we'll start with movements. Stiff, plain, no dynamics (Ugh, I hate to say that first 3 words of the list....), but basic and easy to learn (Or copy, actually).
 
I - First words
Ia - So, what things you could've done that makes you want to code?
---- 1. Staring in awe of a masterpiece from one of the better AVS artists, then having a brain overload after looking at the coding involved.
---- 2. Reviews of your presets said in one part, "Code!"
---- 3. You just want to.
Ib - Hopefully, you read the AVS FAQ at the main AVS forum first. If you don't...
Ic - This part is useless, dontya think?
 
-----------------
II - Basic Coding
-----------------
 
IIa - Variables!
--------Yes, there are many variables - Despite the fact that you can see as much as 100 variables in a single preset, but guess what, most of them aren't even something that come with AVS! More than half of them would be custom variables. That's something you don't need to know if you're just starting coding.
--------So, what are the actual variables?
-D, for distance
-R, for rotation
-X, for... X axis
-Y, for Y axis
-The rest should be custom variables...
 
IIb - Now the Basics
--------Where to start coding? Somewhere simple. Let's start with a simple zooming-in. It's simple, and easily substitutes Blitter Feedback. Don't forget that handy moving particle.
-The code is simple, and short : d=d/1.01;
-It's slow, but it's a start... want it to be faster? set it to a higher number! Note that 1.02 will make the zooming speed twice the current speed. Be careful, or you'll end up with... Something chaotic.
-You can also substitute the code with d=d-0.01; It's quite a lot faster, and it unfortunately adds a bubbling effect to it. Use it when appropriate... We're talking about plain zooming right now.
-Oh yeah, be sure leave bilinear filtering on and don't use "Clear Every Frame".
 
--------Now that you zoomed in, let's zoom out!
-The code is... d=d*1.01;
-Not surprising, huh? It's simply the opposite of zooming in, so it just changes the division sign with the multiplication.
-You can also change the code with the - sign into a code with a + sign. Zooms out, but with a side effect too.
==Math behind it? Just read the formula, and remember, d is distance.
 
--------So you've zoomed in and out... Now rotate.
-R is rotation, so the code is simply r=r+0.05 or r=r-0.05;
-"+" goes anti-clockwise, - goes clockwise
-R doesn't cope well with "*" or "/". Don't use them.
-Use with combination of D for a zooming and rotating movement. You can easily replace the "Tunneling" movement with combination of D and R, AND make newbies think you're a coder... Well, possibly.
 
--------Move left, move right, move up, move down.
-Now you'll learn simple x-y transition! Simplest thing in terms of math.
-Check the "Rect Coords" checkbox. Sounds weird, but it needs to be used to make them transition work.
-Simple X transition? x=x+0.01; or x=x-0.01;
-Replace X with Y for Y transition.
-Use combination of 2 at once for diagonal movement.
-You can use x/y with d/r movement in conjunction, but that would take some advanced coding... Sorry, but you'll have to wait for a bit till you're able to do such thing, which seems like a simple thing, but definately isn't.
 
III - Dynamics!
 
IIIa - Simple dynamics
--------Now, you get to play around with something more - The "Dynamic Movement". It's not named Dynamic for nothing.
-First of all, change the grid size. What's your AVS window size? It should be "AxB", A and B being the size in pixles. The grid size should be A/10 and B/10. Do the math yourself. This is done to prevent the DM's tendency to move the image slightly to top-left.
-The box you want to type in is the 3rd big box from the top, labeled "Pixel" or somwthing like that.
-Try the basic movements that I told you in the previous chapter. It works the same as a typical movement! Good, eh?
-One new variable : B. 1 on beat, 0 otherwise.
-So, wanna dynamics? Try this : d=d/(1.01+b/10)
-There! Now it got some nice beat-detection!
-BTW, you can substitute a black OnBeat clear by using the code d=d+b.
 
http://avs.chat.ru