I just tried something straightforward (for me):

dummy = Import["http://pastebin.com/raw.php?i=g8D7NprC", "List"] & /@ col;
colors = dummy[[1]];
Graphics[{colors, Rectangle[{0, 0}]}]

Is it not possible to import color data from a file?

  • $\begingroup$ it works fine if you remove & /@ col at the end of the first line. $\endgroup$ – kglr Jun 3 '14 at 20:10
  • $\begingroup$ Ok I don't know much but now there is nothing happening. No output at all. Which is very weird when it works fine with you. It states "RGBColor[0, 0, 1] is not a Graphics primitive or directive" $\endgroup$ – MaxJ Jun 3 '14 at 20:17
  • 2
    $\begingroup$ I think it is because your colors is a string; to change it to a color directive use ToExpression@colors... $\endgroup$ – kglr Jun 3 '14 at 20:25
  • 1
    $\begingroup$ Or just color = << "http://pastebin.com/raw.php?i=GXbeGrcD". $\endgroup$ – user484 Jun 3 '14 at 20:25
  • 1
    $\begingroup$ @user3683367 - you oversimplified your question. what does your file to be imported REALLY look like? does it contain DIFFERENT colors, a list of colors ? But even in this case: How, exactly, do you want to color ONE rectangle with these different colors? $\endgroup$ – eldo Jun 3 '14 at 20:40

I think you need something like the following:

 dummy = Import["http://pastebin.com/raw.php?i=g8D7NprC", "List"];
 colors = ToExpression /@ dummy;
 Graphics[Thread[{colors, Rectangle/@ RandomInteger[10, {5, 2}]}]]

enter image description here

| improve this answer | |
  • $\begingroup$ Yes this is exactly what I wanted. Would you recommend using "Thread" or "Sequence" like in the following question: mathematica.stackexchange.com/questions/48818/… $\endgroup$ – MaxJ Jun 3 '14 at 21:38
  • 1
    $\begingroup$ @user3683367, you probably will be using this in an animation similar to the linked question; so i would recommend using the same setup... that is, {colors[[t]],Rectangle @@ (rectCoords[[t]])} with t the index you use in Animate or Table... $\endgroup$ – kglr Jun 3 '14 at 21:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.