Pressed / grid look

Just starting out? Need help? Post your questions and find answers here.
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Pressed / grid look

Post by kinglestat »

I am trying to make a pressed button effect which has kind of grid line look to it...slanted like "/////"

Code: Select all


Procedure            rndCol()
      Protected.i       r, g ,b
      Protected.i       i, j
      Static.i          _r, _g, _b
      
      j = _r + _g + _b
      
      Repeat
         r = Random(255, Random(80,48))
         g = Random(255, Random(80,48))
         b = Random(255, Random(80,48))
         i = r + g + b
         
      Until Abs(i - j) > 64
      
      _r = r : _g = g : _b = b
      ProcedureReturn RGB(r,g,b)
   EndProcedure

tw = 100 : th = 40

If OpenWindow(0, 0, 0, 240, 60, "ButtonImageGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
      image = CreateImage(#PB_Any, tw,th)
      color = rndCol()
      
      StartDrawing( ImageOutput( image ) )
      Box( 0, 0, tw, th, color )
      
      DrawingMode(#PB_2DDrawing_Default)
      DrawText(2, 2,"( 1 / 1 )", #Black,#Yellow)
      StopDrawing()
      
      pressed = CreateImage(#PB_Any, tw,th)
      StartDrawing( ImageOutput( pressed ) )
      DrawAlphaImage(ImageID(image), 0, 0,220)
      StopDrawing()
      
      ButtonImageGadget(0, 10, 10, tw, th, ImageID(image))
      ButtonImageGadget(1, 120, 10, tw, th, ImageID(pressed))
    
    Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

I managed to get it darker this way, but I still wish for this slanted grid effect. Anyone think can help?
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: Pressed / grid look

Post by kinglestat »

[Updated]

Code: Select all

 For i = 10 To tw Step 10
         For j = 15 To th Step 5
            Line(0,j,tw,1,$C0C0C2)
            Line(i,15,1,tw,$C0C0C2)
            
            ;LineXY(tw, j, tw, th, $C4B3AB)
         Next
      Next
I have added this code....but it is not the effect I would like; I am looking for a net like pattern, so instead of squares, there will be diamonds
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Pressed / grid look

Post by infratec »

Can you show a picture of what you want, or a link to a picture?
I'm not sure if I know what you want to achieve.
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Pressed / grid look

Post by collectordave »

This draws diamonds choose how big:

Code: Select all

      For x1 = 0 To tw Step 10
        x2 = x1 + 10
        
        LineXY(x1, 0, x2, 40, RGB(255,255,255))
      
      Next x1
      
      For x1 = 10 To tw Step 10
        x2 = x1 - 10
        
        LineXY(x1, 0, x2, 40,  RGB(255,255,255))
      
      Next x1 
      
      
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: Pressed / grid look

Post by kinglestat »

Something like this

https://www.shutterstock.com/image-vect ... 1829955269

I know there is an example i saw...unrelated
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: Pressed / grid look

Post by kinglestat »

@collectordave

your example is defective...it does make 1 line of diamonds but does not fill the image
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: Pressed / grid look

Post by firace »

From my code library... To be adapted to your needs:
EDIT: simplified code

Code: Select all

Procedure diamondfield(cx,cy,rayon,color=$ffffff)  
  x = -1000
  x1 = x + 600
  y1 = y + 600
  
  While x1 < 3000 
    
    x1 = x1 + 20
    x = x + 20
    
    LineXY(x,y,x1,y1,color) 
    LineXY(x,y1,x1,y,color) 
  Wend 
EndProcedure 

OpenWindow(0, 0, 0, 800, 600, "diamondfield", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget) 

CanvasGadget(222, 0,0,800, 600)

StartDrawing(CanvasOutput(222))
Box(0,0,999,799,0) 

diamondfield(x+50,y,50,$ffffff) 

StopDrawing()   

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow  
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: Pressed / grid look

Post by kinglestat »

that's really perfect @firace
Thank you
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
collectordave
Addict
Addict
Posts: 1309
Joined: Fri Aug 28, 2015 6:10 pm
Location: Portugal

Re: Pressed / grid look

Post by collectordave »

kinglestat wrote: Thu Sep 16, 2021 4:59 pm @collectordave

your example is defective...it does make 1 line of diamonds but does not fill the image
Hi

If you check your code the image you create is 100 wide and 40 high.

My code use values for x between 0 and 100 and values for y between 0 and 40 filling the image.

Now if you had read my post it asks you to choose how big.

Please read the whole post in future.
Any intelligent fool can make things bigger and more complex. It takes a touch of genius — and a lot of courage to move in the opposite direction.
kinglestat
Enthusiast
Enthusiast
Posts: 732
Joined: Fri Jul 14, 2006 8:53 pm
Location: Malta
Contact:

Re: Pressed / grid look

Post by kinglestat »

@collectordave
relax. It was not a slight at you. I didn't understand it, and didn't manage to make it work. But thanks for the help, I appreciate it.
I may not help with your coding
Just ask about mental issues!

http://www.lulu.com/spotlight/kingwolf
http://www.sen3.net
Post Reply