yashsingh1/xdaforums huggingface dataset:
[Android Apps and Games] Tamasaka:
Table formatter

This script draws a formatted table from data in keyword file of the page. We can edit the keyword file and add data by selecting ‘Index page X’(where ‘X’indicates current page number) in the main menu of app. To add data we can paste from clipboard in the keyword editor.

Data can coexist with real keywords in the keyword file.

Lines of data are restricted to start with ‘[’ or ‘,’ .

Data should be surrounded with lines of [DATA] and [/DATA] tabs.

Data should be in csv (comma-separated values) with leading comma.

The [/DATA] line must contain keyword ‘table’, or the data among [DATA] and [/DATA] is ignored.

Data format in the keyword file is;

[DATA] <title string>

csv with leading comma

[/DATA] table <left>

In lines of data the <> parts are optional.

Body of data in csv with leading comma accepts double quotation and spaces.

A line of only a single comma is a separator between column headers and body.

Numbers are aligned to decimal tab. Numbers in scientific format (for instance, -1.2e-3) turn into the form of mantissa times ten raised to the power of index.

It has no parameters, but an option ‘left’ in [/DATA] line aligns words to left, while default alignment is centered.

Warning! When you use ‘Notebook index’, ‘Folder index’, ‘Notebook broad index’ or exported PDF, the data line behaves as if it were a keyword, and appears in the index.

Sample data as follows gives the sample table attached.

[DATA]Table 1. Properties of elements
, ,Atomic,Atomic
,Element,weight,radius (m)
,
,C, 12.01 , 7.7e-11
,Mg, 24.3 , 1.6e-10
,Ca, 40.078, 1.97e-10
[/DATA] table
[Android Apps and Games] Tintinnuntius:
Would it be possible to add another entry field to custom tools where one could enter a short description or instructions for use? Right after the name for example. This description would then be displayed when the user would be choosing the parameters (but could be turned off in settings for small screens).

I think it might make sharing and using shared containers a bit simpler since users would not have to read through the code and understand what it does, but it would not slow down the code like using comments would.

Also, maybe a field for the author of the tool? This one could stay hidden (only visible when editing the tool), it would just be a convenient way to make note of everyone who had a hand in creating the tools. I know I borrowed some of my code from the posts people made here, but it's difficult to try to remember where everything came from every time I share a container.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: That's an interesting idea, I noted it down. I guess a description might also serve to acknowledge the authors, so that one field is sufficient, right? I anyway plan to soon add a string parameter, several users suggested that.
[Android Apps and Games] Tintinnuntius:
I suggested two fields so that the description could be kept as minimal as possible. Like I said, the authors don't have to be displayed every time a code is used, I'd just like a way to keep track where I got bits of code from. Or there could be an option to display them at the bottom of the parameter dialogue in smaller font or something. Either way a separate field would be better. Maybe some people with smaller screen would like to use the description anyway, but would prefer only essential information.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: OK, good point, let me think a moment about the suggestion.
[Android Apps and Games] Tamasaka:
Free triangle

This script draws a triangle of specified angles. Two angles are set by parameters.

Parameter 1 is the degree part of angle A from 10 to 170.

Parameter 2 is the fractional part of angle A in degree from 0 to 99.

Parameter 3 is the degree part of angle B from 10 to 170.

Parameter 4 is the fractional part of angle B in degree from 0 to 99.

Parameter 5 is the switch for filling.

Large angles of A and B lead to an error message.

Images of icon and parameter settings dialog are attached below, but you can import easily by the zip file.
[Android Apps and Games] bmwelch:
help with round bullet

Thanks for posting these!! Would it be possible to get a plain round bullet?
[Android Apps and Games] Tamasaka:
Bullet

[MENTION=5144453]Canguy247[/MENTION]: Excuse me for entering from side to the conversation. I found your idea to mark between horizontal ruled lines is excellent and the offset is very useful. Please allow me to modify your code.

[MENTION=4010233]bmwelch[/MENTION]: This script provides a simple tool to draw round bullet between horizontal ruled lines. It has no parameter but three variables are changeable.

"bulletsize = 1.0;": sets the radius of bullet to the line width of current pencil. This value is proportional to the radius.

"horizontalstep = 0.5;": sets the horizontal position to every half of the step size of acadoid's standard grid.

"lefty = false;": sets the offset for a right-handed person. If you are lefty, change it "true".

You can install it easily by the zip file attached.

/* Bullet ver, 1.00 */
bulletsize = 1.0;
horizontalstep = 0.5;
lefty = false;

radius = LN.getStrokeWidth() * bulletsize;
width = LN.getWidth();
scale = LN.getScale();
step = width / 150 + scale * width / 25;
x2 = LN.getX2();
y2 = LN.getY2();
xshift = lefty ? 1.2 : -0.2;
x2 = Math.floor(x2 / step / horizontalstep + xshift) * step * horizontalstep;
y2 = Math.floor(y2 / step + 0.3) * step;
LN.setClip(x2 - radius, y2 - radius, x2 + radius, y2 + radius);
LN.drawFilledCircle(x2, y2, radius);
[Android Apps and Games] bmwelch:
RE: bullet

Perfect! Thanks so much!!
[Android Apps and Games] Tamasaka:
Protractor

This script displays the digital value of the angle of a corner.

Parameter 1 chooses unit of angle from degree or radian.

Parameter 2 selects ruler length which is times of the step size of acadoid's standard grid.

Parameter 3 sets opacity of rulers. Transparent rulers are helpful to superimpose on the target corner. Value 0 chooses current color's opacity.

Parameter 4 selects display position from 4 quadrants around the center of the angle. Default position is floating to keep away from the rulers.

Touch on the target corner and drag to show temporary rendering of angled two rulers. The angle of the first ruler varies with the inclination between start and end point. The angle of the second ruler varies with the distance between the start point and the end point.

You have better to use this tool on another layer to the target figure.
[Android Apps and Games] travboat:
Cylinder

I have been lurking around this forum for a while, so I thought that I should finally register and contribute. I wrote some code for a cylinder!

/* cylinder 1.0 */
x1 = LN.getX1();
y1 = LN.getY1();
x2 = LN.getX2();
y2 = LN.getY2();

xmin = Math.min(x1, x2);
ymin = Math.min(y1, y2);
xmax = Math.max(x1, x2);
ymax = Math.max(y1, y2);

xbar = (x1+x2)/2;
r1 = Math.abs(x2-xbar);
r2 = Math.abs(0.2*(y2-y1));

LN.setClip(xmin, ymin - r1, xmax, ymax+r1);

LN.drawLine(x1, y1, x1, y2);
LN.drawLine(x2, y1, x2, y2);

LN.drawArc(xbar, ymin, r1,r2, 6.28, 6.28);
LN.drawArc(xbar, ymax, r1,r2, 0, 3.14);

View attachment 2883669
[Android Apps and Games] Tamasaka:
Thick arrow

This script draws a thick arrow with or without outline.

Parameter 1 is thickness of stem of arrow.

Parameter 2 is ratio of head width to the stem thickness.

Parameter 3 sets tip-angle of arrow head in degrees.

Parameter 4 selects the number of arrow heads.

Parameter 5 switches drawing style. When the value is 0, it draws only outline of arrow with current pencil. Value 1 gives filled arrow painted with current color. Value 2 gives filled arrow painted with current color and outlined in black with the stroke width of current pencil. Value 3 gives filled arrow painted with current color and outlined with white.

Parameter 6 is the switch for snapping to grid. 0 draws free from grid. 1 is for the start point snaps to coarse grid while the end point is free. 2 is for the start point snaps to coarse grid while the end point snaps to 1/5 fine grid. 3 is for both points snap to coarse grid.

In addition to the parameters, the length of arrow modifies the proportions of the arrow suitably.
[Android Apps and Games] Tintinnuntius:
Here's an update for all the containers I've uploaded before. New tools are in bold and some of the old ones have been tweaked a bit (eg. snapped to grid, resized for a better fit,...).

Discrete Maths:

- Graphs on n points (cycles, wheels, paths, etc.)

- Famous graphs (K(3,3), Petersen, Durer, Heawood, cube, octahedron,...)

- Circulant graphs

- Petersen graphs

- Venn diagram (just three simple circles)

- Truth table

- Sequences

- Divisors

Geometry:

- Sphere

- Torus

- Fractals

- Parametric curves

Probability:

- various discrete distributions (graphs and tables)

- Bell curve (graph)

- Chi squared curve (graph)

Statistics:

- Sample Statistics

- Pie Chart

- Bar Chart

- Linear Regression

- Student Table

- Chi-squared Table

Misc:

- Parabola

- Square Root Symbol

- Checkerboard

- Trees

- Buffon Needle Simulator

- Vector fields

- Euclidean Algorithm

Some tools would really benefit from string input, though, or at least integers/floats entered via numberical keyboard. For example, the script that lists all divisors of a given integer. It's a bit annoying to have to use the slider to find a particular integer between 1 and 1000. Initially, I wanted it to go up to 10000 or more since it doesn't take that much longer to run, but selecting the desired integer was too time consuming.

Similarly, linear regression uses precisely 5 data points right now. If at some point it becomes possible to input string parameters or at least use more than 10 parameters I'll tweak the tool to make it work for n points. I suppose I could borrow Tamasaka's method to write the data into the keyword file but I'd rather wait for more suitable input methods to become available.

Oh, and I've been experimenting with rainbow colors in some of the tools (like in Vector Fields, where the color of the vector depends on the angle). It makes for nice looking graphics but it slows the tools down even more. I'm quite certain that the tools are much slower on my Note 12.2 compared to 10.1. I don't have the 10.1 with me at the moment, so I cannot verify. Let me know if you have runtime problems with any of the tools although there's not much I can do to make them work. Sometimes it fails once and then works on the next try. Parametric curves seem to be particulary sensitive to the number of plotpoints, and Fractals to the level of recursion.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: Many thanks for posting these tools!

String parameters have not been forgotten, they will come very soon.

The number of parameters can be increased further, I noted that down. However, the dialog will get very confusing, won't it?

The performance of the tools is determined by the performance of the JavaScript engine on the device (and Android 4.4 brought a completely revised JavaScript engine).
[Android Apps and Games] Tintinnuntius:
Great, I'm looking forward to the string parameters. Once we have these I don't think increasing the number of parameters is necessary, since any number of them can be entered as a csv string or something along those lines.

Sadly for the JS engine "revised" is not "improved". Here's the first thing that came up when I googled "javascript android 4.4 slow":

https://groups.google.com/forum/#!topic/phonegap/1ZxXe6chHZc

They complain about the new webview and mention something called crosswalk which apparently speeds things up. Now, I've absolutely no idea what they're talking about, but is this something that could be used with LectureNotes to speed up custom drawing tools? They really are impossibly laggy even when they do not time out.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: The JavaScript engine on my Nexus 10 and my Nexus 7 (both running Android 4.4) is not particularly fast, but response of the drawing tools is OK.

To include an independent JavaScript engine (this is what Crosswalk would provide) might speed things a bit up, but this is likely to cause problems in other areas, so I am not sure whether this is a solution.
[Android Apps and Games] Tintinnuntius:
It must be a GN 12.2 thing then and not Android 4.4. I'm having other problems with lag. Sometimes the paper pattern dissapears when a new page is added and the file needs to be reopened for it to show up again (I'm using the Dotted pattern). At one point the pattern refused to show up in a brand new file even after reopening. Also, LectureVideos are useless because when the recording is in progress the lag is so bad it's impossible to write. I never use them, though, so that's not too big a problem at the moment.

Can anyone with GN 12.2 confirm any of these problems? I don't believe it's just my device because this was happening ever since I bought it. Even now it's less than two months old and I have not rooted it or changed much of anything. The only things I did in developers settings is I turned off the animations and tried Force GPU rendering on and off (I think on was a bit better, but JS still crashed, so it could be just my imagination and possibly totally unrelated).
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: In general, I recommend not to touch any of the options in the device's developer settings.

I am sorry to hear about the problem concerning LectureVideos. Again, my Nexus 10 has the same display resolution (2560 times 1600), and LectureVideos works fine. The general problem with these first generation of high-resolution devices is that the number of pixels and hence the amount of RAM to be handled quadrupled (from 1280 times 800 to 2560 times 1600), so that the rest of the hardware requires four times the speed to show the same overall response.
[Android Apps and Games] Tintinnuntius:
Well, like I said, I don't really need LectureVideos at the moment. The lag in custom tools and the random failure in loading the paper patterns are a bit annoying though. I just wish there was a magic setting I could tick to make it go away rather than sit around and wait for Samsung to maybe fix it in a sistem update. Well, if Nexus 10 works fine at least there's some hope... It also means the fault is not in LN app, so I guess there's nothing you can do at the moment.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: I just uploaded v2.5.5 into the app stores. This version allows for up to 20 parameters and both numerical and string parameters. Furthermore, LN.getMode() now returns 0 for the final drawing and 1 for the temporary drawing (up to now, it always returned 0 for custom drawing tools), so that one can distinguish in the code and do a faster temporary drawing.

I also revised the video recording, making it hopefully somewhat faster.
[Android Apps and Games] Tintinnuntius:
If I use the text parameter, then the variable I read it into always ends up with the value 0. For example, if I say

x = parseInt(LN.getParameter(1));
LN.drawText(x,x0,y0);

and then enter 100 at the prompt, it will draw a 0 in the middle of the screen, rather than 100. Am I doing something wrong or is this a bug? The same happens with

x = parseFloat(LN.getParameter(1));

or even just

x = LN.getParameter(1);

x is always set to 0.
[Android Apps and Games] acadoid:
[MENTION=4226212]Tintinnuntius[/MENTION]: LN.getParameter() yields 0 for a string parameter, you need to use LN.getStringParameter(); likewise, LN.getStringParameter() yields an empty string for a numerical parameter.
[Android Apps and Games] Tamasaka:
Speed test of custom drawing tools

I felt KitKat is apparently slow to execute custom drawing tools as Tintinnuntius mentioned.

So I tested how many times a function can be called in time on two machines of same hardware (Tegra Note 7) running different version of Android (JellyBean 4.2.2 and KitKat 4.4.2).

The temporary drawing was always faster than the final drawing, so I checked the final drawing.

Kitkat called 1810 LN.drawPoint(x,y), 1977 LN.getAlpha(), and 246 million Math.sin(a).

JellyBean called 46524 LN.drawPoint(x,y), 64323 LN.getAlpha(), and 237 million Math.sin(a).

The numbers are not accurate upper limits, but Math class functions are extremely fast. I feel something wrong with KitKat and LN class functions.
[Android Apps and Games] Tamasaka:
Speed test tool

The speed tests were carried out using this tool, which is a user interface to set number of loops speedily. You can easily repeat the loop test many times, and search the limit of loops.

At first, select one of three functions by Parameter 1.

Touch near left-bottom corner of a page, and you can see a table of numbers. Then drag to some cell of number, and loop-test starts with the number of loop. The value is shown in orange at bottom. The orange value is the looping number at the temporary drawing if the value is less enough to avoid timeout error. Then lift your pen or finger off and you will see the value in black if it is less enough at the final drawing.

The number in leftmost column represents power of ten and the numbers in square cells are mantissas. For instance, the cell "3" in the row of "1000" is the selection button for 3000 as the number of loops.

The green dot at left-bottom of the table is a mark for next test. Drag from the green mark at next test to overlay the table just on the table of the previous test.

The red line is the result of drawing points.

Warning! Large value causes timeout error and may abort app.

You can modify this code, and test other functions.
[Android Apps and Games] acadoid:
[MENTION=5816619]Tamasaka[/MENTION]: LectureNotes' JavaScript function are added to JavaScript via Android's WebView JavaScript interface, they are not hard-coded into JavaScript. If this interface is slow in KITKAT, calling LectureNotes' JavaScript functions will be slow.
[Android Apps and Games] Tamasaka:
Scatter plot

This script draws a scatter plot of data in string parameters or in keywords of the page.

Type in values and labels as csv (comma-separated values) in string parameters at the parameter setting dialog. Tap ‘OK’ and drag your pen on a page, and you get a chart of scatter plot.

Unfortunately, string parameters are volatile and we cannot reuse data in the string parameters. When string parameters are blank, this script gets data from keywords like previous "Table formatter" tool.

We can edit the keyword file and add data by selecting ‘Index page X’ (where ‘X’ indicates current page number) in the main menu of app. Data can coexist with real keywords in the keyword file.

Rows of data are restricted to start with ‘[’ or ‘,’.

Data should be surrounded with rows of [DATA] and [/DATA] tags. The data should be in csv with a leading comma.

The [/DATA] row needs to contain keyword ‘plot’.

Data format in the keyword file is;

[DATA] <title string>

csv with a leading comma

[/DATA] plot

The value in csv accepts double quotation and spaces.

The leftmost numeric column is data for horizontal axis.

The row just before [/DATA] tag can contain options that specify the shape, size and color of symbols.

The optional words are ‘open’, ‘fill’, ‘circle’, ‘square’, ‘diamond’, ‘large’, ‘small’, ‘dummy’, ‘black’, ‘green’, ‘blue’, ‘red’, ‘orange’, ‘marine’, ‘indigo’, ‘magenta’, and ‘brown’.

This script has two numerical parameters.

Parameter 1 selects vertical axis in linear scale or logarithmic scale.

Parameter 2 draws legend labels.

Depending on the data, a short help or error messages are shown.

Warning! When you use ‘Notebook index’, ‘Folder index’, ‘Notebook broad index’ or exported PDF, the data row behaves as if it were a keyword, and appears in the index.

This script needs app v2.5.5 or later.

Sample data as follows gives the sample plot attached.

[DATA]Sample plot
,X label, Label 1, Label 2, Label 3
,
, -15, 1.5, 8e-1
, 5, 4 , 2.1, 0.75
, 20, 8 , , 1.5
, 30, , 7
, 35, 17
, 50, 35, , 6.5
, , fill, blue, red
[/DATA] plot
[Android Apps and Games] nbog:
Where and how do I put one of these templates in my notebook? Copy the script and paste it where?
[Android Apps and Games] acadoid:
[MENTION=4803345]nbog[/MENTION]: The custom drawing tools can be accessed via the pencil toolbox (you will need to enable `include custom drawing tools´ in the pencil toolbox setup) or the drawing tools menu.

To have a look on the custom drawing tools and to add new ones, select `custom drawing tool settings´ in the `drawing´ menu (or double-click on a custom drawing tool in the pencil toolbox), this brings up a list of all custom drawing tools including the ones that are disabled by default. There, you can show, hide, and reorder custom drawing tools, add new custom drawing tools, add new containers, etc. The UI should be rather self-explaining.
[Android Apps and Games] nbog:
thanks, will try that. Off topic but related to LNotes, my 2 posts here

http://xdaforums.com/showthread.php?t=1790204

and

http://xdaforums.com/showthread.php?t=2214912
[Android Apps and Games] Tamasaka:
Table formatter update

Previous version was posted as #80 in this thread.http://xdaforums.com/showpost.php?p=53119998&postcount=80

1. Alternate data source (string parameters) added.

2. Numerical parameter for left-tab option added.

3. Formatting of the row just before [/DATA] tag improved. (If the row consists of non-numeric fields, the leftmost field is shown as a footer of table. Other fields in the row are ignored. This feature is for data compatibility with ‘Scatter plot’ tool above.)

4. Snapping feature improved. (Free from grid when drag down. Snaps to grid when drag up.)

5. Data source information by the temporary rendering added.

6. Floating help and error messages improved.

7. Minor issues fixed.

Following sample data is compatible for Table ver. 1.37 and Plot ver. 1.38.

Screenshots of the results attached.

[DATA]Sample2
,Battery,Energy density,Dulability,Discharge,Capacity/Cost,Safety
, , (Wh/kg) , (year) ,rates (C),
,
,Lead acid, 30 , 2 , 4 , 9 , 7
, Ni-Cd, 40 , 6 , 10 , 10 , 5
, Ni-MH, 60 , 4 , 5 , 6 , 10
, Li ion, 100 , 2 , 1.5, 3.5, 6
,Properties, , blue ,large red, orange fill
[/DATA] table plot
[Android Apps and Games] Tamasaka:
Speed test tool 2nd version

This tool times the execution time of functions in microsecond.

Touch near left-bottom corner of a page, and you can see a table of numbers and names of functions. Drag to some blue cell of number that is the number of loops, the name of selected function and the number turns to red. The value shown in red above the table is the average execution time of selected function at the temporary drawing if the number of loops is less enough to avoid timeout error. Then lift your pen or finger off and you will see the value of time in black at right of the function name if the number of loops is less enough at the final drawing.

The green ‘start’ button at left-bottom of the table is a mark for next test. Drag from the green ‘start’ button at next test, and the table overlaps just on that of the previous test.

Less loops result in a large error of time or zero, but too many loops cause timeout error and may abort app.

This script is not only a useful tool, but a model code of interactive user interface of custom drawing tools.

Script of this speed test tool was attached as a zip file.

The results of the test on three android tablets are summarized in the table data as follows which can be formatted with the ‘Table formatter’ above.

[DATA]Speed test on functions of LectureNotes custom drawing tool
,Function,KitKat 4.4.2,Jelly Bean 4.2.2,Jelly Bean 4.1.1
,,TegraNote 7,TegraNote 7,TF201
,
,LN.drawLine,722,47,88.9
,LN.drawPoint,719,39.6,75.7
,LN.getMode,727,16.2,30.7
,LN.getAlpha,723,17.4,34.9
,trim,0.145,0.16,0.36
,Math.sin,0.0042,0.0177,0.271
,Execution time in microsecond
[/DATA] table