0

I'm trying to create a torch item in my game, that will light bitmaps\bitmap that are behind him in a circle shape (for example torch in terraria), so basically I'm trying to understand how to create a bright circle. example picture made in photoshop: http://puu.sh/evqet/4277f7e2c8.png

anyone has idea how can I do that?

SpoocyCrep
  • 604
  • 7
  • 23

2 Answers2

0

There many ways to achieve this. One (fast) is to use the HSL color space and increase the L parameter foe example. I don't know if you are working with RGB if there is an easy way around it.

I guess since you probably wont want to check every pixel in the circle you may need to add a second circle semi-opaque for example which will make the calculation easier for you.

Eypros
  • 5,370
  • 6
  • 42
  • 75
  • so I need to check every pixel inside a circle and change the L parameter? what if I want it to be custom light, like yellow torch and blue torch will add some color and light it up? – SpoocyCrep Jan 14 '15 at 14:39
  • Like I said the first method is maybe too demanding but on the semi-opaque you can select a different color as easily instead of a neutral white one, like yellow etc and it will work fine – Eypros Jan 14 '15 at 14:52
  • I cant find a source code of running on every pixel in a bitmap in a circle shape, i managed to find one for the whole bitmap but not as a circle – SpoocyCrep Jan 14 '15 at 20:56
0

You can simply use a transparent PNG sprite and draw it as a bitmap in your canvas at desidered position.

More info about how-to-do can be found here and here.

Community
  • 1
  • 1
bonnyz
  • 13,458
  • 5
  • 46
  • 70
  • that won't work, i want the torch to work on any image and while i move it the circle will move with it – SpoocyCrep Jan 14 '15 at 15:22
  • This depends on how you implement it. Just an idea: you can create a stretchable torch sprite and save to a PNG and use it as a MASK while drawing the image by multiplying the image pixel in the "masked" region by a brigther value. – bonnyz Jan 14 '15 at 15:30
  • Uhm I don't really understand you :( – SpoocyCrep Jan 14 '15 at 16:09
  • I've edited the answer by adding one more link. Take a look :) – bonnyz Jan 14 '15 at 16:28
  • I see, but in my case each bitmap is small, they are blocks that connect together into one and ontop of them i want to draw the circle, so it doesn't really work out with my problem. – SpoocyCrep Jan 14 '15 at 19:54