[bb] Diagonal stripes by EsseEmmeErre [ 1+ years ago ]

Started by BlitzBot, June 29, 2017, 00:28:40

Previous topic - Next topic

BlitzBot

Title : Diagonal stripes
Author : EsseEmmeErre
Posted : 1+ years ago

Description : Lord Year 2010, August 16, Monday
Hi everybody, here is EsseEmmeErre tiping from Italy! :D
What I am bringing to you is a simple BLITZ 3D code to generate diagonal stripes.
This is the first working version I have made; the code could be improved but at the moment I would give you it as is.
Sorry for the variable names that are in italian; I hope this may not discourage you to examine my simple code.
HAVE FUN! :-D


Code :
Code (blitzbasic) Select
;-> Strisce Diagonali by Stefano Maria Regattin
;i> Monday 16 August 2010
;-------------------------
AppTitle("Striscie diagonali by Stefano Maria Regattin")
AltezzaFinestra=GraphicsHeight()
LarghezzaFinestra=GraphicsWidth()
LarghezzaStriscia=20
For YPunto=0 To AltezzaFinestra-1
 For XPunto=0 To LarghezzaFinestra-1
  Punto=XPunto+YPunto
  If Punto Mod LarghezzaStriscia=LarghezzaStriscia-1 Then
   If StrisciaGialla=False
    StrisciaGialla=True
   Else
    StrisciaGialla=False
   EndIf
  EndIf
  If StrisciaGialla=False
   Rosso=95:Verde=95:Blu=95
  Else
   Rosso=191:Verde=191:Blu=0
  EndIf
  Color(Rosso,Verde,Blu):Plot(XPunto,YPunto)
 Next
 If YPunto Mod LarghezzaStriscia=LarghezzaStriscia-1 Then
  If StrisciaGialla=False
   StrisciaGialla=True
  Else
   StrisciaGialla=False
  EndIf
 EndIf
Next
MouseWait()
End


Comments :


_PJ_(Posted 1+ years ago)

 Welcome Stefano.I had a go at translating this but I don't know what "Gialla" means :)
AppTitle("Diagonal Stripes by Stefano Maria Regattin")
WindowHeight=GraphicsHeight()
WindowWidth=GraphicsWidth()
StripeWidth=20
For YPoint=0 To WindowHeight-1
For XPoint=0 To WindowWidth-1
If (StripeGialla)
Red=191: Green=191:Blue=0
Else
Red=95: Green=95:Blue=95
End If
Point=XPoint+YPoint
StripeGialla= ((Point Mod StripeWidth)=(StripeWidth-1))
Color(Red,Green,Blue)
Plot(XPoint,YPoint)
Next
StripeGialla=((YPoint Mod StripeWidth)=(StripeWidth-1))
Next
MouseWait()
End
Anyway, I alswo made an effort to clean the code up a tad, I hope that it helps with the formatting!


EsseEmmeErre(Posted 1+ years ago)

 Lord Year 2010, August 17, TuesdayHi, here is EsseEmmeErre tiping from Italy! :DThank you Malice for your interest of my little code! :)Gialla is Yellow in italian, so the variable should be YellowStripe. :)THANK ALL YOU AND MANY WHISHES OF HAPPY HOLIDAYS TO EVERYBODY! :D


EsseEmmeErre(Posted 1+ years ago)

 Hi everybody, here is EsseEmmeErre from Italy! :)I have correpted my little code, now should be better.MANY GREETINGS FROM ITALY! :D;-> Diagonal Stripes by EsseEmmeErre;i> Monday 16 August 2010;m> 14 Sep 2010;m> 2 Oct 2010;--------------AppTitle("Diagonal Stripes by EsseEmmeErre")WindowHeight=GraphicsHeight()WindowWidth=GraphicsWidth()StripeWidth=20For YPoint=0 To WindowHeight-1 For XPoint=0 To WindowWidth-1  Point=XPoint+YPoint  If Point Mod StripeWidth=0 Then   If YellowStripe=False    YellowStripe=True   Else    YellowStripe=False   EndIf  EndIf  If YellowStripe=False   Red=95:Green=95:Blue=95  Else   Red=191:Green=191:Blue=0  EndIf  Color(Red,Green,Blue):Plot(XPoint,YPoint) Next If Point Mod StripeWidth=0 Then  If YellowStripe=False   YellowStripe=True  Else   YellowStripe=False  EndIf EndIfNextMouseWait()End


DaveS(Posted 1+ years ago)

 Heya all here is it, easy to use, cleaned up and a little bit faster :)AppTitle("Diagonal Stripes by Stefano Maria Regattin")
Graphics(800, 600, 32, 2)
StripeImage% = CreateDiagonalStripes(800, 600, 20, 255, 255, 255, 100, 100, 100)
DrawImage(StripeImage%, 0, 0)
MouseWait()
End

Function CreateDiagonalStripes%(iWidth%, iHeight%, iStripeWidth%, iStripeRed1%, iStripeGreen1%, iStripeBlue1%, Red2%, Green2%, Blue2%)
Local tmpImage% = CreateImage(iWidth%, iHeight%)
Local tmpImageBuffer% = ImageBuffer(tmpImage%)
Local tmpPoint, tmpXPoint%, tmpYPoint%, tmpIsStripe%, tmpARGB%
Local tmpRed%, tmpGreen%, tmpBlue%

If ((tmpImageBuffer% = 0) Or (tmpImage% = 0)) Then Return 0

LockBuffer(tmpImageBuffer%)
For tmpYPoint% = 0 To (iHeight% - 1)
For tmpXPoint% = 0 To (iWidth% - 1)
If (tmpIsStripe%)
tmpRed% = iStripeRed1% : tmpGreen% = iStripeGreen1% : tmpBlue% = iStripeBlue1%
Else
tmpRed% = Red2% : tmpGreen% = Green2% : tmpBlue% = Blue2%
End If
tmpPoint% = (tmpXPoint% + tmpYPoint%)
tmpIsStripe% = ((tmpPoint% Mod iStripeWidth%) = (iStripeWidth% - 1))
tmpARGB% = ((0 * $1000000) + (tmpRed% * $10000) + (tmpGreen% * $100) + tmpBlue%)
WritePixelFast(tmpXPoint%, tmpYPoint%, tmpARGB%, tmpImageBuffer%)
Next
tmpIsStripe% = ((tmpYPoint% Mod iStripeWidth%) = (iStripeWidth% - 1))
Next
UnlockBuffer tmpImageBuffer%

Return tmpImage%
End Function



EsseEmmeErre(Posted 1+ years ago)

 Lord Year 2010, October 19, TuesdayHi to all here, I must let you know that my last code here is buggy. :(The bug is at start when XPoint and YPoint are 0, that is Point=0 also, so the line [Point Mod StripeWidth=0] gives 0 and so the first stripes is changed here! :(My apologies to all the coders here that I know will bring here a solution for the bug. :)HAPPY CODING AND GREETINGS FROM ITALY!


EsseEmmeErre(Posted 1+ years ago)

 Lord Year 2010, October 20, WednesdayHi here, I am EsseEmmeErre again! :-DHere is the bug free version of this code; enjoy using it! :-)GOOD CODING AND MANY GREETINGS FROM ITALY TO ALL YOU! :-D;-> Diagonal Stripes by EsseEmmeErre;i> Monday 16 August 2010;m> 14 Sep 2010;m> 2,20 Oct 2010;------------------AppTitle("Diagonal Stripes by EsseEmmeErre")StripeWidth=20WindowHeight=GraphicsHeight()WindowWidth=GraphicsWidth()For YPoint=0 To WindowHeight-1 For XPoint=0 To WindowWidth-1  Point=XPoint+YPoint  If Point>0 And Point Mod StripeWidth=0 Then   If YellowStripe=False    YellowStripe=True   Else    YellowStripe=False   EndIf  EndIf  If YellowStripe=False   Red=95:Green=95:Blue=95  Else   Red=191:Green=191:Blue=0  EndIf  Color(Red,Green,Blue):Plot(XPoint,YPoint) Next If Point Mod StripeWidth=0 Then  If YellowStripe=False   YellowStripe=True  Else   YellowStripe=False  EndIf EndIfNextMouseWait()End


EsseEmmeErre(Posted 1+ years ago)

 Lord Year 2011, April 27, WednesdayHi here to all you, I have found a bug into my previous code: if the width or the height of the graphics area for the stripes are not divisble by the stripes size, you will get some nasty unpredictable drawing instead of the stripe! :(The followin code should be the solution for this problem.;-> DiagonalStripes2 by EsseEmmeErre;d> Wednesday 27th April 2011 from StrisceDiagonali;---------------------------------------------------AppTitle("StrisceDiagonali2","Would you leave?")StripesWidth=20For YPoint=0 To GraphicsHeight()-1 For XPoint=0 To GraphicsWidth()-1  Point=(XPoint+YPoint)/StripesWidth Mod 2  If Point=0 Then   YellowStripe=True  Else   YellowStripe=False  EndIf  If YellowStripe=False   Red=95:Green=95:Blue=95  Else   Red=191:Green=191:Blue=0  EndIf  Color(Red,Green,Blue):Plot(XPoint,YPoint) NextNextColor(255,255,255)Write("Press a mouse button to leave...")MouseWait()End


virtlands(Posted 1+ years ago)

 Aha, I see we're getting into the mathematical art zone. [ screenshot of Diagonal stripes by EsseEmmeErre ][img]img585.imageshack.us/img585/9515/stripesbyeee.html"> [/i]