Reflection Effect

Just starting out? Need help? Post your questions and find answers here.
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Reflection Effect

Post by netmaestro »

Thanks for sharing that, RASHAD. It's another nice and compact implementation and it works well. My only concern with it is that the alpha drops off rather suddenly at the 2/3 mark. The dropoff is too sharp. If you look at the image in the first post, with the alpha reduced exponentially via the code from #NULL, you see that the alpha drops off quickly but yet still gradually. If you combine what you have with a variant of what #NULL supplied, we may have a viable alternative. Which we can always use. Please see what you can do.
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Reflection Effect

Post by RASHAD »

@NM I just added a new snippet to my previous post
Maybe we should use the vector lib all around
Will try it if I have some more time
Egypt my love
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8451
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: Reflection Effect

Post by netmaestro »

In threads like this one I really miss my friend srod. He really brings math to the masses, a rare and remarkable talent.
BERESHEIT
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4955
Joined: Sun Apr 12, 2009 6:27 am

Re: Reflection Effect

Post by RASHAD »

Agree not only for his talent with math but for more than that
But we still have Demivec ,Wilbert (Trond and I hope he is doing well)
Egypt my love
coder14
Enthusiast
Enthusiast
Posts: 327
Joined: Tue Jun 21, 2011 10:39 am

Re: Reflection Effect

Post by coder14 »

THANK YOU EVERYONE!!! :D :D :D

Really great codes. Now to study and understand them.

TBH after testing them I feel that netmaestro's results are the best for my needs - I increased the exponent and get the perfect fade that looks like a drop reflection. Very nice! :D

I'm grateful to all of you for your help.
User avatar
blueb
Addict
Addict
Posts: 1116
Joined: Sat Apr 26, 2003 2:15 pm
Location: Cuernavaca, Mexico

Re: Reflection Effect

Post by blueb »

netmaestro wrote:... If only I'd spent less time dipping pigtails in the inkwell and paid more attention in school I might know some of this stuff.
:lol: :lol:

We have the same disease.
- It was too lonely at the top.

System : PB 6.21(x64) and Win 11 Pro (x64)
Hardware: AMD Ryzen 9 5900X w/64 gigs Ram, AMD RX 6950 XT Graphics w/16gigs Mem
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Re: Reflection Effect

Post by Kwai chang caine »

Very very nice ..... :shock:
And very useful because, never i have a table enough clean in my house, for can have really this effect :mrgreen:
Thanks a lot at all for sharing 8)
ImageThe happiness is a road...
Not a destination
User avatar
Keya
Addict
Addict
Posts: 1890
Joined: Thu Jun 04, 2015 7:10 am

Re: Reflection Effect

Post by Keya »

blueb wrote:
netmaestro wrote:... If only I'd spent less time dipping pigtails in the inkwell and paid more attention in school I might know some of this stuff.
:lol: :lol:
We have the same disease.
or maybe just the same type of teachers like mine who never showed maths actually can be fun :(
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3943
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: Reflection Effect

Post by wilbert »

Looking a bit closer to the example in the first post, it looks like the reflection in the image is also blurred.
Windows (x64)
Raspberry Pi OS (Arm64)
SeregaZ
Enthusiast
Enthusiast
Posts: 628
Joined: Fri Feb 20, 2009 9:24 am
Location: Almaty (Kazakhstan. not Borat, but Triple G)
Contact:

Re: Reflection Effect

Post by SeregaZ »

no any new simplest solution for mirror image? i need some horisontal or vertical or both case. without this fade out or mix colors.
normeus
Enthusiast
Enthusiast
Posts: 472
Joined: Fri Apr 20, 2012 8:09 pm
Contact:

Re: Reflection Effect

Post by normeus »

This Procedure from @RASHAD's & @Netmaestro sample code:

Code: Select all

Procedure Image_Rotate(Image,Angle)
  nimgw = h*Sin(Angle*#PI/180)+w*Cos(Angle*#PI/180)
  nimgh = w*Sin(Angle*#PI/180) + h*Cos(Angle*#PI/180)

  temp=CreateImage(#PB_Any,nimgw,nimgh)
 
  Dim p.Point(2)
  p(0)\x=0
  p(0)\y=nimgh
  p(1)\x=nimgw
  p(1)\y=nimgh
  p(2)\x=0
  p(2)\y=0

  ImageDc = CreateCompatibleDC_(0)
  SelectObject_(ImageDc,ImageID(Image))
  dc=StartDrawing(ImageOutput(temp))
    PlgBlt_(dc,@p(),ImageDc,0,0,w,h,0,0,0)
  StopDrawing()
  CopyImage(temp,image)
  FreeImage(temp)
EndProcedure

flips the image.

see the full code here http://www.purebasic.fr/english/viewtop ... 37#p501437 and
around line 59 comment out ;FreeImage(10) then use image 10
around line 63 ImageGadget(1,0,h,w,h,ImageID(10))


send an image to it and it will flip it.

if you want vertical (horizontal?) change this section:

Code: Select all

;   p(0)\x=0
;   p(0)\y=nimgh
;   p(1)\x=nimgw
;   p(1)\y=nimgh
;   p(2)\x=0
;   p(2)\y=0
  
  p(0)\x=nimgw
  p(0)\y=0
  p(1)\x=0
  p(1)\y=0
  p(2)\x=nimgw
  p(2)\y=nimgh
[edit] added some code

Norm.
google Translate;Makes my jokes fall flat- Fait mes blagues tombent à plat- Machte meine Witze verpuffen- Eh cumpari ci vo sunari
Post Reply