Codea 2.1 Released

Have you tried opening the asset viewer on the main screen and resyncing the dropbox assets - I had to do that on mine, although my custom asset packs are still fine.

@TechDojo, I have another project, this works with some lag, but works :confused:

i like the fast search and the possibility to change icon size and add photos.
but where is the author under the title ?
it would be nice to be able to create folders by authors or themes.
thanks for the update.

@Simeon I have my projects set to sort by “name”, but if I close Codea and open it again, my projects are sorted by “recent”. I have to select “recent”, then “name” to resort them, which stays until Codea is closed.

@dave1707 could you log this one in the issue tracker? It’s a bug. Sorry about that!

@hpsoft custom collections are coming.

thank you

The update seems to have broken the rounded rect shader I use.
Here’s the code:

local vertex = [[
//
// A basic vertex shader
//

//ThiCurs ntTouch.state is the current model * view * projection matrix
// Codea sets it automatically
uniform mat4 modelViewProjection;

//ThiCurs ntTouch.state is the current meshertex position, color and tex coord
// Set automatically
attribute vec4 position;
attribute vec4 color;
attribute vec2 texCoord;

//ThiCurs ntTouch.state is an output variable that will be passed to the fragment shader
varying lowp vec4 vColor;
varying highp vec2 TexV;

uniform vec4 fill;
uniform vec4 stroke;

varying lowp vec4 Fill;
varying lowp vec4 Stroke;

uniform vec3 gradient;
varying lowp vec3 Gradient;

void main()
{
    //Pass the mesh color to the fragment shader
    vColor = color;
    TexV = texCoord;
    
    // Passes Normalized Stroke and Fill to Fragment
    Fill = vec4(fill.r/255.,fill.g/255.,fill.b/255.,fill.a/255.);
    //Fill = texture2D( texture, TexV );
    Stroke = vec4(stroke.r/255.,stroke.g/255.,stroke.b/255.,stroke.a/255.);

    // Gradient
    Gradient = vec3(gradient.x / 255., gradient.y / 255., gradient.z / 255.);

    //Multiply the vertex position by our combined transform
    gl_Position = modelViewProjection * position;
}
]]

local fragment = [[
//
// A basic fragment shader
//

//Default precision qualifier
precision highp float;

//uniform lowp sampler2D texture;

uniform vec2 position;
uniform float Smooth;
uniform float StrokeWidth;
uniform float radius;

//The interpolated vertex color for this fragment
varying lowp vec4 vColor;
varying lowp vec4 Stroke;
varying lowp vec4 Fill;
varying lowp vec3 Gradient;

//The interpolated texture coordinate for this fragment
varying highp vec2 TexV;

void main()

{
    //lowp vec4 tcol = texture2D( texture, TexV );
    //Fill = vColor;
    float SM = Smooth * 0.5; 
    vec4 Color = vec4(0,0,0,0);

    //Fill = texture2D(texture,TexV);

    vec4 Dims = vec4(0.5 - position.x * 0.5, 0.5 + position.x * 0.5, 
    0.5 + position.y * 0.5, 0.5 - position.y * 0.5);

    //Dims = vec4(0., position.x, position.y, 0.);
    
    float L = Dims.x; float R = Dims.y; float U = Dims.z; float D = Dims.w;
    float Radius = abs(radius); float dist = min(position.x * 0.5,position.y * 0.5);
    if (Radius > dist) Radius = dist;
        float Max = max(StrokeWidth,Radius);

    float DimHeight = 1. / abs(U - D);
    
    // Sets Bounds for Drawing
    if (TexV.x >= L - SM && TexV.x <= R + SM && TexV.y <= U + SM && TexV.y >= D - SM) {
    
       // Rounds Rectangle Corners
       if ((TexV.x < L + Radius || TexV.x > R - Radius) && 
        (TexV.y < D + Radius || TexV.y > U - Radius)){ 
    
        float Dist = min(min(distance(vec2(L + Radius,D + Radius),TexV),
         distance(vec2(R - Radius,D + Radius),TexV)),
         min(distance(vec2(L + Radius,U - Radius),TexV),
         distance(vec2(R - Radius,U - Radius),TexV))); 
        
        if (Dist <= Radius - StrokeWidth + SM && Dist >= Radius - StrokeWidth - SM)
         {if (StrokeWidth > 0.) // Fill Smoothing
         Color = mix(Fill,Stroke,(abs(Radius - StrokeWidth - SM - Dist))/Smooth);
         else Color = mix(Fill,vec4(0,0,0,0),((abs(Radius - StrokeWidth - SM - Dist))/Smooth));}
        
        else if (Dist <= Radius + SM && Dist >= Radius - StrokeWidth + SM) 
         if (Dist < Radius - SM) Color = Stroke; //Stroke Smiothing
         else Color = mix(vec4(Stroke.x,Stroke.y,Stroke.z,0),Stroke,(Radius + SM - Dist)/Smooth); 
        
        else if (Dist < Radius + SM) Color = Fill;
        else if (Dist > Radius + SM) Color = vec4(0,0,0,0); }
        
       else { // Draws Rectangle Sides/Interior
    
        float Dist = min( // Distance From Pixel to Closest Side
         min(distance(vec2(TexV.x, U + SM),TexV),distance(vec2(TexV.x,D - SM),TexV)), 
         min(distance(vec2(L - SM,TexV.y),TexV),distance(vec2(R + SM,TexV.y),TexV))); 
        
        if (Dist <= Smooth + StrokeWidth && Dist >= StrokeWidth && StrokeWidth > 0.) 
         Color = mix(Fill,Stroke,(Smooth - Dist + StrokeWidth)/Smooth); 
        else if (Dist + StrokeWidth <= Smooth) 
         Color = mix(Fill,vec4(0,0,0,0),(Smooth - Dist + StrokeWidth)/Smooth);
        else if (Dist <= Smooth && StrokeWidth > 0.) 
         Color = mix(Stroke,vec4(0,0,0,0),(Smooth - Dist)/Smooth);
        else if ((TexV.y <= D + StrokeWidth || TexV.y >= U - StrokeWidth) ||
         (TexV.x <= L + StrokeWidth || TexV.x >= R - StrokeWidth)) Color = Stroke;   
        else Color = Fill; }} 

    else discard;
    
    //Set the output color to the texture color
    gl_FragColor = vec4(mix(vec3(Color.x,Color.y,Color.z),vec3(Color.x-Gradient.x,Color.y-Gradient.y,Color.z-Gradient.z),((1.-TexV.y)-D)*DimHeight),Color.w);
}
]]

Any idea what’s wrong?

@Dave1707 I’m having the same problem

Hello.
After update… here is a bug —???
local sourceImage=readImage("Dropbox:sprites") local sW,sH=sourceImage.width,sourceImage.height atemp to index local sourceImage(...
Before this was correct.

@Muravei Did you sync your Dropbox. You’re code works if I use a normal sprite.

This works for me (if Dropbox:sprites exists, of course). Comments are prefixed with – rather than <<

local sourceImage=readImage("Dropbox:sprites")
local sW,sH=sourceImage.width,sourceImage.height   --atemp to index local sourceImage(...

@Simeon I was playing around with the saveText and readText examples you have in the built in documentation. The example uses the Documents folder and it appears that the file needs to be created manually before the example works. Is that correct, does the file need to be created manually before anything can be saved to it. I also have an empty folder under Assets with the name of the test project I was using. There isn’t anything in the folder and I don’t see any way to remove it. Deleting the project doesn’t remove it.

Dropdox was in sync.
Still does not work…

Btw… Sprite, width, height - exist and prints correctly


Ok, I fix it.
Just add “sourceImage.width or 0”.
This error of precompilation. In runtime all fine

So how could I fix that shader? I’ve confirmed that it is the same copy that worked perfectly on 2.0, so I’m not sure what’ scalding the problem.

@Simeon Ignore part of what I said above. Apparently a folder with the project name appears in every project when you look at the Assets from within the editor.

@FLCode - I don’t know how anyone is going to see an error in all that code. I suggest you need to debug it yourself, by isolating the error. I started for you by doing the following:

The observed behaviour is no reported errors, but nothing is drawn. This suggests either a syntax error not picked up by Codea’s compiler, or else an arithmetic calculation that produces a nil result.

I tested for errors by simply putting this at the end of the fragment shader

gl_FragColor=vec4(1.,0.,0.,1.);

It overrides any calculations and simply draws red. If it works, there are no syntax errors, and our problem is one of calculation (or inputs).

It works, so we need to look at the calculations.

An obvious starting point is the alpha value of the colour. If I change the last line of the fragment shader so alpha is hard coded to 1, I get a black square. Now it may may be black (and square) because I haven’t passed through sensible values for all the uniform variables, but at least I’m getting something. It tells me that the alpha value is incorrect, and confirms that something is wrong with the calculations (or inputs).

I don’t have the time or energy to continue debugging the rest of the code, but I suggest you keep testing, by removing or commenting out code, overriding calculation results with a hard coded result, to eliminate chunks of the code until you find the problem.

A belated congrats to @Simeon and the team! Well done chaps! :smiley:

@andymac3d thank you!

@dave1707 those are the new “Project” assets. You can now store assets per-project and access them with "Project:AssetName". This means not everything has to sit in Documents or Dropbox.

@Simeon - Noticed a visual bug tonight:

https://www.dropbox.com/s/xuarwcsx0wa1v5o/2014-12-08%2020.15.00.png?dl=0

Both readGlobalData and format.string are showing the one line description at the end of the line. This is from the Jump Hex project on CC.

Edit: Issue #326 on the issue tracker. Please let me know if you need anymore!

I like the new project layout, as well as the flappy demo. Really good job.