• fullscreen
  • filters.pde
  • PFont font;
    String fontpath = "ArialMT-200.vlw";
    int fontstart = 300;
    int fontend = 8;
    float fontsize = fontstart;
    float fontsizedecrease = 0.97;
    PImage img;
    String imgpath = "mlk10.jpg";
    String letters = "IhaveadreamIamhappytojoinwithyoutodayinwhatwillgodowninhistoryasthegreatestdemonstrationforfreedominthehistoryofournationFivescoreyearsagoagreatAmericaninwhosesymbolicshadowwestandtodaysignedtheEmancipationProclamationThismomentousdecreecameasagreatbeaconlightofhopetomillionsofNegroslaveswhohadbeensearedintheflamesofwitheringinjusticeItcameasajoyousdaybreaktoendthelongnightoftheircaptivityButonehundredyearslatertheNegrostillisnotfreeOnehundredyearslaterthelifeoftheNegroisstillsadlycrippledbythemanaclesofsegregationandthechainsofdiscriminationOnehundredyearslatertheNegrolivesonalonelyislandofpovertyinthemidstofavastoceanofmaterialprosperityOnehundredyearslatertheNegroisstilllanguishedinthecornersofAmericansocietyandfindshimselfanexileinhisownlandAndsowevecomeheretodaytodramatizeashamefulconditionInasensewevecometoournationscapitaltocashacheckWhenthearchitectsofourrepublicwrotethemagnificentwordsoftheConstitutionandtheDeclarationofIndependencetheyweresigningapromissorynotetowhicheveryAmericanwastofallheirThisnotewasapromisethatallmenyesblackmenaswellaswhitemenwouldbeguaranteedtheunalienableRightsofLifeLibertyandthepursuitofHappinessItisobvioustodaythatAmericahasdefaultedonthispromissorynoteinsofarashercitizensofcolorareconcernedInsteadofhonoringthissacredobligationAmericahasgiventheNegropeopleabadcheckacheckwhichhascomebackmarkedinsufficientfundsButwerefusetobelievethatthebankofjusticeisbankruptWerefusetobelievethatthereareinsufficientfundsinthegreatvaultsofopportunityofthisnationAndsowevecometocashthischeckacheckthatwillgiveusupondemandtherichesoffreedomandthesecurityofjusticeWehavealsocometothishallowedspottoremindAmericaofthefierceurgencyofNowThisisnotimetoengageintheluxuryofcoolingoffortotakethetranquilizingdrugofgradualismNowisthetimetomakerealthepromisesofdemocracyNowisthetimetorisefromthedarkanddesolatevalleyofsegregationtothesunlitpathofracialjusticeNowisthetimetoliftournationfromthequicksandsofracialinjusticetothesolidrockofbrotherhoodNowisthetimetomakejusticearealityforallofGodschildrenItwouldbefatalforthenationtooverlooktheurgencyofthemomentThisswelteringsummeroftheNegroslegitimatediscontentwillnotpassuntilthereisaninvigoratingautumnoffreedomandequalityNineteensixtythreeisnotanendbutabeginningAndthosewhohopethattheNegroneededtoblowoffsteamandwillnowbecontentwillhavearudeawakeningifthenationreturnstobusinessasusualAndtherewillbeneitherrestnortranquilityinAmericauntiltheNegroisgrantedhiscitizenshiprightsThewhirlwindsofrevoltwillcontinuetoshakethefoundationsofournationuntilthebrightdayofjusticeemergesButthereissomethingthatImustsaytomypeoplewhostandonthewarmthresholdwhichleadsintothepalaceofjusticeIntheprocessofgainingourrightfulplacewemustnotbeguiltyofwrongfuldeedsLetusnotseektosatisfyourthirstforfreedombydrinkingfromthecupofbitternessandhatredWemustforeverconductourstruggleonthehighplaneofdignityanddisciplineWemustnotallowourcreativeprotesttodegenerateintophysicalviolenceAgainandagainwemustrisetothemajesticheightsofmeetingphysicalforcewithsoulforceThemarvelousnewmilitancywhichhasengulfedtheNegrocommunitymustnotleadustoadistrustofallwhitepeopleformanyofourwhitebrothersasevidencedbytheirpresenceheretodayhavecometorealizethattheirdestinyistiedupwithourdestinyAndtheyhavecometorealizethattheirfreedomisinextricablyboundtoourfreedomWecannotwalkaloneAndaswewalkwemustmakethepledgethatweshallalwaysmarchaheadWecannotturnbackTherearethosewhoareaskingthedevoteesofcivilrightsWhenwillyoubesatisfiedWecanneverbesatisfiedaslongastheNegroisthevictimoftheunspeakablehorrorsofpolicebrutalityWecanneverbesatisfiedaslongasourbodiesheavywiththefatigueoftravelcannotgainlodginginthemotelsofthehighwaysandthehotelsofthecitiesWecannotbesatisfiedaslongasthenegrosbasicmobilityisfromasmallerghettotoalargeroneWecanneverbesatisfiedaslongasourchildrenarestrippedoftheirselfhoodandrobbedoftheirdignitybysignsstatingForWhitesOnlyWecannotbesatisfiedaslongasaNegroinMississippicannotvoteandaNegroinNewYorkbelieveshehasnothingforwhichtovoteNonowearenotsatisfiedandwewillnotbesatisfieduntiljusticerollsdownlikewatersandrighteousnesslikeamightystream¹IamnotunmindfulthatsomeofyouhavecomehereoutofgreattrialsandtribulationsSomeofyouhavecomefreshfromnarrowjailcellsAndsomeofyouhavecomefromareaswhereyourquestquestforfreedomleftyoubatteredbythestormsofpersecutionandstaggeredbythewindsofpolicebrutalityYouhavebeentheveteransofcreativesufferingContinuetoworkwiththefaiththatunearnedsufferingisredemptiveGobacktoMississippigobacktoAlabamagobacktoSouthCarolinagobacktoGeorgiagobacktoLouisianagobacktotheslumsandghettosofournortherncitiesknowingthatsomehowthissituationcanandwillbechangedLetusnotwallowinthevalleyofdespairIsaytoyoutodaymyfriendsAndsoeventhoughwefacethedifficultiesoftodayandtomorrowIstillhaveadreamItisadreamdeeplyrootedintheAmericandreamIhaveadreamthatonedaythisnationwillriseupandliveoutthetruemeaningofitscreedWeholdthesetruthstobeselfevidentthatallmenarecreatedequalIhaveadreamthatonedayontheredhillsofGeorgiathesonsofformerslavesandthesonsofformerslaveownerswillbeabletositdowntogetheratthetableofbrotherhoodIhaveadreamthatonedayeventhestateofMississippiastateswelteringwiththeheatofinjusticeswelteringwiththeheatofoppressionwillbetransformedintoanoasisoffreedomandjusticeIhaveadreamthatmyfourlittlechildrenwillonedayliveinanationwheretheywillnotbejudgedbythecoloroftheirskinbutbythecontentoftheircharacterIhaveadreamtodayIhaveadreamthatonedaydowninAlabamawithitsviciousracistswithitsgovernorhavinghislipsdrippingwiththewordsofinterpositionandnullificationonedayrightthereinAlabamalittleblackboysandblackgirlswillbeabletojoinhandswithlittlewhiteboysandwhitegirlsassistersandbrothersIhaveadreamtodayIhaveadreamthatonedayeveryvalleyshallbeexaltedandeveryhillandmountainshallbemadelowtheroughplaceswillbemadeplainandthecrookedplaceswillbemadestraightandthegloryoftheLordshallberevealedandallfleshshallseeittogetherThisisourhopeandthisisthefaiththatIgobacktotheSouthwithWiththisfaithwewillbeabletohewoutofthemountainofdespairastoneofhopeWiththisfaithwewillbeabletotransformthejanglingdiscordsofournationintoabeautifulsymphonyofbrotherhoodWiththisfaithwewillbeabletoworktogethertopraytogethertostruggletogethertogotojailtogethertostandupforfreedomtogetherknowingthatwewillbefreeonedayAndthiswillbethedaythiswillbethedaywhenallofGodschildrenwillbeabletosingwithnewmeaningMycountrytisoftheesweetlandoflibertyoftheeIsingLandwheremyfathersdiedlandofthePilgrimsprideFromeverymountainsideletfreedomringAndifAmericaistobeagreatnationthismustbecometrueAndsoletfreedomringfromtheprodigioushilltopsofNewHampshireLetfreedomringfromthemightymountainsofNewYorkLetfreedomringfromtheheighteningAllegheniesofPennsylvaniaLetfreedomringfromthesnowcappedRockiesofColoradoLetfreedomringfromthecurvaceousslopesofCaliforniaButnotonlythatLetfreedomringfromStoneMountainofGeorgiaLetfreedomringfromLookoutMountainofTennesseeLetfreedomringfromeveryhillandmolehillofMississippiFromeverymountainsideletfreedomringAndwhenthishappenswhenweallowfreedomringwhenweletitringfromeveryvillageandeveryhamletfromeverystateandeverycitywewillbeabletospeedupthatdaywhenallofGodschildrenblackmenandwhitemenJewsandGentilesProtestantsandCatholicswillbeabletojoinhandsandsinginthewordsoftheoldNegrospiritualFreeatlastFreeatlastThankGodAlmightywearefreeatlast";
    char[] chars = new char[52];
    int nchars = 0;
    int iterations = 500;
    int c = 0;
    PGraphics letter,lettersquare,drawing;
    
    void setup(){
      //initialize the sketch
      size(438,600);
      background(255);
      //initialize the font
      //font = loadFont(fontpath);
      ///*
      for(int i=0;i<letters.length();i++){
        boolean found = false;
        char lc = letters.charAt(i);
        for(int j=0;j<nchars;j++){
          if(chars[j]==lc){
            found = true;
            break;
          }
        }
        if(!found) chars[nchars++] = lc;
      }
      chars = (char[]) subset(chars,0,nchars);
      font = createFont("Arial",200,true,chars);
      //*/
      textAlign(CENTER,CENTER);
      //load the image that will be filled with letters
      img = loadImage(imgpath);
      //posterize the image
      img.filter(THRESHOLD,0.4);
      img.filter(BLUR,3);
      img.filter(THRESHOLD,0.6);
      //initialize the drawing buffers
      letter = createGraphics((int)fontsize,(int)fontsize,JAVA2D);
      lettersquare = createGraphics((int)fontsize,(int)fontsize,P2D);
      drawing = createGraphics(width,height,JAVA2D);
      drawing.beginDraw();
      drawing.background(255);
      drawing.endDraw();
    }
    
    void draw(){
      background(255);
      if(floor(fontsize)>fontend&&c<letters.length()-1){
        if(!letterfit()){
          fontsize *= fontsizedecrease;
        }else{
          c++;
          if(c==11){
            fontsize *= 0.75;
          }
        }
        tint(255);
        image(drawing,0,0);
        if(mousePressed){
          tint(255,100);
          image(img,0,0);
        }
      }else{
        tint(255);
        image(drawing,0,0);
        println(c+" "+letters.length());
        /*
        save("mlk-"+hour()+""+minute()+""+second()+".tif");
        exit();
        */
        noLoop();
      }
    }
    
    boolean letterfit(){
      letter.beginDraw();
      letter.background(255,0);
      letter.fill(0); 
      letter.textAlign(CENTER,CENTER);
      letter.translate(fontsize/2,fontsize/2); 
      letter.rotate(random(TWO_PI));
      letter.scale(fontsize/fontstart); 
      letter.textFont(font); 
      letter.smooth();
      letter.text(letters.charAt(c),0,0); 
      letter.endDraw();
      lettersquare.beginDraw(); 
      lettersquare.background(255); 
      lettersquare.image(letter,0,0);
      lettersquare.filter(ERODE);
      lettersquare.filter(ERODE);
      lettersquare.endDraw();
      for(int i=0;i<iterations;i++){
        int x = floor(random(width-fontsize));
        int y = floor(random(height-fontsize));
        boolean fits = true;
        for(int dx=0;dx<fontsize&&fits;dx++){ 
          for(int dy=0;dy<fontsize&&fits;dy++){
            if(brightness(img.get(x+dx,y+dy))>127){
              fits = false;
              break;
            }
            if(brightness(lettersquare.get(dx,dy))<127){ 
              if(brightness(drawing.get(x+dx,y+dy))<127){
                fits = false;
              }
            }
          }
        }
        if(fits){
          drawing.beginDraw();
          drawing.image(letter,x,y);
          drawing.endDraw();
          return true;
        }
      }
      return false;
    }
    
    /*
    void mousePressed(){
      save("mlk-"+hour()+""+minute()+""+second()+".tif");
      exit();
    }
    */
    

    code

    tweaks (0)

    about this sketch

    This sketch is running as Java applet, exported from Processing.

    license

    advertisement

    Don Havey

    MLK Day

    Add to Faves Me Likey@! 73
    You must login/register to add this sketch to your favorites.

    A portrait of Martin Luther King Jr., composed of the transcribed text from his famous Lincoln Memorial ("I have a dream") speech. Not optimized for framerate, just for pretty results. Generates the font with createFont... so I think that means that you need Arial installed on your system to see anything.

    Hold the mouse button down to see the underlying image.

    Inspiration and space filling method borrowed from this smartly-built sketch: http://www.openprocessing.org/visuals/?visualID=1811

    Xavier
    20 Jan 2010
    Greate
    wauv that's very nice, I realized it was layed on top of MLK's image after my third visit to this sketch :)
    Abel Dewitz
    24 Jan 2010
    I really like that very much!
    Lindo.
    Keith Rowell
    10 Feb 2013
    I get a null pointer exception here:

    img.filter(THRESHOLD,0.4);

    any help?
    You did not add any image in your data folder that's why.
    messengerboy
    12 Feb 2013
    This is SUCH a great sketch... but I can't get it to work for me! So, I make sure it has a data folder with the Arial typeface and the mlk10.jpg picture. Then I get an error saying...

    createGraphics() with P2D requires size() to use P2D or P3D

    ...So I change "size(438,600);" to "size(438,600,P2D)", and the sketch runs without any errors... but it doesn't work!! Could anyone help me out with this? I'd really love to tweak this!
    messengerboy
    12 Feb 2013
    Going off of Rupert Russell's comment on the original Scattered Letter sketch (http://www.openprocessing.org/sketch/1811), I've found that replacing the line...

    lettersquare = createGraphics((int)fontsize,(int)fontsize,P2D);

    ...with...

    lettersquare = createGraphics((int)fontsize,(int)fontsize,JAVA2D);

    ...makes it work... but it only uses the same "I" (first letter of the string "Ihaveadream...") at the same angle and the same font size...!

    Example: http://i.imgur.com/A0zuvXP.png?1

    Still lost! Haalllppp!
    Adam Parker
    24 Feb 2013
    I'm having the same problem as messengerboy. Does anybody have a solution?
    You need to login/register to comment.