unable to enter data in Input Control of a GUI in autoit - user-interface

The below one is my code. I am unable to click and edit in the second Input control.
#include <GUIConstants.au3>
$gui = GuiCreate("Hello World", 700, 600)
$Label_HelloWorld = GuiCtrlCreateLabel("Path / Directory", 40, 20, 300, 18)
$file = GUICtrlCreateInput("", 140, 20, 300, 20)
$Label_boot = GuiCtrlCreateLabel("path of boot.c", 40, 60, 300, 18)
$file2 = GUICtrlCreateInput("", 140, 60, 300, 20)
$Button_OK = GuiCtrlCreateButton("CHECK", 400, 90, 50, 20)
GuiSetState(#SW_SHOW, $gui)
Sleep(10000)

Your labels are overlapping the controls (again), this time horizontally. A width of 300px when the inputs are 100px to the right means the first 200px is overlapping. If you try to click in the last 100px of the input then it will work.
This is very easy to check for, just use the autoit window info tool and look at the outlines of the controls.

Related

d3.scaleLog ticks with base 2

I trying to produce ticks for scaleLog().base(2).
Seems to be, it does not work correctly.
For instance, for the call:
d3.scaleLog().base(2).domain([50,500]).ticks(10)
I got:
[ 50, 100, 150, 200, 250, 300, 350, 400, 450, 500 ]
Which just linear placed ticks. For base(10) it works properly.
d3.scaleLog().base(10).domain([50,500]).ticks(10)
[ 50, 60, 70, 80, 90, 100, 200, 300, 400, 500 ]
I using d3.js version 6.1.1.
I am missing something?
You're not missing anything, but there is this line, inside the source code:
if (z.length * 2 < n) z = ticks(u, v, n);
Here, z is the generated array (in this case [64, 128, 256]), n is the required number of ticks (10), and u and v are the domain (50 and 500).
Because the number of generated ticks is too low, d3 defaults to a linear scale. Try one of the following instead:
console.log(d3.scaleLog().base(2).domain([50, 500]).ticks(6));
console.log(d3.scaleLog().base(2).domain([32, 512]).ticks(10));
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.1.1/d3.min.js"></script>
If all parameters are variable, you could calculate the maximum possible number of ticks and use that as an upper bound:
const domain = [50, 500];
const ticks = 100;
console.log(d3.scaleLog().base(2).domain(domain).ticks(ticks));
function getNTicks(domain, ticks) {
const maxPossibleTicks = Math.floor(Math.log2(domain[1]) - Math.log2(domain[0]));
return Math.min(ticks, maxPossibleTicks);
}
console.log(d3.scaleLog().base(2).domain(domain).ticks(getNTicks(domain, ticks)));
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/6.1.1/d3.min.js"></script>

Hover over button

I want to make a shape in gosu to have a border when a mouse hovers over it.
Gosu.draw_rect(50, 50, 100, 50, Gosu::Color::GREEN, ZOrder::TOP, mode=:default)
I expect the output, the shape will have a black border around it when the mouse cursor hovers over the rectangle
You can add a check in update routine.
def update
if mouse_over?(50, 50, 150, 100)
Gosu.draw_rect(50, 50, 100, 50, Gosu::Color::GREEN, ZOrder::TOP, mode=:default)
end
end
def mouse_over?(px1, py1, px2, py2)
mx = mouse_x
my = mouse_y
((mx >= px1) && (my >= py1)) && (mx <= px2) && (my <= py2)
end
mouse_x and mouse_y are variable provided by Gosu.
HERE MORE INFO...

How can I create an array from a method with ruby

How can I make an array of 30 min intervals to 8 hours. so this ish:
[30, 60, 90, all-the-way-to, 480]
You can use a Range and the step method, then convert it to an Array:
(30..480).step(30).to_a
The result is:
[30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480)
Your arguments are
increment = 30
duration = 480 # 8*60
You could use
increment.step(by: increment, to: duration).to_a
#=> [ 30, 60, 90, 120, 150, 180, 210, 240,
# 270, 300, 330, 360, 390, 420, 450, 480]
which reads well. Numeric#step, when used without a block, returns an enumerator, which is why .to_a is needed.
I came up with this, but #infused answer is way better.
a = (1..16).to_a.map{|i| i*30 }
Option selecting (Enumerable#select) from the range:
stop = 480
step = 30
(step..stop).select { |n| n % step == 0 }
#=> [0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330, 360, 390, 420, 450, 480]

Processing - Ellipse is covering text

In the below image, I would like to have the score as text within the green ellipse. However, the ellipse is being drawn over the text, regardless of the order of the ellipse() and text() functions in the loop. Can anyone suggest why? My draw loop is shown below.
import processing.core.PApplet;
import processing.core.PFont;
public void drawHUD(PApplet marker, Clock time, int score)
{
PFont font = marker.createFont("Impact", 25, true);
marker.textFont(font);
marker.ellipseMode(CENTER);
fill(25, 100, 25);
marker.ellipse(50, marker.height - 50, 75, 50);
marker.noFill();
marker.text("Score: ", 25, marker.height - 100);
marker.text(score, 50, marker.height - 50);
marker.text("Seconds left: ", marker.width - 175, marker.height - 100);
marker.text(time.toString(), marker.width - 125, marker.height - 50);
}
Try replacing marker.noFill(); with marker.fill(255);. I don't believe noFill() works for text, and I have a feeling the text is being drawn above the ellipse, but is just the same colour as the ellipse so can't be seen.
I deleted the ellipsemode. It got rid of the center ellipse, but it got the text to the front.

Spotting the first local minimum of 2 column CSV data in a Bash shell script

I want to write a Bash shell script function to return the x, y coordinates of the first local minimum data point in simple 2 column CSV data.
The function would take as an input a Bash variable (say "${myData}") storing data such as the following:
10, 0.14665
20, 0.144971
30, 0.14262
40, 0.142424
50, 0.142370
60, 0.142375
70, 0.142375
80, 0.142375
90, 0.142375
100, 0.142375
110, 0.142306
120, 0.142017
130, 0.141054
140, 0.140148
150, 0.139993
160, 0.139972
170, 0.139958
180, 0.139932
190, 0.139886
200, 0.139876
210, 0.13987
220, 0.139865
230, 0.139861
240, 0.13986
250, 0.139857
260, 0.139855
270, 0.139853
280, 0.139852
290, 0.139847
300, 0.139847
I want the function to spot the first local minimum point (in this case, this would correspond to the coordinate 50, 0.142370) and return the coordinate of this point. Could you suggest a simple way of doing this?
You can use awk, either on one line or prettily indented as in here:
awk '
NR > 1 {
if ($2 > n) {
print line;
exit(0);
}
}
{
line=$0;
n=$2
}
' <<< "${myData}"
You can also take out the exit(0); to show all local minimas.

Resources