Psycho-Augenverzerrer von ??? |
Diesen Effekt habt ihr bestimmt schonmal gesehen: Schaut die ganze Zeit auf den roten Punkt in der Mitte des sich drehenden Bildes. Schaut dabei nicht weg! Nach 30 Sekunden schließt sich das Programm automatisch, und dann solltet ihr auf etwas anderes schauen. Wer dann noch alles "normal" sehen kann, sollte unbedingt mal den Augenarzt aufsuchen ;) Hier der Code: [code:1:663e6e25a0]Graphics 500,500,0,2 SetBuffer BackBuffer() AppTitle "Augen-Verzerrer" Const Bilder = 36 Const Genauigkeit = .7 ; Je kleiner desto besser die Qualität, desto größer jedoch auch die Rechenzeit! Const Richtung = 1 Const Zeit = 30 Dim Bild(Bilder) ZeichneBilder Anfangszeit = MilliSecs() While (Not KeyDown(1)) And (MilliSecs() - Anfangszeit < Zeit * 1000) Cls Temp1 = (Temp1 + 1) Mod 5 If Not Temp1 Then Temp2 = (Temp2 + 1) Mod 35 DrawBlock Bild(Temp2),0,0 Flip Wend End Function ZeichneBilder() Local a#, b#, x#, y# For i = 0 To 35 Bild(i) = CreateImage(GraphicsWidth(),GraphicsHeight()) Next For i = 0 To 35 b = 0 Cls LockBuffer() Cls For a = 1 To 500 Step Genauigkeit b = b + Genauigkeit For c = 1 To b x# = GraphicsWidth()/2 + Cos(Sgn(Richtung)*(b+c+b*5)+360*i/Bilder)*a y# = GraphicsHeight()/2 + Sin(Sgn(Richtung)*(b+c+b*5)+360*i/Bilder)*a If (x >= 0) And (x < GraphicsWidth()) And (y >= 0) And (y < GraphicsHeight()) Then WritePixelFast x,y,$FFFFFF EndIf Next Next For a = 1 To 360 Step 10 WritePixelFast GraphicsWidth()/2+Cos(a)*5,GraphicsHeight()/2+Sin(a)*5,$FF0000 Next UnlockBuffer() GrabImage Bild(i),0,0 Next End Function[/code:1:663e6e25a0]Viel Spaß (*muahaha* :twisted:) |
von ??? |
alt wie ein baum *sing* =) irgendwie ist der effekt nicht so stark wie beim original. liegt wohl daran, das der kontrast zu gering ist... |
von ??? |
Wird wohl auch daran liegen, dass ich daran nur 15 Minuten gecodet habe. Soll ja kein Glanzwerk sein, nur halt nen nettes kleines Eye-Candy ;) [EDIT] Und übrigens, komischerweise ist bei mir der Effekt sogar noch stärker als beim Original, das wird aber wohl von Person zu Person anders sein... [EDIT2] Das mit dem Kontrast: Wenn ich ca. 5 Sekunden den roten Kreis fixiere, schalten meine Augen anscheinend irgendwie automatisch in die "Schwarz-Weiß-Ansicht", sodass der Kontrast perfekt wirkt und die kleinen ungewollten Lücken und Pünktchen verschwinden... |
von tasky |
Hi, ich hab mich auch mal an dem Augenverzerrungszeugs versucht und hab zwei Möglichkeiten gefunden: :D [b:8bf1550287]BB3D Version:[/b:8bf1550287] [code:1:8bf1550287]Graphics3D 640, 480, 32, 1 SetBuffer BackBuffer() camera = CreateCamera() PositionEntity camera, 0, 0, -1 sprite = CreateSprite() ScaleSprite sprite, 1.3, 1.3 texture = CreateTexture(512, 512) texbuf = TextureBuffer(texture) EntityTexture sprite, texture EntityFX sprite, 1 LockBuffer texbuf For b# = 0 To 360 Step .1 c = 128 + Sin(b#) * 127 For a# = 0 To 640 x = 256 + Sin(6 * a# + b#) * a# * .8 y = 256 + Cos(6 * a# + b#) * a# * .8 If x >= 0 If x < 512 If y >= 0 If y < 512 WritePixelFast x, y, (c Shl 16) Or (c Shl 8) Or c, texbuf End If End If End If End If Next Next UnlockBuffer texbuf a# = 0 While Not KeyHit(1) a# = a# + 4 RotateSprite sprite, a# RenderWorld Flip Wend ClearWorld[/code:1:8bf1550287] Und eine weniger schnelle, aber dafür vom Code interessantere Methode. Diese benutzt eine 8-Bit Paletteemulation. Die Spirale muss dabei nur einmal gezeichnet werden. Das Bild an sich besteht nur aus Farbattributen, wobei jedem (insgesamt 256) ein RGB-Wert zugewiesen wird. Diese "Farbpalette" wird dann einfach rotiert. Die Funktionen hab ich schnell aus einer eigens programmierten Bibliothek rausgenommen und dazu den Spiralcode hinzugefügt: [b:8bf1550287]Version mit Paletteemulation:[/b:8bf1550287] [code:1:8bf1550287] Type TPALIMG8 Field palbuf Field imgbuf Field width Field height Field winLeft Field winRight Field winTop Field winBottom End Type Graphics 640, 480, 32, 1 SetBuffer BackBuffer() palimg = createPalImage(640, 480) For i = 0 To 127 setPal(palimg, i, i Shl 1, i Shl 1, i Shl 1) setPal(palimg, 128 + i, 255 - (i Shl 1), 255 - (i Shl 1), 255 - (i Shl 1)) Next For b# = 0 To 360 Step .1 c = 255.0 * b# / 360.0 For a# = 0 To 640 x = 320 + Sin(4 * a# + b#) * a# * .7 y = 240 + Cos(4 * a# + b#) * a# * .7 writePalImagePixel(palimg, x, y, c) Next Next While Not KeyHit(1) drawPalImage(palimg, 0, 0) rotatePal(palimg, 0, 256, 4) Flip Wend freePalImage(palimg) Function createPalImage(width, height) Local palimg.TPALIMG8 = New TPALIMG8 palimgpalbuf = CreateBank(769) palimgimgbuf = CreateBank(width * height) palimgwidth = width palimgheight = height palimgwinLeft = 0 palimgwinTop = 0 palimgwinRight = GraphicsWidth() - 1 palimgwinBottom = GraphicsHeight() - 1 Return Handle(palimg) End Function Function freePalImage(hpalimg) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) FreeBank(palimgpalbuf) FreeBank(palimgimgbuf) Delete palimg End Function Function freeAllPalImages() Local palimg.TPALIMG8 = First TPALIMG8 For palimg.TPALIMG8 = Each TPALIMG8 freePalImage(Handle(palimg)) Next Delete Each TPALIMG8 End Function Function setPal(hpalimg, i, r, g, b) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) Local p = 3 * i PokeByte(palimgpalbuf, p, r) PokeByte(palimgpalbuf, p + 1, g) PokeByte(palimgpalbuf, p + 2, b) End Function Function getPal(hpalimg, i, r, g, b) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) Local p = 3 * i Return (PeekByte(palimgpalbuf, p) Shl 16) Or (PeekByte(palimgpalbuf, p + 1) Shl 8) Or PeekByte(palimgpalbuf, p + 2) End Function Function rotatePal(hpalimg, start, size, s = 1) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) Local tmpBank If start < 0 start = 0 Else If start > 255 start = 255 End If If size < 0 size = 0 Else If (size + start) > 256 size = 256 - start End If s = s Mod size If s > 0 tmpBank = CreateBank(s * 3) CopyBank palimgpalbuf, (start + size - s) * 3, tmpBank, 0, s * 3 CopyBank palimgpalbuf, start * 3, palimgpalbuf, (start + s) * 3, (size - s) * 3 CopyBank tmpBank, 0, palimgpalbuf, start * 3, s * 3 FreeBank(tmpBank) Else tmpBank = CreateBank(-s * 3) CopyBank palimgpalbuf, start * 3, tmpBank, 0, -s * 3 CopyBank palimgpalbuf, (start - s) * 3, palimgpalbuf, start * 3, (size + s) * 3 CopyBank tmpBank, 0, palimgpalbuf, (start + size + s) * 3, -s * 3 FreeBank(tmpBank) End If End Function Function writePalImagePixel(hpalimg, x, y, i) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) If x >= 0 If x < palimgwidth If y >= 0 If y < palimgheight PokeByte(palimgimgbuf, y * palimgwidth + x, i) End If End If End If End If End Function Function readPalImagePixel(hpalimg, x, y) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) If x >= 0 If x < palimgwidth If y >= 0 If y < palimgheight Return PeekByte(palimgimgbuf, y * palimgwidth + x) End If End If End If End If Return 0 End Function Function drawPalImage(hpalimg, x, y, buffer = 0) Local palimg.TPALIMG8 = Object.TPALIMG8(hpalimg) Local xp, yp, xe, ye Local i, c If Not buffer buffer = GraphicsBuffer() xe = palimgwidth - 1 ye = palimgheight - 1 If x < palimgwinLeft x = palimgwinLeft If y < palimgwinTop y = palimgwinTop If xe > palimgwinRight xe = palimgwinRight If ye > palimgwinBottom xe = palimgwinBottom LockBuffer buffer For yp = y To ye For xp = x To xe i = PeekByte(palimgimgbuf, yp * palimgwidth + xp) c = PeekInt(palimgpalbuf, i * 3) And $FFFFFF WritePixelFast xp, yp, c, buffer Next Next UnlockBuffer buffer End Function[/code:1:8bf1550287] |