Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Media";
Текущий архив: 2004.08.08;
Скачать: [xml.tar.bz2];

Вниз

алгоритм "Плазма"   Найти похожие ветки 

 
miek ©   (2004-05-23 20:12) [0]

Пытаюсь реализовать алгоритм псевдофрактала "Плазма". Работает нормально, но на рисунке видны некрасивые горизонтальные и вертикальные линии. Как от них избавиться? В фотошопе и других программах ничего подобного нет.
Вот демо-программа:
http://www.miek.narod.ru/plasma.zip


 
Sapersky   (2004-05-24 13:03) [1]

Отчасти помогает замена

if (x1<=x0) or (y1<=y0) then exit;

на

if (x1-x0<=1) or (y1-y0<=1) then exit;

К тому же и быстрее работает. Но "крестообразность" всё равно видна - чтобы её убрать, нужно как-то по-другому считать i. Я пробовал вместо умножения брать геометрическое расстояние:

i:=Round( 255 * Sqrt( (Sqr(x1-x0) + Sqr(y1-y0)) / (Sqr(Width) + Sqr(Height)) ) );

Крестообразность не исчезла, но результат получился довольно интересный - что-то вроде облаков...

Ещё. Предложение по поводу SpriteUtils. Чисто софтверную версию неплохо бы выпустить в качестве дополнения к FastLIB (в виде набора процедур). Сильно повысило бы юзабилити, правда. Собственно, я и этот пример, чтобы протестировать, переводил на FastDIB - ну не хочется мне ставить 6-й Дельфи, а потом изучать очередной класс-контейнер битмапа. И ломать голову, с чем его использовать: KOL - слишком экстремально, VCL - слишком неудобно и громоздко.
А FastLIB, кстати, за исключением использования класса, написан вполне в стиле KOL, и в то же время KOL не требует.
Ну и желательно перевести весь ассемблер в форму, понятную Delphi 5. Не только MMX - он и обычный asm кое-где не понимает. Где конкретно - могу выдать список.


 
Sapersky   (2004-05-24 13:30) [2]

Опс, ошибка вышла, тестировал с картинкой бинарных размеров. Для произвольных можно делать:

xd:=x1-x0; yd:=y1-y0;
if (xd<=0) or (yd<=0) or ((xd=1) and (yd=1)) then Exit;


 
Sapersky   (2004-05-24 13:31) [3]

Опс, ошибка вышла, тестировал с картинкой бинарных размеров. Для произвольных можно делать:

xd:=x1-x0; yd:=y1-y0;
if (xd<=0) or (yd<=0) or ((xd=1) and (yd=1)) then Exit;


 
miek ©   (2004-05-24 18:40) [4]

Кресты удалось победить, в осноном - с помощью большей примеси случайной величины:
_i:= plasmarandomness+(255-plasmarandomness)*( x1-x0)*(y1-y0) div (screen.Width*screen.height);
Вычислять расстояние по SQRT мне не хотелось, т.к. хотел встроить "Плазму" в Graffiti, а там каждая микросекунда на счету.

По SpriteUtils:
1) Использовать SU совместно с FastLib - нет проблем. Давай напишу версию NewDirectDrawRegion, только регион будет создаваться не над поверхностью, а над спрайтом TFastDIB. И овцы целы, и волки сыты. Переделывать саму библиотеку считаю неразумным, потому что мой подход к растру проще, быстрее и ресурсы кушает не так жадно.

>не хочется...изучать очередной класс-контейнер битмапа

Ничем не могу помочь. В отличие от фастлиба, SU несколько лучше документирована. Если уж и так не хочется, умываю руки.

>Ну и желательно перевести весь ассемблер в форму, понятную Delphi 5... Где конкретно - могу выдать список
2) Я не против. Давай список - сделаю. Только тестировать мне негде - нет у меня 5-й версии.


 
Sapersky   (2004-05-25 13:34) [5]

Давай напишу версию NewDirectDrawRegion, только регион будет создаваться не над поверхностью, а над спрайтом TFastDIB

Хм... была обертка одинарная, стала двойная... так? :) Ну попробуй, напиши, посмотрю, что получится.
А FastDIB можно приспособить к любому растру (в т.ч. поверхности DDraw) с помощью SetInterface без написания дополнительного кода.
И спецэффектов у него больше, пусть не супер-быстрых, но всё-таки :)
Всё-всё, молчу :)

Относительно ассемблера для D5... вот что ему не нравится:

1) Инструкции вида mul al,bl. Может быть, он считает, что mul можно делать только с eax, так что al нужно просто убрать? Аналогично - imul eax, op и т.п.
2) Несовпадение размеров типов, например, cmp  ax, transcolor, или cmp eax, word ptr transcolor
3) Возможно, и то, и другое: mul   al, [edi]
4) and   [edi], $FF000000 - не понял :(

Полный список - то есть, ещё не полный, судя по завершающему комментарию - в следующем сообщении.


 
Sapersky   (2004-05-25 13:38) [6]

[Error] SU2_alpha.inc(51): Invalid combination of opcode and operands
[Error] SU2_alpha.inc(54): Invalid combination of opcode and operands
[Error] SU2_alpha.inc(59): Invalid combination of opcode and operands
[Error] SU2_alpha.inc(62): Invalid combination of opcode and operands
[Error] SU2_alpha.inc(67): Invalid combination of opcode and operands
[Error] SU2_alpha.inc(70): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(266): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(269): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(274): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(277): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(285): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(330): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(334): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(339): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(343): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(348): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(352): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(402): Operand size mismatch
[Error] su2_spriteput.inc(407): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(409): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(415): Invalid combination of opcode and operands
[Error] su2_spriteput.inc(419): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(707): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(710): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(715): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(718): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(733): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(765): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(768): Invalid combination of opcode and operands
[Error] SU2_gamma.inc(773): Invalid combination of opcode and operands
[Error] SU2_scroll.inc(68): Invalid combination of opcode and operands
[Error] SU2_scroll.inc(338): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(72): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(74): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(80): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(84): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(108): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(110): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(116): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(120): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(160): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(163): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(168): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(171): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(176): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(179): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(219): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(222): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(227): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(230): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(235): Invalid combination of opcode and operands
[Error] su2_transpaint.inc(238): Invalid combination of opcode and operands


 
Sapersky   (2004-05-25 13:40) [7]

[Error] su2_resize.inc(414): Invalid combination of opcode and operands
[Error] su2_resize.inc(463): Invalid combination of opcode and operands
[Error] su2_resize.inc(473): Invalid combination of opcode and operands
[Error] su2_resize.inc(519): Invalid combination of opcode and operands
[Error] su2_resize.inc(570): Invalid combination of opcode and operands
[Error] su2_resize.inc(580): Invalid combination of opcode and operands
[Error] su2_resize.inc(1211): Operand size mismatch
[Error] su2_resize.inc(1213): Invalid combination of opcode and operands
[Error] su2_resize.inc(1263): Operand size mismatch
[Error] su2_resize.inc(1265): Invalid combination of opcode and operands
[Error] su2_resize.inc(1276): Invalid combination of opcode and operands
[Error] su2_resize.inc(1322): Operand size mismatch
[Error] su2_resize.inc(1324): Invalid combination of opcode and operands
[Error] su2_resize.inc(1376): Operand size mismatch
[Error] su2_resize.inc(1378): Invalid combination of opcode and operands
[Error] su2_resize.inc(1389): Operand size mismatch
[Error] su2_resize.inc(1391): Invalid combination of opcode and operands
[Error] su2_rotate.inc(504): Invalid combination of opcode and operands
[Error] su2_rotate.inc(506): Invalid combination of opcode and operands
[Error] su2_rotate.inc(512): Invalid combination of opcode and operands
[Error] su2_rotate.inc(516): Invalid combination of opcode and operands
[Error] su2_rotate.inc(567): Invalid combination of opcode and operands
[Error] su2_rotate.inc(570): Invalid combination of opcode and operands
[Error] su2_rotate.inc(575): Invalid combination of opcode and operands
[Error] su2_rotate.inc(578): Invalid combination of opcode and operands
[Error] su2_rotate.inc(583): Invalid combination of opcode and operands
[Error] su2_rotate.inc(586): Invalid combination of opcode and operands
[Error] su2_rotate.inc(633): Invalid combination of opcode and operands
[Error] su2_rotate.inc(636): Invalid combination of opcode and operands
[Error] su2_rotate.inc(641): Invalid combination of opcode and operands
[Error] su2_rotate.inc(644): Invalid combination of opcode and operands
[Error] su2_rotate.inc(649): Invalid combination of opcode and operands
[Error] su2_rotate.inc(652): Invalid combination of opcode and operands
[Error] su2_rotate.inc(712): Invalid combination of opcode and operands
[Error] su2_rotate.inc(714): Invalid combination of opcode and operands
[Error] su2_rotate.inc(720): Invalid combination of opcode and operands
[Error] su2_rotate.inc(724): Invalid combination of opcode and operands
[Error] su2_rotate.inc(785): Invalid combination of opcode and operands
[Error] su2_rotate.inc(788): Invalid combination of opcode and operands
[Error] su2_rotate.inc(793): Invalid combination of opcode and operands
[Error] su2_rotate.inc(796): Invalid combination of opcode and operands
[Error] su2_rotate.inc(801): Invalid combination of opcode and operands
[Error] su2_rotate.inc(804): Invalid combination of opcode and operands
[Error] su2_rotate.inc(857): Invalid combination of opcode and operands
[Error] su2_rotate.inc(860): Invalid combination of opcode and operands
[Error] su2_rotate.inc(865): Invalid combination of opcode and operands
[Error] su2_rotate.inc(868): Invalid combination of opcode and operands
[Error] su2_rotate.inc(873): Invalid combination of opcode and operands
[Fatal Error] su2_rotate.inc(876): Compilation terminated; too many errors


 
Ойёё   (2004-05-25 20:02) [8]

Сапёски, что с тобой?


 
miek ©   (2004-05-25 20:27) [9]

Я тут прикинул объем работы по адаптации к Д-5 и мне сразу поплохело. Проще написать парсер, который будет исходники переделывать. Вот, наверное, так и сделаю.


 
miek ©   (2004-05-25 20:27) [10]

Я тут прикинул объем работы по адаптации к Д-5 и мне сразу поплохело. Проще написать парсер, который будет исходники переделывать. Вот, наверное, так и сделаю.


 
Rouse_ ©   (2004-05-25 20:53) [11]

Вот у меня тут демка плазмы валяется уже не знаю с каких времен:
Автор кода неизвестен:

unit Unit2;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics,   Controls, Forms, Dialogs, StdCtrls, ExtCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   Image1: TImage;
   procedure Button1Click(Sender: TObject);
 procedure makeplasma;
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;
 plasma : array[0..768,0..768] of byte;

implementation

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
var  x,y:integer;
begin

makeplasma;
for x:=0 to 255 do
       begin
       for y:=0 to 255 do
               begin
               image1.canvas.pixels[x,y]:=rgb(plasma[x,y],plasma[x+256,y+256],plasma[x+512,y+512]);
               end;
       image1.update;
       end;
//

end;

procedure TForm1.makeplasma;
   procedure halfway(x1,y1,x2,y2: integer);
       procedure adjust(xa,ya,x,y,xb,yb: integer);
       var      d: integer;
                v: double;
       begin
          if plasma[x,y]<>0 then exit;
          d:=Abs(xa-xb)+Abs(ya-yb);
           v:=(plasma[xa,ya]+plasma[xb,yb])/2+(random-0.5)*d*2;
           if v<1 then v:=1;
            if v>=193 then v:=192;
             plasma[x,y]:=Trunc(v);
       end;
   var    x,y: integer;
          v: double;
   begin
       if (x2-x1<2) and (y2-y1<2) then exit;
       x:=(x1+x2) div 2;
       y:=(y1+y2) div 2;
       adjust(x1,y1,x,y1,x2,y1);
       adjust(x2,y1,x2,y,x2,y2);
       adjust(x1,y2,x,y2,x2,y2);
       adjust(x1,y1,x1,y,x1,y2);
       if plasma[x,y]=0 then
       begin
           v:=(plasma[x1,y1]+plasma[x2,y1]+plasma[x2,y2]+plasma[x1,y2])/4;
           plasma[x,y]:=Trunc(v);
       end;
       halfway(x1,y1,x,y);
       halfway(x,y1,x2,y);
       halfway(x,y,x2,y2);
       halfway(x1,y,x,y2);
   end;

var  x,y :integer ;
begin
   randomize;
   plasma[0,768]:=random(192);
   plasma[768,768]:=random(192);
   plasma[768,0]:=random(192);
   plasma[0,0]:=random(192);
   halfway(0,0,768,768);
end;

end.



Страницы: 1 вся ветка

Форум: "Media";
Текущий архив: 2004.08.08;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.51 MB
Время: 0.034 c
14-1090311478
Moses Fender
2004-07-20 12:17
2004.08.08
DNS


11-1078141206
Чапаев
2004-03-01 14:40
2004.08.08
Создание компонентов под KOL


14-1090260768
ИМХО
2004-07-19 22:12
2004.08.08
You know: Мазуту, Алексу и всем-всем-всем...


1-1090907569
prorok2
2004-07-27 09:52
2004.08.08
Смещение компонент при разворачивание формы на полный экран


4-1088110925
nick_mas
2004-06-25 01:02
2004.08.08
Как скопировать строку в Edit другого приложения?





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский