Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Show Emojis

edited December 2016 in Code Sharing Posts: 77

My code for a movie with emoji is not transferred from the 1st emoji sign here. How can I change this?
On my iPad Pro it runs perfectly.

Comments

  • @matox I don't exactly understand what you are trying to do. Please add a small description. Also, you have added the same post twice.

  • Posts: 1,098

    @matox - did you get anywhere with your emoji movie, I am trying to set up a basic game with emoji images and would like to refer to them as numbers. I was thinking of setting up a table with the emoji details in so I could refer to the image by array index, is that what you did for your short video demo?

  • dave1707dave1707 Mod
    edited December 2018 Posts: 7,312

    @Bri_G Here’s an example of an emoji table. It didn’t show here correct with the emojis in the table so I took them out. Just put some emojis between the “” in the table.

    function setup()
        em={"","","","",""}
    end
    
    function draw()
        background(40, 40, 50)
        fill(255)
        fontSize(100)
        for z=1,#em do
            text(em[z],200,150*z)
        end
    end
    
  • Posts: 1,098

    @dave - thanks, took the code right off of my fingers. Have now put 120 of these in an emoji list and can display them easily. It’s just like a sprite library, soon have a project set up for my granddaughter. Only problem now is I’m getting more requests.

    All they need now is very basic so I can put things together fairly easily. Thanks again.

  • dave1707dave1707 Mod
    Posts: 7,312

    @Bri_G Here’s some code that displays a full screen emoji sprite and also allows you to view each of the emoji's. Should save you the trouble of creating a table. You can probably modify this to create a table of emoji's if you want. Run in landscape orientation.

    function setup()
        print("1: This takes about 5 seconds to create the full screen emoji sprite")
        print("2: Slide the multi slider left to show individual emoji's")
        print("3: value1 slider is x 1")
        print("4: value2 slider is x 50")
        print("5: value1 + value2 * 50 = emoji value")
    
        parameter.boolean("multi",true)
        parameter.integer("value1",0,50,0)
        parameter.integer("value2",0,50,0)
    
        img=image(WIDTH,HEIGHT)
        fill(255)
        setContext(img)
        fontSize(15)
        cnt=127744
        for y=1,43 do
            for x=1,42 do
                text(utf(cnt),x*17,HEIGHT- y*17)
                cnt=cnt+1
            end
        end
        setContext()
    end
    
    function draw()
        background(40,40,50)
        fill(255)
        if multi then
            sprite(img,WIDTH/2,HEIGHT/2)
        else
            fontSize(30)
            text(value1+value2*50,WIDTH/2,HEIGHT-50)
            fontSize(400)
            cnt=127744
            text(utf(cnt+value1+value2*50),WIDTH/2,HEIGHT/2)
        end       
    end
    
    function utf(val)
        local b4 = val % 64 + 128
        local b3 = val // 64 % 64 + 128
        local b2 = val // 4096 % 64 + 128
        local b1 = val // 262144 + 240
        return string.char(b1, b2, b3, b4)
    end
    
  • Posts: 1,098

    @dave1707 - thanks for that, I was wondering how to call the emojis from code, utf is the way.

    I have built up a list of some 160 emojis, will add more later and then probably re-organise into sub groups. Using your simple display program above Modified to display them I have now a full page of the Apple emojis.

    Tip, just add fontSize() before your text loop and put in any size you want. Instant image !!! Just tried it out and it worked. Qualitiy is excellent so I am assuming these emojis work on a vectored image basis.

    Thanks again.

    P.s. once you have a library, I use dependencies to pull out the emojis I need. This is cool.

  • dave1707dave1707 Mod
    Posts: 7,312

    @Bri_G Not sure what you mean with your Tip. Where are you putting the fontSize() that’s giving you excellent quality on the emoji.

  • Posts: 1,098

    @dave1707 - posted reply in another thread. Just thought I may have raised this through my own ignorance - I know next to nothing about emojis other than their use on phones. For a project I downloaded an image of a thumbs up emoji and used it as a sprite on an intro cover. Then later I used the table of emojis to print up emojis on screen with text(). Then I thought 'if you're using text, why not see if fontSize() will change the emoji images size'- and it did. It also did in a surprising retention of quality - hence my surprise - must be vector images like TrueFonts. It's like having a whole new sprite library.

    So if you knew this already - just ignore my post.

  • dave1707dave1707 Mod
    edited December 2018 Posts: 7,312

    @Bri_G Here’s the post you wanted moved. I deleted it in the other discussion. For some reason emoji's don’t show and stop the text after them. I did the same thing a few post above. I had to remove the emoji's from the table before the rest of the text would show. In my program above where I display the full screen of emoji's, are you sliding the multi parameter slider and displaying the emoji’s one by one. I’m using fontsize(400) and they’re showing a little fuzzy.

    PS. Bri-G, If you mess up a post you can re-edit it and make whatever changes you want. You could have gone in the post you wanted me to delete and removed all the text and just left the words “delete this post”. You then could have gone into the the discussion you wanted and put in the new text there. Anyways it no problem for me to delete posts. I’m always going into posts I make to correct spelling errors or just to add stuff.


    @dave1707 - sorry there must be something in the code which is messing up the post. Trying without the emoji present just the speech marks, add your own emoji. Try changing fontSize(). function setup() -- emoj = {""} end -- This function gets called once every frame function draw() -- This sets a dark background color background(40, 40, 50) fontSize(256) text(emoj[1], 364,512) end
  • Posts: 77
    --Emojis
    
    displayMode(FULLSCREEN)
    supportedOrientations(LANDSCAPE_LEFT)
    function setup()
        print("Hello World!")
        displayMode(FULLSCREEN)
        fill(246, 245, 245, 255)
        h = 1
        w = 1
        x=100
        y=100
        g=200
        hold = true   
        r1="\u{1F6b4}" --byke
        r2 = "\u{1F6b4}" --byke
        tr1 = "\u{1F332}" --tree
        tr2 = "\u{1F333}"
        tr3 = "\u{1F335}"
        tr4 = "\u{1F384}"
        x1=1000
        x2=1100
        x3=1200
        x4=1300
        r=1
        bh=1   
    end
    
    -- This function gets called once every frame
    function draw()
        -- This sets a dark background color 
        background(40, 40, 50)
    
        -- This sets the line thickness
        strokeWidth(5)
    
        -- Do your drawing here
         background(51, 198, 34, 255)
    
        -- This sets the line thickness
        strokeWidth(5)
    
        if hold == false then h = h + 1 end
        if hold == false then w = w + 1 end
        if hold == false then x = x + 7 end
        if hold == false then g = g - 1 end
        if h > 200 then hold = true end
        if hold == true then  h = h - 1 end
        if hold == true then  w = w - 1 end
        if hold == true then  x = x - 7 end
        if hold == true then  g = g + 1 end
        if h < 10 then hold = false end
    
        -- Do your drawing here
        fontSize(200)
        text("\u{1F31E}",x,750) --sun
        fontSize(100)
        text("\u{1F45F}",50,50) --schuh
        text("\u{1F3D0}",w*5,h*5) --ball
        text("\u{1F3C0}",w*2,h*3)--ball
        bh=bh+1
        if bh > 900 then bh = 1 end
        text("\u{1F388}",150,bh*3)
        text("\u{1F682}",x,y)  --lok 
        text("\u{1F683}",x+100,y) --wagon1
        text("\u{1F683}",x+200,y) --wagon2
        text("\u{1F683}",x+300,y) --wagon3
        fontSize(g)
        text("\u{1F681}",900, 700) --heli
        text("\u{1F3C1}",900,500)  --startflag  
        text("\u{1F698}",100,550) --car
        text("\u{1F696}",250,520)
        text("\u{1F694}",400,490)
        text("\u{1F68D}",550,460)
     --   text("\u{1F388}",900,800) --ballon
        text("\u{1F448}",900,200) --hand
        fontSize(100)
        text("ShowEmojis",550,250)
        x1 = x1 - math.random(7)
        x2 = x2 - math.random(7)
        x3 = x3 - math.random(7)
        x4 = x4 - math.random(7)
        if x4<0 then r=r+1 end
        r=tostring(r)
        if x1 < 0  then x1 = 1600 end
        if x2 < 0  then x2 = 1600 end
        if x3 < 0  then x3 = 1600 end
        if x4 < 0  then x4 = 1600 end
        fontSize(70)
        text(tr1,200,50) --trees
        text(tr2,250,50)
        text(tr3,300,50)
        text(tr4,350,50)
        text(tr1,400,50)
        text(tr2,450,50)
        text(tr3,500,50)
        text(tr4,550,50)
        text(tr1,600,50)
        text(tr2,650,50)
        text(tr3,700,50)
        text(tr4,750,50)
        text(tr1,800,50)
        text(tr2,850,50)
        text(tr3,900,50)
        text(tr4,950,50)
        text("Round "..r,600,900) -- Round counter
        fontSize(200)
        text("\u{1F327}",300,750) --cloud1
        text("\u{1F328}",600,750)--cloud2
    
        fontSize(150)
        -- Do your drawing here
        text(r1,x1,400) --byker
        text(r2,x2,350)
        text(r1,x3,300)
        text(r2,x4,250)   
    
    end
    
    function touched(t)
        if t.state == BEGAN then
        close()
    end 
    end
    
    
  • dave1707dave1707 Mod
    Posts: 7,312

    @matox Thanks for the post. That’s an easy way to show the emoji’s instead of doing the calculations I was doing. I’ll have to modify my code above and see if it creates the emoji sprite faster.

  • dave1707dave1707 Mod
    Posts: 7,312

    I guess it’s been so long since I played with emoji’s that I forgot about this code I wrote back in March 2015. See the link below.

    https://codea.io/talk/discussion/6435/utf8-character-values
    
  • Posts: 1,098

    @dave1707 - thanks for the post editin. I tried editing my post several times, pasting new code in to replace the old. Even tried it with a second post but it wouldn’t accept it. I think it must be some spurious characters in the emoji image code which corrupted the html. Below is my post for printing up a page of emojis. Unfortunately I can’t paste up my emoji table.


    -- EmojiDisplay displayMode(OVERLAY) -- Use this function to perform your initial setup function setup() -- 243 end function draw() background(40, 40, 50) fill(255) fontSize(48) for y=1,20 do for x = 1,16 do text(emList[(y-1)*8+x],x*48-16,48*y) end end end

    @matox - now there is a completely new dimension to Codea. Thanks for posting it.

Sign In or Register to comment.