1. Post #2201
    Gold Member
    Dr Magnusson's Avatar
    July 2008
    2,642 Posts
    I can get the world position of panels, and I have a push/pop method that is ready to have some code put into it.
    But look, here is the problem with your method:
    I can't have subpanels clip and their parents with a different clip. That's why I can't just use g.setWorldClip, because you can't "stack" the clips.
    That's why you keep track of clips using a stack like Dajoh said.

    Here's a really quick example I wrote up in lua:
    local clip = {stack = {{x =0, y = 0, w = 3000, h = 3000}}, current = {x =0, y = 0, w = 3000, h = 3000}}
    
    function clip.push(x, y, w, h)
        local c = clip.current
        
        -- If the new region is smaller in any way than the old region, compress the current region to fit.
        if(x + w < c.x + c.w) then c.w = w end
        if(y + h < c.y + c.h) then c.h = h end    
        if(x > c.x) then c.x = x end
        if(y > c.y) then c.y = y end
        table.insert(clip.stack, {x = x, y = y, w = w, h = h})
    end
    
    function clip.pop()
        if(#clip.stack <= 0) then return end
        -- Remove the "current" stack
        table.remove(clip.stack, #clip.stack)
        
        local c = clip.current
        local o = clip.stack[#clip.stack]
        
        -- If the old region on the stack is bigger in any way, expand the relevant component to fit.
        if(o.x + o.w > c.x + c.w) then c.w = o.w end
        if(o.y + o.h > c.y + c.h) then c.h = o.h end    
        if(o.x < c.x) then c.x = o.x end
        if(o.y < c.y) then c.y = o.y end
    end
    
    function clip.getRegion()
        return clip.current.x, clip.current.y, clip.current.w, clip.current.h
    end
    
    -- Tests
    print("start: ", clip.getRegion())
    clip.push(10, 10, 200, 200)
    print("push: ", clip.getRegion())
    clip.push(50, 10, 50, 200)
    print("push: ", clip.getRegion())
    clip.push(10, 70, 200, 130)
    print("push: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    

    It outputs this, which is the expected output. It's basically the smallest possible region that doesn't expand beyond any of the given points.
    Code:
    lua clip.lua
    start:  0       0       3000    3000
    push:   10      10      200     200
    push:   50      10      50      200
    push:   50      70      50      130
    pop:    50      10      50      200
    pop:    10      10      200     200
    pop:    0       0       3000    3000
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events Programming King Programming King x 2Funny Funny x 1Agree Agree x 1 (list)

  2. Post #2202
    jonnopon3000's Avatar
    August 2009
    380 Posts
    Progress on my stab at rendering an image as text!
    After some modifications and working it through to find the issue with the colouration, I have managed to turn this:



    Into this:



    Right now, the only character it writes in is +'s, and there is an inevitable smoothing issue due to the way I am doing it. When I process a coloured striped image similar to the test above, I only get half of the image processed...so I've gotta find out why.
    Next stages are implementing a character set and refining the method to produce a more detailed and accurate representation of the colours in a processed image.

    For anyone who is interested, here's the source :)
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Programming King Programming King x 2 (list)

  3. Post #2203
    Map in a box's Avatar
    July 2009
    5,801 Posts
    That's why you keep track of clips using a stack like Dajoh said.

    Here's a really quick example I wrote up in lua:
    local clip = {stack = {{x =0, y = 0, w = 3000, h = 3000}}, current = {x =0, y = 0, w = 3000, h = 3000}}
    
    function clip.push(x, y, w, h)
        local c = clip.current
        
        -- If the new region is smaller in any way than the old region, compress the current region to fit.
        if(x + w < c.x + c.w) then c.w = w end
        if(y + h < c.y + c.h) then c.h = h end    
        if(x > c.x) then c.x = x end
        if(y > c.y) then c.y = y end
        table.insert(clip.stack, {x = x, y = y, w = w, h = h})
    end
    
    function clip.pop()
        if(#clip.stack <= 0) then return end
        -- Remove the "current" stack
        table.remove(clip.stack, #clip.stack)
        
        local c = clip.current
        local o = clip.stack[#clip.stack]
        
        -- If the old region on the stack is bigger in any way, expand the relevant component to fit.
        if(o.x + o.w > c.x + c.w) then c.w = o.w end
        if(o.y + o.h > c.y + c.h) then c.h = o.h end    
        if(o.x < c.x) then c.x = o.x end
        if(o.y < c.y) then c.y = o.y end
    end
    
    function clip.getRegion()
        return clip.current.x, clip.current.y, clip.current.w, clip.current.h
    end
    
    -- Tests
    print("start: ", clip.getRegion())
    clip.push(10, 10, 200, 200)
    print("push: ", clip.getRegion())
    clip.push(50, 10, 50, 200)
    print("push: ", clip.getRegion())
    clip.push(10, 70, 200, 130)
    print("push: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    clip.pop()
    print("pop: ", clip.getRegion())
    

    It outputs this, which is the expected output. It's basically the smallest possible region that doesn't expand beyond any of the given points.
    Code:
    lua clip.lua
    start:  0       0       3000    3000
    push:   10      10      200     200
    push:   50      10      50      200
    push:   50      70      50      130
    pop:    50      10      50      200
    pop:    10      10      200     200
    pop:    0       0       3000    3000
    The children need to be clipped to the parents, too.
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events Agree Agree x 1 (list)

  4. Post #2204
    Gold Member
    Dr Magnusson's Avatar
    July 2008
    2,642 Posts
    The children need to be clipped to the parents, too.
    Then push the panel's clipping region as you traverse down the chain of panels as you draw them.
    function Panel:draw()
        clip.push(self.x, self.y, self.w, self.h)
        g.setClipRegion(clip.getRegion())
        -- Draw panel here
        for _, child in pairs(self.children) do
            child:draw()
        end
        clip.pop()
    end
    
    I don't know what I'm supposed to be explaining to you at this point, all the tools for doing what you want are by your fingertips.
    Reply With Quote Edit / Delete Windows 7 Denmark Show Events

  5. Post #2205
    Gold Member
    Deco Da Man's Avatar
    July 2007
    1,005 Posts
    The children need to be clipped to the parents, too.
    Here's the solution I used for my LÖVE GUI library:
        function Panel:render(ax, ay, aw, ah)
            local X, Y = self.X, self.Y
            local nax, nay = ax+X, ay+Y
            --print(self, aw-X, self.W)
            local naw, nah = math.min(aw-X, self.W), math.min(ah-Y, self.H)
            if naw > 0 and nah > 0 then
                love.graphics.push()
                    love.graphics.translate(X, Y)
                    love.graphics.setScissor(nax, nay, naw, nah)
                    self:draw()
                    local children = self.Children
                    for child_i = 1, #children do
                        children[child_i]:render(nax, nay, naw, nah)
                    end
                love.graphics.pop()
            end
            love.graphics.setScissor()
        end
    
    Reply With Quote Edit / Delete Windows 7 Australia Show Events

  6. Post #2206
    ..............
    nekosune's Avatar
    February 2009
    1,827 Posts
    Currently waiting for the www.udacity.com courses to start
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  7. Post #2207
    Paulendy's Avatar
    January 2008
    631 Posts
    Programming courses are cool and all but the write ups are fucking annoying.

    Reply With Quote Edit / Delete Windows 7 Guernsey Show Events Agree Agree x 9Dumb Dumb x 1Funny Funny x 1 (list)

  8. Post #2208
    Map in a box's Avatar
    July 2009
    5,801 Posts
    Then push the panel's clipping region as you traverse down the chain of panels as you draw them.
    function Panel:draw()
        clip.push(self.x, self.y, self.w, self.h)
        g.setClipRegion(clip.getRegion())
        -- Draw panel here
        for _, child in pairs(self.children) do
            child:draw()
        end
        clip.pop()
    end
    
    I don't know what I'm supposed to be explaining to you at this point, all the tools for doing what you want are by your fingertips.
    Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report.

    Edited:

    What I'm working on: A web browser.
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events Funny Funny x 2Dumb Dumb x 1 (list)

  9. Post #2209
    This title has been removed due to a copyright claim from Viacom Inc.
    neos300's Avatar
    July 2008
    3,404 Posts
    Malbodge.

    I'm going to go drill a hole in my head now.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Funny Funny x 1Agree Agree x 1 (list)

  10. Post #2210
    Gold Member
    Downsider's Avatar
    July 2007
    1,718 Posts
    Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report.

    Edited:

    What I'm working on: A web browser.
    There's only one thing you need support for, and that's clipping before you actually render. Does Slick2D do that? In other words, in your tests, is only one clip applying, and that clip being the last clip you perform?

    If not, then Slick2D provides everything you need.. except a brain, of course.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  11. Post #2211
    Gold Member
    ROBO_DONUT's Avatar
    March 2005
    3,028 Posts
    Slick2D doesn't support stacked clips, which was my main problem to begin with. I'll just make a bug report.
    It's going to get ignored. You have everything you need already, and I've given you the answer.

    If you want to find the region where rectangles overlap, you find the minimum of the maximum bounds and the maximum of the minimum bounds. So as you're traversing the UI elements, you calculate and apply the new clip region as described. If you use recursion, you don't even need to write any fancy data structures, classes or subroutines to keep track of the clip regions, since each stack frame will have the correct clip region for that UI element.
    Reply With Quote Edit / Delete Windows 7 Show Events

  12. Post #2212
    Gold Member
    iPope's Avatar
    October 2008
    1,732 Posts
    Programming courses are cool and all but the write ups are fucking annoying.

    -snip img-
    Your telling me! I have to make a table of every variable in my code and every fucking function it's used in with a page referance to that code page. What the fuck is the use of that?
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 1 (list)

  13. Post #2213
    Map in a box's Avatar
    July 2009
    5,801 Posts
    Yes, unfortunately. I need to clip all the children and the subchildren, like what I do when I translate them.

    Edited:

    It's going to get ignored. You have everything you need already, and I've given you the answer.

    If you want to find the region where rectangles overlap, you find the minimum of the maximum bounds and the maximum of the minimum bounds. So as you're traversing the UI elements, you calculate and apply the new clip region as described. If you use recursion, you don't even need to write any fancy data structures, classes or subroutines to keep track of the clip regions, since each stack frame will have the correct clip region for that UI element.
    Look, with your method a subpanel could clip outside of its root panel. That is why I'm saying it won't work.
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events Dumb Dumb x 3 (list)

  14. Post #2214
    ben1066's Avatar
    August 2009
    530 Posts
    uh, alien swarm already has vscript
    Indeed it does, however vscript is closed source, by implementing it myself I have greater access.
    Reply With Quote Edit / Delete Windows 8 United Kingdom Show Events Agree Agree x 1 (list)

  15. Post #2215
    ASK ME ABOUT MY PLAYBOOK INSTEAD OF COLLEGE
    icantread49's Avatar
    April 2011
    1,610 Posts
    Look, with your method a subpanel could clip outside of its root panel. That is why I'm saying it won't work.
    dude

    no, it can't

    you find the intersection of your stack of clip rectangles, and you set that as the final clip rectangle

    Edited:

    Reply With Quote Edit / Delete Windows XP United States Show Events Zing Zing x 1 (list)

  16. Post #2216
    Gold Member
    ROBO_DONUT's Avatar
    March 2005
    3,028 Posts
    Look, with your method a subpanel could clip outside of its root panel.
    No, it can't. That doesn't even make sense.

    What you want is the intersection of the set of pixels, applied recursively as you traverse the UI tree.
    So, we start with a full-screen rectangle denoted 'A'. For the first (root) UI element, confined to rectangle 'B', the drawable region is 'A∩B'. Then for the first child, in rectangle 'C', the drawable region would be '(A∩B)∩C'. That is, we take the previous calculated result ('A∩B'), and intersect that with the clip region for the current UI element, 'C', resulting in 'A∩B∩C'. Every clip region for every parent, child, and sub-child all the way up and down the chain is accounted for. All you need is the formula for the intersection of rectangles, which I've given to you.

    It's:
    Code:
    x_min = max(x_min, current.x_min);
    x_max = min(x_max, current.x_max);
    y_min = max(y_min, current.y_min);
    y_max = min(y_max, current.y_max);
    if (x_min > x_max || y_min > y_max) {
      // no visible pixels
      return;
    }
    Apply recursively.
    Reply With Quote Edit / Delete Windows 7 Show Events

  17. Post #2217
    kill yourself
    Protocol7's Avatar
    June 2006
    21,717 Posts
    Finally wrote a hello world.

    In Java.

    For Android.

    It's actually not terrible. But when I write Java something about everything kind of irks me
    Reply With Quote Edit / Delete Windows 7 United States Show Events Programming King Programming King x 5Agree Agree x 2 (list)

  18. Post #2218
    Map in a box's Avatar
    July 2009
    5,801 Posts
    I'm sorry, you're just confusing me even more. I'll work on clipping later.
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events Dumb Dumb x 7Funny Funny x 2 (list)

  19. Post #2219


    Game == setup
    Reply With Quote Edit / Delete Windows 8 Netherlands Show Events Winner Winner x 1 (list)

  20. Post #2220
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    3,976 Posts


    Just another day in Programmers Chat.
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Funny Funny x 15Agree Agree x 1 (list)

  21. Post #2221
    Gold Member
    BlkDucky's Avatar
    May 2008
    6,136 Posts


    Just another day in Programmers Chat.
    oh man

    it's basically a list of people I've wanted to ban from that chat but for some reason Jallen won't let me.

    edit: except you of course, stan
    Reply With Quote Edit / Delete Windows Vista United Kingdom Show Events Funny Funny x 6Friendly Friendly x 3Winner Winner x 1 (list)

  22. Post #2222
    ASK ME ABOUT MY PLAYBOOK INSTEAD OF COLLEGE
    icantread49's Avatar
    April 2011
    1,610 Posts
    someone made me a theme song in FP chat!

    http://puu.sh/hxYH
    Reply With Quote Edit / Delete Windows XP United States Show Events Dumb Dumb x 4Funny Funny x 2 (list)

  23. Post #2223
    Map in a box's Avatar
    July 2009
    5,801 Posts
    Fixing key input in my web browser and i'll show it off. Because I'm proud of et.
    Reply With Quote Edit / Delete Windows XP Professional x64 United States Show Events Dumb Dumb x 2 (list)

  24. Post #2224
    Slaaf van EternalFlamez.Ik wilde heel graag de laatste Indie Bundle, en ik kreeg deze kuttitel er gratis bij.
    Staneh's Avatar
    March 2010
    3,976 Posts
    AGOP
    Reply With Quote Edit / Delete Windows 7 Netherlands Show Events Dumb Dumb x 2Agree Agree x 1 (list)

  25. Post #2225
    ASK ME ABOUT MY PLAYBOOK INSTEAD OF COLLEGE
    icantread49's Avatar
    April 2011
    1,610 Posts
    ~~SHI~RI~~NIAN~~
    Reply With Quote Edit / Delete Windows XP United States Show Events Dumb Dumb x 3Funny Funny x 2Artistic Artistic x 2 (list)

  26. Post #2226
    BOSSMAN
    leontodd's Avatar
    January 2009
    4,067 Posts
    someone made me a theme song in FP chat!

    http://puu.sh/hxYH
    Better than the original, downloading this now.
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events

  27. Post #2227
    Paid for a title.
    Maurice's Avatar
    June 2005
    6,080 Posts
    Better than the original, downloading this now.
    Contradiction
    Reply With Quote Edit / Delete Windows 7 Germany Show Events

  28. Post #2228
    ASK ME ABOUT MY PLAYBOOK INSTEAD OF COLLEGE
    icantread49's Avatar
    April 2011
    1,610 Posts
    there was another one ?? tell me!
    Reply With Quote Edit / Delete Windows XP United States Show Events Dumb Dumb x 5 (list)

  29. Post #2229
    alexaz's Avatar
    October 2010
    146 Posts

    poor mans whiteboard :(
    Reply With Quote Edit / Delete Windows 7 Lithuania Show Events Friendly x 6Artistic x 2Funny x 2Optimistic x 1Dumb x 1Informative x 1 (list)

  30. Post #2230
    Gold Member
    ROBO_DONUT's Avatar
    March 2005
    3,028 Posts
    I think you mean awesome dude's whiteboard.
    I'll take graph paper over whiteboard anyday.
    Reply With Quote Edit / Delete Windows 7 Show Events Disagree Disagree x 12Agree Agree x 4Funny Funny x 1 (list)

  31. Post #2231
    Commie
    supersnail11's Avatar
    September 2008
    6,656 Posts
    I just noticed this on udacity's website:

    If they actually do that, that'd be awesome.
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  32. Post #2232
    ..............
    nekosune's Avatar
    February 2009
    1,827 Posts
    I just noticed this on udacity's website:

    If they actually do that, that'd be awesome.
    I would so sign up for that one as soon as you can enroll
    Reply With Quote Edit / Delete Windows 7 United Kingdom Show Events Agree Agree x 5 (list)

  33. Post #2233
    Moderator Illuminati
    Hexxeh's Avatar
    June 2006
    5,014 Posts
    Can anyone recommend a tool for Mac to record a window onscreen along with the systems audio output? I used Jing previously, but this outputs to SWF, and I want something that outputs to a sane format I can upload to YouTube.
    Reply With Quote Edit / Delete Mac United Kingdom Show Events

  34. Post #2234
    Reply With Quote Edit / Delete Windows 8 United Kingdom Show Events

  35. Post #2235
    Gold Member
    efeX's Avatar
    April 2009
    2,323 Posts

    poor mans whiteboard :(
    glad you drew that out, i hate when i forget the auth, inventory, damage, and entities are controlled by the server.
    Reply With Quote Edit / Delete Windows 7 United States Show Events Dumb Dumb x 8Funny Funny x 3Agree Agree x 2Disagree Disagree x 1 (list)

  36. Post #2236
    Commie
    supersnail11's Avatar
    September 2008
    6,656 Posts
    Can anyone recommend a tool for Mac to record a window onscreen along with the systems audio output? I used Jing previously, but this outputs to SWF, and I want something that outputs to a sane format I can upload to YouTube.
    ScreenFlow?
    Reply With Quote Edit / Delete Windows 7 United States Show Events

  37. Post #2237
    Gold Member
    HiredK's Avatar
    November 2006
    378 Posts
    I'm having a little issue with HDR,. This is the wanted result, only works if I render it directly to a screen quad



    However if I bind the output to a buffer I get a weird artifact... (I tried to change the buffer to GL_RGBA16F and to clamp/unclamp it but no luck) not sure what's causing it, anyone seen that before?

    Reply With Quote Edit / Delete Windows 7 Canada Show Events

  38. Post #2238
    alexaz's Avatar
    October 2010
    146 Posts
    glad you drew that out, i hate when i forget the auth, inventory, damage, and entities are controlled by the server.
    That shows 4 threads being controlled by the network thread.
    Reply With Quote Edit / Delete Windows 7 Lithuania Show Events

  39. Post #2239
    Gold Member
    Catdaemon's Avatar
    February 2005
    2,818 Posts


    Dem networked clocks. Aww yeah.
    Reply With Quote Edit / Delete Windows 7 Show Events

  40. Post #2240
    Hates php
    high's Avatar
    May 2006
    2,338 Posts
    Just rewrote one of my older programs(SpeedTest Forger) Decided to try WPF too. All I have to say is WOW. WPF is so much nicer than WinForms. Going to have to switch LoLNotes over to it.

    Did a time-lapse of it (recorded 2 fps, playback 12 fps).

    Here is a screenshot of it.


    And of course here is the source.
    https://github.com/high6/SpeedTest-Generator

    (I really should blog this kind of stuff :|)
    Reply With Quote Edit / Delete Windows 7 United States Show Events Programming King Programming King x 5Funny Funny x 3Disagree Disagree x 2 (list)