Skip to content

Commit

Permalink
remove trailing white spaces
Browse files Browse the repository at this point in the history
```
sed --in-place 's/[[:space:]]\+$//' DistFX.ash
sed --in-place 's/[[:space:]]\+$//' DistFX.asc
```
  • Loading branch information
ericoporto committed Mar 21, 2023
1 parent 1fd2436 commit 6ff7511
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 36 deletions.
58 changes: 29 additions & 29 deletions distfx_demo/DistFX.asc
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
// DistFX Module Script
//
//
// MIT License
//
//
// Copyright (c) 2022 Érico Porto
//
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
Expand All @@ -25,7 +25,7 @@
#define D_FORMAT_FIX "%.6f"

enum DistType {
eDT_None = 0,
eDT_None = 0,
eDT_Hori, // Horizontal
eDT_HInt, // Horizontal Interlaced
eDT_Vert, // Vertical
Expand Down Expand Up @@ -73,11 +73,11 @@ void _distfx_init()
String str_c1 = String.Format(D_FORMAT_FIX, (1.0 / 512.0));
String str_c2 = String.Format(D_FORMAT_FIX, (8.0 * Maths.Pi / (1024.0 * 256.0)));
String str_c3 = String.Format(D_FORMAT_FIX, (Maths.Pi / 60.0));

_d_c1 = str_c1.AsFloat;
_d_c2 = str_c2.AsFloat;
_d_c3 = str_c3.AsFloat;

_set_fx_rom(0, eDT_None, 0, 0, 0, 0, 0, 0, 0);
_set_fx_rom(1, eDT_Hori, 2048, 0, 1024, 0, 0, 0, 2);
_set_fx_rom(2, eDT_Hori, 4096, 0, 1024, 0, 0, 0, 2);
Expand Down Expand Up @@ -212,24 +212,24 @@ void _distfx_init()
_set_fx_rom(131, eDT_Rand, 0, 90, 256, 0, 0, 0, 2); // f4
_set_fx_rom(132, eDT_Rand, 21600, 65446, 256, 0, 0, 0, 2); // f4
_set_fx_rom(133, eDT_Vert, 0, 128, 512, 0, 0, 0, 0);
_set_fx_rom(134, eDT_Vert, 65280, 65408, 512, 0, 0, 0, 0);
_set_fx_rom(134, eDT_Vert, 65280, 65408, 512, 0, 0, 0, 0);
}

int _distorter(int y, int t, DistCfg* dist_cfg)
{
float C1 = _d_c1;
float C2 = _d_c2;
float C3 = _d_c3;

DistType distortEffect = dist_cfg.type;
float ampl = dist_cfg.ampl;
float ampl_accel = dist_cfg.ampl_accel;
float ampl = dist_cfg.ampl;
float ampl_accel = dist_cfg.ampl_accel;
float s_freq = dist_cfg.s_freq;
float s_freq_accel = dist_cfg.s_freq_accel;
float compr = dist_cfg.compr;
float compr_accel = dist_cfg.compr_accel;
float speed = dist_cfg.speed;

float ft = IntToFloat(t);
float fy = IntToFloat(y);

Expand All @@ -243,7 +243,7 @@ int _distorter(int y, int t, DistCfg* dist_cfg)

// Compute the value of the sinusoidal line offset function
int S = FloatToInt(C1 * amplitude * Maths.Sin(kangle));

if(distortEffect == eDT_Rand) {
distortEffect = FloatToInt(4.0+4.0*Maths.Sin(IntToFloat(t%64)/32.0))%3 + 1;
}
Expand Down Expand Up @@ -276,32 +276,32 @@ void _compute_frame(DrawingSurface* dst, DrawingSurface* src, int transparency,
#endif
int S, L;
DistType distortEffect = dist_cfg.type;

if(distortEffect == eDT_Rand) {
distortEffect = (ticks/2)%3 + 1;
}

for (int y = 0; y < h; y+= tile_h) {
S = _distorter(y, ticks, dist_cfg);
L = y;
L = y;

if (distortEffect == eDT_Vert) {
L = S;
}

//if (y < letterbox || y > w - letterbox) {
// continue;
//}

for (int x = 0; x < w; x+= tile_w) {
int dx = x;

if (distortEffect == eDT_Hori || distortEffect == eDT_HInt) {
dx = (x + S) % 256;
if (dx < 0) dx = 256 + dx;
if (dx > 255) dx = 256 - dx;
}

#ifdef SCRIPT_API_v360
dst.DrawSurface(src, transparency, x, y, tile_w, tile_h, dx, L, tile_w, tile_h);
#endif
Expand All @@ -310,7 +310,7 @@ void _compute_frame(DrawingSurface* dst, DrawingSurface* src, int transparency,
dst.DrawImage(x, y, tmp.Graphic, transparency, tile_w, tile_h);
tmp.Delete();
#endif
}
}
}
}

Expand All @@ -321,22 +321,22 @@ void _compute_frame(DrawingSurface* dst, DrawingSurface* src, int transparency,
void DistFX::Update(DrawingSurface* source, DrawingSurface* dest, int effect)
{
if(effect != this._prev_fx) this._ticks = 0; // reset ticks on effect change

if(this._tile_width <= 0) { this._tile_width = 64; }
if(this._tile_height <= 0) { this._tile_height = 1; }

_compute_frame(dest, source, this._drawing_transparency, 0, this._ticks, _fx_rom[effect], this._tile_width, this._tile_height);

if(this._ticks < 0) {
this._reverse_ticks = false;
} else if(this._ticks > 4096) {
this._reverse_ticks = true;
}

if(this._reverse_ticks) {
this._ticks-=1;
this._ticks-=1;
} else {
this._ticks++;
this._ticks++;
}
this._prev_fx = effect;
}
Expand Down
14 changes: 7 additions & 7 deletions distfx_demo/DistFX.ash
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@
// Version 0.2.0

/// DistFX object
struct DistFX {
struct DistFX {
/// Draws from a source surface to a destination surface using a distortion effect
import void Update(DrawingSurface* source, DrawingSurface* dest, int effect);

/// Reset internal state, use on state change
import void Reset();

// Attributes

/// Drawing Transparency, use for blurring the effects (default is 0, range from 0 to 99)
import attribute int DrawingTransparency;
import int get_DrawingTransparency(); // $AUTOCOMPLETEIGNORE$
import void set_DrawingTransparency(int value); // $AUTOCOMPLETEIGNORE$

/// Distortion Tile Width, factor of source width, bigger is less resource intensive (default is 64 pixels)
import attribute int TileWidth;
import int get_TileWidth(); // $AUTOCOMPLETEIGNORE$
import void set_TileWidth(int value); // $AUTOCOMPLETEIGNORE$

/// Distortion Tile Height, factor of source height, bigger is less resource intensive (default is 1 pixel)
import attribute int TileHeight;
import int get_TileHeight(); // $AUTOCOMPLETEIGNORE$
import void set_TileHeight(int value); // $AUTOCOMPLETEIGNORE$

// private internals
protected int _tile_width; // $AUTOCOMPLETEIGNORE$
protected int _tile_height; // $AUTOCOMPLETEIGNORE$
Expand Down

0 comments on commit 6ff7511

Please sign in to comment.