
-----------------------------------
Daetyrnis
Fri Aug 24, 2007 4:17 pm

Palettes
-----------------------------------
Anyone who's looked into how graphics in video games (at least the general 2D ones as far as I know) will learn what palettes are.  At first, these limitations can seem annoying, but upon rethinking various situations, palettes can make your life much easier.  The simplest benefit of palettes is - of course - recolouring images, right?  This enemy is normally green, but later on, he's blue!  See what I mean?

Anyways, I was wondering if there is a way to implement palettes in Turing that work with pictures.  I am aware of the 256 colours available, able to be changed at a whim (and added onto, I believe the maximum was 1024?).  This serves perfectly as a palette for Turing-based draw operations, such as drawing text, boxes, lines, dots, et cetera.  But, what about pictures?

Is there a way that I could display a picture file with the colours in the palette?  So far, all I can think of is to create a sort of custom-Pic.Draw process that draws a given picture pixel by pixel, and possibly with palette functionality.  Is there a simpler way?

-----------------------------------
rizzix
Fri Aug 24, 2007 4:22 pm

RE:Palettes
-----------------------------------
As far as a custom Pic.Draw is concerned, this might help: [url=http://compsci.ca/v3/viewtopic.php?t=2235&highlight=bitmap] bitmap library

:P

-----------------------------------
Flikerator
Mon Aug 27, 2007 11:55 pm

Re: Palettes
-----------------------------------
Drawing pixel-by pixel in turing is extremely slow.

Heres to show the speed difference:

View.Set ("offscreenonly")
colorback (42)

var tTime : int := Time.Elapsed
for i : 1 .. maxx
    for j : 1 .. maxy
        Draw.Dot (i, j, red)
    end for
end for

put "Total time to draw pixel by pixel: ", (Time.Elapsed - tTime) / 1000, " seconds"
View.Update
Input.Pause

tTime := Time.Elapsed
cls
put "Total time to clear screen: ", (Time.Elapsed - tTime) / 1000, " seconds"
View.Update


The reason is, and this is a guess, cls applies a single colored buffer, and drawing pixel-by-pixel changes a buffer (Its even slower without offscreenonly, since it changes directly to the screen instead of a buffer). However, you will notice that without offscreenonly, cls is still just as fast, since it applies a buffer to the screen rather then redrawing; so it takes the same time as View.Update takes anytime.

Thats my guess anyway.
