Browse Search Popular Register Upload Rules User list Login:
Search:
Pixelated Line Displayer

Image:
screenshot of the scene

Author: lololoer

Group: Default

Filesize: 6.76 kB

Date added: 2014-02-08

Rating: 5

Downloads: 538

Views: 246

Comments: 11

Ratings: 1

Times favored: 0

Made with: Algodoo v2.1.0

Tags:

Scene tag

This code could be used in a programs like Paint, Paint.net, etc..
The probems are:
1. The size of the line increases with the distance.
2. The displayer does not work good in the left of the group of the boxes because of the negative natural values of the angle (d_from,app.mousepos).
Please log in to rate this scene
edit
Similar scenes
Title: A pixelated look for your boring default scene!
Rating: 5
Filesize: 18.7 kB
Downloads: 753
Comments: 4
Ratings: 1
Date added: 2021/10/22 23:24:52
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Line Car V1.4
Rating: 5
Filesize: 121.91 kB
Downloads: 439
Comments: 1
Ratings: 1
Date added: 2020/02/23 18:18:20
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Star Type M (with planet) NEW UPDATE!
Rating: 5
Filesize: 89.34 kB
Downloads: 1891
Comments: 1
Ratings: 1
Date added: 2024/09/07 18:32:21
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: basketball
Rating: 5
Filesize: 46.42 kB
Downloads: 1712
Comments: 0
Ratings: 1
Date added: 2023/12/05 02:09:24
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: ABCs and Numbers
Rating: 5
Filesize: 53.47 kB
Downloads: 1881
Comments: 0
Ratings: 1
Date added: 2017/07/30 14:36:43
Made with: Algodoo v2.1.0
Rating: rated 5
download
Title: Minecraft items
Rating: 5
Filesize: 46.82 kB
Downloads: 3021
Comments: 5
Ratings: 1
Date added: 2021/07/23 00:15:18
Made with: Algodoo before v1.8.5
Rating: rated 5
download
I moved the script from update to postStep so that it runs only when Algodoo is running, and it seems to still work properly. If you would move the script to update in all 64 boxes, then people will be able to select boxes and make changes without the scene constantly running.

This is interesting but I don't understand how it can be used in other programs like Paint, etc. Please explain.

Thanks!
In a program, I mean, when you use the pencil tool to make straight lines.
Obviosly with the appropriate script language transcription.
Last edited at 2014/02/08 18:25:05 by lololoer
Could you please explain how your function scene.my.display works? I cannot figure it out by myself. :s

Thanks!
(gm,tar,d_from)=>{
m=(from, to)=>{math.atan2(to(1) - from(1), to(0) - from(0))};
pv=(v)=>{v<0? -v:v};
gm_a=m(d_from,gm.pos);
tar_a=m(d_from,tar);­
[1,0,pv(gm_a-tar_a)*3,1]
};

gm= a pixel (box)
tar= target ending line point (app.mousepos), in this case there's not ending point.
d_from= starting point, (where th line stars displaying([0,0])).
m= intrinsic function with 2 arguments. Maths the angle between 2 points (startingpoint,ending point).
pv= intrinsic function with 1 argument. Makes a value to positive being negative or positive, pv(-1)= 1; pv(1)= 1;.
gm_a= Angle between the starting line point ang the pixel (box), uses the m function.
tar_a= Angle between the starting point and the ending one, uses m function.
pv(gm_a-tar_a)*3= the difference between gm_a and tar_a.
The other array variables are the rest of the colorHSVA features.

I hope you understood it, Thanks! :tup: .

Edit: The display variable is able to change in the text box, if you know how to fix the 2 problems, or at least one of them please upload the scene without the problems.
Last edited at 2014/02/08 18:44:32 by lololoer
YES! Now I understand it. THANK YOU!!! _o_
update = (e)=>{
scene.my.display = eval("" + text)
}

THIS IS NOT GOOD! The code continuously defines the function over and over again. You should run this script (including the maths of course) only ONE TIME in the console. Once the function has been defined, it will work as expected. :)
Last edited at 2014/02/08 20:24:45 by Xray
I did it on purpose, I wont to make the code continuosly defined to change the code if it failed working and directly change it, why it isn't good?.
I did it o purpose to the user help me too!
By the way, do you know how to fix the problems on the function?
Last edited at 2014/02/09 14:48:31 by lololoer
It is not good because it is not good programming practice. You should only define a variable or function one time. When the variable or function continues to be defined over and over again, it eats up resources and it could cause computer lag or other undesirable things to happen. In fact, the scene crashed a number of times when I tried to make some simple changes because the script was running continuously even though Algodoo was not running. Those are some reasons why it is bad to do that.

I did try to fix the problem of the line growing wider over distance, but I was not able to figure out what causes that to happen. I did not work on the other problem of the line not working on the left side, but I will take a look at it today.
lololoer - You said: tar= target ending line point (app.mousepos), in this case there's not ending point.

Please explain. first you say that the ending line point is (app.mousepos), and then you say in this case there's no ending point! :s What do you mean by that?
The ending point is the point to element in the m function (math angle), in this case, math angle ([0,0],app.mousepos), and I said that there's no ending point because the line does not finishes, if the line could be able to finish if woud finish on the target (tar), (app.mousepos).
Last edited at 2014/02/10 16:02:38 by lololoer
Okay, now I understand. Thanks. :)