需要想法只显示一些像素并将剩余像素变灰
我正在寻找想法...为客户集思广益一个新项目...我有一张图像...300px x 300px ...我需要一次随机显示一个像素,直到整个图像显示完毕揭示了。
基本上,在一定的时间间隔内,一个像素会被显示并保持显示状态,而其他像素仍为空白。在每个时间间隔,随机显示另一个像素,并保持显示状态以加入其他显示的像素。最终,所有像素都会被揭示。
关于如何实现这一点有什么建议吗?
我可以制作大量图像副本并手动显示一个随机像素,但肯定可以通过编程来完成:)
哦,它不能是任何形式的闪存。
I'm looking for ideas ...brainstorming a new project for a client ....I have an image ...300px x 300px ...I need to display the image one random pixel at a time until the entire image is revealed.
Basically, at certain intervals, a pixel is revealed and remains revealed while other pixels are still blank. At each interval, another pixel at random is revealed and remains revealed to join the other revealed pixels. Eventually, all the pixels will be revealed.
Any suggestions on how to make that happen?
I could make numerous copies of the image and manually reveal one random pixel, but surely it can be done programatically :)
Oh, and it cannot be any form of flash.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
编辑:我意识到我误解了你需要做什么,但我认为这很酷,并且可以应用于你的问题...
查看以下内容的工作演示 →
我将其放在 jQuery 中。我实际上将每个像素制作为 3x3 框,因为否则处理时间会太长。尽管我还没有测试过 IE,但似乎在客户端的某些方面工作得很好。
查看工作示例→
EDIT: I realize I mis-interpreted what you needed to do, but I thought this was cool anyway and could be applied to your problem...
See working demo of the following →
I threw this together in jQuery. I made each pixel actually a 3x3 box instead because otherwise it would take way too long to process. Seems to work pretty well for something on this in client side, though I haven't tested IE yet.
See working example →
将图像文件加载到图像资源中 (imagecreatefrompng, < a href="http://www.php.net/manual/en/function.imagecreatefromgif.php" rel="nofollow">imagecreatefromgif 等)。
使用 rand() 或您想要选择的方式决定要显示哪些像素。
循环图像中的每个像素,如果不是您选择显示的像素,则使用 imagesetpixel。
Load the image file into an image resource (imagecreatefrompng, imagecreatefromgif, etc).
Decide what pixels to show, using rand() or however you want to choose them.
Loop over every pixel in the image, and if it's not one you chose to show, color it gray with imagesetpixel.