#1 Members - Reputation: 139
Posted 25 August 2012 - 02:17 PM
Today i was working in FlashPunk. I couldn't find a background color function. (Its probably there but i dont really care).
But instead of that i just made 1 white pixel in photoshop (cause i needed a white background) and scaled it up to the screen width and height.
Now my own theory is that this should be fast cause it only has to load 1 pixel from a .jpg. But on the other side it has to calculate the scaling too.
So I am just wondering, is this an efficient way to make a white background? Or is this a bad way because of the scaling?
#2 Members - Reputation: 1015
Posted 25 August 2012 - 03:26 PM
So probably for each pixel it maps it to the source and interpolates stuff (which might be faster for a single pixel source)
idk. "Profile, profile, profile!!!1!1!!11" etcetc...
#3 Members - Reputation: 2763
Posted 25 August 2012 - 05:27 PM
Ignoring the scaling completely, which do you think is quicker -- copying one value to a million+ places one by one, or blasting those million places with a known value (that you don't have to read each time) in a straight shot. Analogy time: You have an empty pool, its your job to fill it. There's a water spigot 20 feet away. Do you run back and forth with a bucket, or find yourself a hose?
Edited by Ravyne, 25 August 2012 - 05:28 PM.
#4 Moderator* - Reputation: 5410
Posted 25 August 2012 - 06:20 PM
Definitely run back and forth with a bucketAnalogy time: You have an empty pool, its your job to fill it. There's a water spigot 20 feet away. Do you run back and forth with a bucket, or find yourself a hose?
@OP: I googled "FlashPunk set background color" and found this.
#5 Marketplace Seller - Reputation: 8956
Posted 25 August 2012 - 09:24 PM
@SoulRyder: Completely unrelated to your actual problem, but worth mentioning: A 1 pixel image should be saved as a BMP or a PNG, but not a JPEG because JPEGs would waste more space than necessary on such a small image - they're better at larger images with many varying values where the original image doens't need to be reproduced 100% accurately. PNGs are good for images small or large, with less color variance, or where the image needs to be exactly as it was originally (like pixel art).
All glory be to the Man at the right hand... On David's throne the King will reign, and the Government will rest upon His shoulders. All the earth will see the salvation of God.
Of Stranger Flames - [indie turn-based rpg set in a para-historical French colony] | Indie RPG development journal
#6 Members - Reputation: 139
Posted 26 August 2012 - 03:03 AM
Im going to use the background color function in flashpunk now.
I was just wondering if it was a good idea to do it with the 1 pixel, but not I know a bit better how it works and it doesnt sound like the best way to do it.
And thanks for the tip about the BMP, PNG JPG etc. Didnt know that yet.






