Skip to main content
removed extraneous tags
Link
Quill
  • 12.1k
  • 5
  • 41
  • 94
edited tags
Link
200_success
  • 145.6k
  • 22
  • 191
  • 481
deleted 378 characters in body; edited tags; edited title
Source Link
Jamal
  • 35.2k
  • 13
  • 134
  • 238

Improve this retrocomputing Retrocomputing scanline function [Chrome only]

I need to refactor this code, targeted to Google Chrome (current+) to make it manageable going forward. My brain seems to be turning to a kind of workable mush, I'm not even sure if I'm thinking or not.

HereHere is a working jsbinJSBin of the idea: http://jsbin.com/unazig/1/.

I want to really tighten up the js, but mush brain has other plans. Even this question is crap, I started to tag it 'stackoverflow'. Awesome.

    function scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line) {
            line = line || 0;
            if(line >= lines) {
                    el_fin_callback();
                    return; // scan finished
            }
            var current_line = real_height*line;    
            var line_os = $(el).offset();
            line_os.top += current_line;
            if(lines > 1) {
                    $(mask)[0].style.height = real_height+'px';
            }
            $(sub_mask).css( { 
                    'height' : $(el).height()-real_height-current_line } );
            $(mask).offset(line_os);
            line_os.top += real_height;
            var length = Math.ceil($(el).text().length*real_width)+push;
            if(lines > 1) {
                    length = $(el).width();
            }
            $(sub_mask).offset(line_os);
            function next_line() { // callback after scan complete
                    scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line+1);
            }
            run_line_scan(length,mask,next_line);
    }

Improve this retrocomputing scanline function [Chrome only]

I need to refactor this code, targeted to Google Chrome (current+) to make it manageable going forward. My brain seems to be turning to a kind of workable mush, I'm not even sure if I'm thinking or not.

Here is a working jsbin of the idea: http://jsbin.com/unazig/1/

I want to really tighten up the js, but mush brain has other plans. Even this question is crap, I started to tag it 'stackoverflow'. Awesome.

    function scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line) {
            line = line || 0;
            if(line >= lines) {
                    el_fin_callback();
                    return; // scan finished
            }
            var current_line = real_height*line;    
            var line_os = $(el).offset();
            line_os.top += current_line;
            if(lines > 1) {
                    $(mask)[0].style.height = real_height+'px';
            }
            $(sub_mask).css( { 
                    'height' : $(el).height()-real_height-current_line } );
            $(mask).offset(line_os);
            line_os.top += real_height;
            var length = Math.ceil($(el).text().length*real_width)+push;
            if(lines > 1) {
                    length = $(el).width();
            }
            $(sub_mask).offset(line_os);
            function next_line() { // callback after scan complete
                    scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line+1);
            }
            run_line_scan(length,mask,next_line);
    }

Retrocomputing scanline function

I need to refactor this code, targeted to Google Chrome (current+) to make it manageable going forward.

Here is a working JSBin of the idea.

function scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line) {
        line = line || 0;
        if(line >= lines) {
                el_fin_callback();
                return; // scan finished
        }
        var current_line = real_height*line;    
        var line_os = $(el).offset();
        line_os.top += current_line;
        if(lines > 1) {
                $(mask)[0].style.height = real_height+'px';
        }
        $(sub_mask).css( { 
                'height' : $(el).height()-real_height-current_line } );
        $(mask).offset(line_os);
        line_os.top += real_height;
        var length = Math.ceil($(el).text().length*real_width)+push;
        if(lines > 1) {
                length = $(el).width();
        }
        $(sub_mask).offset(line_os);
        function next_line() { // callback after scan complete
                scan_el(el_fin_callback,el,mask,sub_mask,real_height,real_width,push,lines,line+1);
        }
        run_line_scan(length,mask,next_line);
}
explicit
Source Link
Loading
Source Link
Loading