
-----------------------------------
MihaiG
Sat Feb 25, 2006 1:47 pm

semi shading?
-----------------------------------
well this is sortoff a shading program i am working on.....its ok so far..

but i need some tips on optimizing...

and i cant get it to work so u draw in -y or - x direction from where mosue is clicked and dragged

and how can i make it more efficient :?:

setscreen ("graphics:max;max")
var mx, my, mb : int

proc shade (x1, y1, x2, y2 : int, col : int)
    for decreasing j : y2 .. y1 by 3
        for i : x1 .. x2 by 3
            Draw.Dot (i, j, col)
        end for
    end for
    for decreasing j : y2 - 1 .. y1 by 3
        for i : x1 + 1 .. x2 - 1 by 3
            Draw.Dot (i, j, col)
        end for
    end for
end shade

var temp := 1
var x1, y1, x2, y2 : int := 0
var chars : array char of boolean

Pic.ScreenLoad ("C:/water.jpg", 100, 100, picUnderMerge)%add a picture to see a bit how it works
loop
    Mouse.Where (mx, my, mb)

    Input.KeyDown (chars)
    if chars ('t') then
        put "The T key is pressed"
    end if
    if mb = 1 and temp = 1 then
        x1 := mx
        y1 := my
        temp := 0
    elsif mb = 1 and temp = 0 then
        x2 := mx
        y2 := my
        shade (x1, y1, x2, y2, 15)
    elsif mb = 0 then
        temp := 1
    end if

end loop



-----------------------------------
Delos
Mon Feb 27, 2006 10:35 am


-----------------------------------
For your shade proc, try this instead:


proc shade (x1, y1, x2, y2 : int, col : int)
    for i : min (x1, x2) .. max (x1, x2) by 3
        for j : min (y1, y2) .. max (y1, y2) by 3
            Draw.Dot (i, j, col)
        end for
    end for
    % etc
end shade


Neat, eh?

Now, for your main loop, look into Mouse.ButtonWait() and Mouse.ButtonMoved().  Specifically, look at the example that comes with F10.  You should be able to edit that to get something.  The best I was able to come up with (without too much work) was one where you click at one point, drag, release, and a clean shading is drawn.  The only set back was that there was no indicator as to where the box would start and end...but that's not too difficult to get around.

No, not posting my code was not a mistake...I'll let you mull over it a little bit before I do that.  Uh, if I do...

-----------------------------------
MihaiG
Mon Feb 27, 2006 6:41 pm


-----------------------------------
well...you read my mind... i am working on that kind of program like drag and release...but i want to make it so when you draw and move the mouse the shading gradient thingy doesn change and it doesnt look like grey lines but grey dots.. :arrow:

-----------------------------------
batman
Thu Mar 02, 2006 9:00 pm

Shading program
-----------------------------------
Your shading program didn"t work on my computer. Nothing was outputed on the output screen.

-----------------------------------
[Gandalf]
Thu Mar 02, 2006 9:43 pm


-----------------------------------
If it doesn't work, that is your computer's fault.  More likely, you didn't check to see what the program does.  It doesn't output anything by default, try clicking around with the mouse, clicking and dragging.

-----------------------------------
batman
Thu Mar 02, 2006 9:50 pm

shading program
-----------------------------------
Oh! Ok after I clicked around and did it the right way this time, the program is pretty cool. Its easier for some reason to shade in the middle part of the screen then in the far end corners though.

-----------------------------------
DaftPunk
Thu Mar 02, 2006 11:45 pm

Cool
-----------------------------------
This little code is pretty cool. Although on my screen it only shows up the first time I drag and drop. What are you planning on doing with it? Just shading pics?

-----------------------------------
Booya
Sun Mar 05, 2006 7:08 pm

Shading Program
-----------------------------------
Awesome shading program your really talented at turing.

-----------------------------------
do_pete
Tue Mar 07, 2006 1:47 pm


-----------------------------------
You could try something like this, but it is too slow to be practicle
proc shade (x1, y1, x2, y2 : int, col : int)
    for i : min (x1, x2) .. max (x1, x2)
        for j : min (y1, y2) .. max (y1, y2)
            var Colour : int
            var r, g, b : real
            var Colour2 : int
            Colour := whatdotcolour (i, j)
            RGB.GetColour (Colour, r, g, b)
            Colour2 := RGB.AddColour (r / 2, g / 2, b / 2)
            Draw.Dot (i, j, Colour2)
        end for
    end for
end shade

-----------------------------------
MihaiG
Tue Mar 07, 2006 8:18 pm


-----------------------------------
ya...ur combining olours...thats really slow...and u rdoing it for eveyr pixel


do it for eveyr other one and i twould run way faster.. :)

-----------------------------------
MysticVegeta
Wed Mar 08, 2006 10:47 pm


-----------------------------------
yes but then it loses its effect too =\

-----------------------------------
do_pete
Thu Mar 09, 2006 12:37 pm


-----------------------------------
Is there a way to make it quicker without losing the effect?

-----------------------------------
MihaiG
Thu Mar 09, 2006 6:50 pm


-----------------------------------
think about it


if u drag a box 10x10 its 100 pixels so ur doing that calculation 100 times...ok.



lets say ur box is 100,100 = 10,000 

that starts to get really slow

and finaly if our box is 400,700

its 280,000 pixels it has to calculate 


so its gonna be very inneficient  :(
