Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8688367
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:20:42+00:00 2026-06-12T23:20:42+00:00

I got a idea if I could make a text file and that would

  • 0

I got a idea if I could make a text file and that would be rendered to pixels. First test succeed. I had one pixel for it. Now when I put more pixels, it will not work. Here is the code:

xhr=new XMLHttpRequest();
xhr.open("GET", "graphtest.prg", false);
xhr.send();
document.write(xhr.responseText);
var file=xhr.responseText;
var c=0;
var bad=false;
var val=0;
var rgbs="rgb(";
while(c<file.length && bad==false) {
    //alert(file.charAt(c));
    cc=file.charAt(c);
    if (cc=="P" || cc=="R" || cc=="G") {
        // magic
    }
    else {
        if (cc=="{") {
            if (val!=5) {
                var newelem=document.createElement("span");
                newelem.innerHTML="&nbsp;";
                /*newelem.style.width="1px";
                newelem.style.height="1px";
                newelem.position="absolute";*/
                newelem.className="graf";
            }
        }
        else if (cc=="'") {
            c++;
            cc=file.charAt(c);
            switch (val) {
                case 0:
                    //alert("RUN");
                    var num=""+cc.toString();
                    c++;
                    while(!isNaN(file.charAt(c))) {
                        num+=file.charAt(c).toString();
                        c++;
                    }
                    newelem.style.left=num+"px";
                    //alert(num);
                    val++;
                    c++;
                    continue;
                    break;
                case 1:
                    var num=""+cc.toString();
                    c++;
                    while(!isNaN(file.charAt(c))) {
                        num+=file.charAt(c).toString();
                        c++;
                    }
                    newelem.style.top=num+"px";
                    //alert(num);
                    val++;
                    c++;
                    continue;
                    break;
                case 2:
                    var num=""+cc.toString();
                    c++;
                    while(!isNaN(file.charAt(c))) {
                        num+=file.charAt(c).toString();
                        c++;
                    }
                    rgbs+=num+",";
                    //alert(num);
                    val++;
                    c++;
                    continue;
                    break;
                case 3:
                    var num=""+cc.toString();
                    c++;
                    while(!isNaN(file.charAt(c))) {
                        num+=file.charAt(c).toString();
                        c++;
                    }
                    rgbs+=num+",";
                    //alert(num);
                    val++;
                    c++;
                    continue;
                    break;
                case 4:
                    var num=""+cc.toString();
                    c++;
                    while(!isNaN(file.charAt(c))) {
                        num+=file.charAt(c).toString();
                        c++;
                    }
                    rgbs+=num+")";
                    //alert(num);
                    val++;
                    c++;
                    continue;
                    break;
                case 5:
                    newelem.style.backgroundColor=rgbs;
                    document.body.appendChild(newelem);
                    val=0;
                    rgbs="";
                    newelem=null;
                    cc="";
                    num="";
                    break;
            }
        }
        if (val==5) {
            newelem.style.backgroundColor=rgbs;
            document.body.appendChild(newelem);
            val=0;
            rgbs="";
            //newelem=null;
            //c;
            alert(file.charAt(c));
            cc="";
            num="";
        }
    }
    c++;
}

Here is the “graphic text” file:

PRG{'100','200','0','255','0'}{'200','100','0','0','255'}

The first pixel is rendered successfully, but the second pixel won’t have a background color. Is this a parsing problem or something else?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:20:44+00:00Added an answer on June 12, 2026 at 11:20 pm

    Right now the parser is confusing because of the big amount of repeated code. In every single of your switch case you repeat a lot of the same code, which isn’t necessary.

    Other than that the one thing I notice is that your rgbs var is initialized with var rgbs="rgb("; at the beginning of your script, but then is reinitialized with rgbs=""; at the end of a pixel parse.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make this test pass - anyone got an idea how to
So I got this crazy idea I could make make something cool work. I
I'm working on a little experiment here. I've got a test file that I
I just got this question on an interview and had no idea how to
Got an idea: functions (in FP) could be composed similar ways as components in
Sorry I had no idea how set a topic which could express what help
I'd like to make a function that receives a 2-dimensional array and returns one
I have got idea of how to build a website in 2 languages, i
Has anybody got an idea of how to create a .Contains(string) function using Linq
Has anyone got any idea why the menu is rendering below the rotating images

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.