it mostly clicks only in side (which is the sides pixels of a square) any idea how can click the middle area inside of pixelsearch? heres what i done but it wont work
$greenbox = PixelSearch(0, 0, #DesktopWidth, #DesktopHeight, 0x00FF00)
If isArray($greenbox) then
newX := greenbox[0] + 25
newY := greenbox[1] + 25
MouseMove($newX[0],$newY[1], 0)
MouseClick("Left")
$NewX and $NewY are not Arrays.
Try like this :
MouseMove($newX,$newY, 0)
MouseClick("Left")
or simplest :
MouseClick("Left,$newX,$newY)
Related
I recently tried to adapt some pseudocode for an in-place quicksort, quoted below:
function quicksort(array)
if length(array) > 1
pivot := select any element of array
left := first index of array
right := last index of array
while left ≤ right
while array[left] < pivot
left := left + 1
while array[right] > pivot
right := right - 1
if left ≤ right
swap array[left] with array[right]
left := left + 1
right := right - 1
quicksort(array from first index to right)
quicksort(array from left to last index)
Following this, I wrote this code:
quicksort<-function(array)
{
len<-length(array)
if(len>1)
{
left<-1
right<-len
pivot<-array[(left+right)%/%2]
while(left<=right)
{
while(array[left]<pivot){left<-left+1}
while(array[right]<pivot){right<-right-1}
if(left<=right)
{
array[c(left,right)]<-array[c(right,left)]
left<-left+1
right<-right-1
}
}
array<-quicksort(array[1:right])#Bug here
array<-quicksort(array[left:len])
}
array
}
If you run this code with more than one integer as an input, you'll find that it eventually tries to sort lists of NAs. I suspect that the problem is that the pseduocode wants array from first index to right - my 1:right - to be read as an empty sequence when right is zero. As is well known, R would actually read as 1:0 as the sequence 0 1.
Is there any function to get the behavior that I intend? I could do this with an if statement, but R is usually good enough with sequences that I can't help but think that there will be a better way. I tried to use seq, but it will throw an error if you try to use anything like seq(from=1,to=0,by=1).
There are two issues with the code:
One of the inequality signs is flipped.
The array assignment needs to be modified to only change a subset of elements rather than replace (and shrink) the whole array.
Here is the corrected code
quicksort <- function(array) {
len <- length(array)
if(len > 1) {
left <- 1
right <- len
pivot <- array[(left+right)%/%2]
while(left <= right)
{
while(array[left] < pivot){
left <- left + 1
}
while(array[right] > pivot) { # Changed "<" to ">"
right <- right - 1
}
if(left <= right) {
array[c(left, right)] <- array[c(right, left)]
left <- left + 1
right <- right - 1
}
}
# Modified the following two lines to only set a subset of array
array[1:right] <- quicksort(array[1:right])
array[left:len] <- quicksort(array[left:len])
}
array
}
quicksort(c(2, 6, 3, 1, 4, 5))
#> [1] 1 2 3 4 5 6
I'm trying to convert an image to 25% opacity via RMagick. The following works from the command line but I can't figure out how to do it in Ruby.
convert input.png -alpha on -channel A -evaluate set 25% +channel output.png
I've tried messing with Magick::AlphaChannelType::ActivateAlphaChannel but can't figure out how to chain the commands together. Any help would be greatly appreciated!
plz try this function to solve your problem
def watermark(opacity = 0.25, size = 'input')
manipulate! do |img|
logo = Magick::Image.read("#{Rails.root}/app/assets/images/{size}.png").first
logo.alpha(Magick::ActivateAlphaChannel)
white_canvas = Magick::Image.new(logo.columns, logo.rows) { self.background_color = "none" }
white_canvas.alpha(Magick::ActivateAlphaChannel)
white_canvas.opacity = Magick::QuantumRange - (Magick::QuantumRange * opacity)
# Important: DstIn composite operation (white canvas + watermark)
logo_opacity = logo.composite(white_canvas, Magick::NorthWestGravity, 0, 0, Magick::DstInCompositeOp)
logo_opacity.alpha(Magick::ActivateAlphaChannel)
# Important: Over composite operation (original image + white canvas watermarked)
img = logo.composite(logo_opacity, Magick::NorthWestGravity, 0, 0, Magick::OverCompositeOp)
end
end
Say I have a line coor1: (0,300) coor2: (600,300)
With that, I want to find the 2 middle third points which would be (200,300) (400,300)
Normally, I'd do something like:
x = (xCoor2 - xCoor1) * (1.0/3.0) + xCoor1;
y = yCoor1 - (yCoor1 - yCoor2) * (1.0/3.0);
But that would only work successfully in some cases. I need one statement that can find those 2 points when coor1 and coor2 are anywhere. Such as coor1: (400,400) coor2: (600,600)
Point left{0.0,300.0}, right{600.0,300.0}, one_third, two_thirds;
one_third = left + (right - left) *1.0/3.0;
two_thirds= left + (right - left) *2.0/3.0;
or more explicitly
one_third.x = left.x + (right.x - left.x) *1.0/3.0;
one_third.y = left.y + (right.y - left.y) *1.0/3.0;
two_thirds.x= left.x + (right.x - left.x) *2.0/3.0;
two_thirds.y= left.y + (right.y - left.y) *2.0/3.0;
I want to use the data of [x] to fill in [test] based on certain sequence:
x = matrix(rnorm(330),165,2)
origins = 130:157
horizon = 8
col = 1:2
test = array(0, c(length(origins)*length(col), horizon))
for( origin in origins){
for (c in col){
test[which(origin==origins), ] = x[(origin+1):(origin+8), c]
}
}
However, this code only helps extract the second column of [x] to fill in the first 28 rows of [test]. The following picture is only a part of a complete [test] table, showing the ineffective filling from row 29 to row 56.
enter image description here
Anyone who can help me fill in them completely? Thank you very much.
Here is a possible solution, but it is still not clear what you want the result to be. better to make much smaller data and show desired result.
The left hand side of the assignment, in the original code, does not vary with c, so each time through the loop for c the same rows of test will be overwrittem,
x = matrix(rnorm(330),165,2)
origins = 130:157
horizon = 8
col = 1:2
test = array(0, c(length(origins)*length(col), horizon))
for( origin in origins){
for (c in col){
# the left hand side must vary somehow with c as well.
test[(which(origin==origins)-1) + (c - 1) * length(origins) + 1, ] = x[(origin+1):(origin+8), c]
}
}
I have a 3d game where I will create an rectangle which is working as screen and the game itself works with vectors to positions. so I will create an rectangle and have only these parameters aviable:
start position ->vector (x,y,z).
Angle(rotation) of object(x,y,z).
size of rectangle.
now also the object need to be roatet to the right side so they are using angels also (x,y,z).
example:
position:-381.968750 -28.653845 -12702.185547
angle: -0.000 90.000 90.000
What I will create is an little bit hard but as idea simple.
I choose 2 complete different positions and angles and will create from the first vector to the second an rectangle.
I can only create an rectangle with the start point and angle.
and I can set the size so (x,y)
So I will now insert 2 positions(vectors) with 2 different angles
The rectangle will have the middle value between the first and second angle so like (90 and 0) -> 45
And the rectangle will start at the start vector and will end with his own size so I don't have a chance to use the end vector directly.
Legendary on photo:
Green=>start and end positions(vectors).
red => the marked zone.
Blue => how I will have the rectangle.
aem_point = vgui.Create( "AEM.Main.Panel" )
if IsValid(aem_point) then
aem_point:SetSize( 2,2 ) -- <-the size that i can set
aem_point:SetPos( 0, 0 )
aem_ph = vgui.Create( "DHTML", aem_point )
aem_ph:SetSize( aem_point:GetSize() )
aem_ph:SetPos(aem_point:GetPos())
aem_ph:SetVisible( true )
aem_ph:SetHTML([[
<html>
<body style="margin:0px;padding:0px;font-size:20px;color:red;border-style: solid;border-color: #ff0000;background-color:rgba(255,0,0,0.1);">
</body>
</html>
]] )
end
hook.Add( "PostDrawOpaqueRenderables", "DrawSample3D2DFrame" .. math.random(), function()
if first and dat_finish then
vgui.Start3D2D( input_position, input_angle, 1 ) -- <-and position&vec
aem_point:Paint3D2D()
vgui.End3D2D()
end
end )
Oh so you want to create a 3d2d plane from 2 vector positions?
Vec1 = A
Vec2 = B
input_position = ( Vec1 + Vec2 ) / 2
A problem you will run into is you need 3 points to generate a plane, so while you can get the position of the screen to get the angle of it you will need another point.
If these screens of yours are staticly set, as in you put their position into the lua code manually and dont intend to have it move or anything, just manually putting in the angle is by far the most simple approch.
As you can see, both of these planes are on the same two points, but they have diffrent angles.
I wrote the demo in expression 2, this should make it clear as to how this works, if you have any other questions just ask.
A = entity(73):pos()
B = entity(83):pos()
if(first())
{
holoCreate(1)
holoCreate(2)
}
holoPos(1,(A+B)/2)
holoScaleUnits(1,vec( abs(B:y() - A:y()) , 1 , abs(sqrt( ( B:z() - A:z() ) ^ 2 + ( B:x() - A:x() ) ^ 2 ))))
holoAng(1,ang(0,90,45))
holoPos(2,(A+B)/2)
holoScaleUnits(2,vec( abs(sqrt( ( B:x() - A:x() ) ^ 2 + ( B:y() - A:y() ) ^ 2 )) , 1 , abs(B:z()-A:z())))
holoAng(2,ang(0,45,0))