Excel 2010 BuildFreeForm Has NO Connection Points - excel-2010

When I use VBA to create a rectangle similar to one I draw on a worksheet, whay are there no connection points? After adding the last node I use ConvertToShape. It doesn't matter if I use msoEditingAuto or msoEditingCorner for all of the points. I can make the connection points available only if I use SetPosition on one of the nodes and use the existing position.

The following code from Microsoft's object reference gives an example of using connector points with rectangles:
Sub buildshape3()
Dim myDocument As Worksheet
Dim s As Object
Dim firstRect As Shape
Dim secondRect As Shape
Dim c As Shape
Set myDocument = Worksheets(1)
Set s = ActiveSheet.Shapes
Set firstRect = s.AddShape(msoShapeRectangle, 100, 150, 150, 150) '50, 200, 100)
firstRect.Fill.Transparency = 1
Set secondRect = s.AddShape(msoShapeRectangle, 300, 300, 200, 100)
Set c = s.AddConnector(msoConnectorCurve, 0, 0, 100, 100)
With c.ConnectorFormat
.BeginConnect ConnectedShape:=firstRect, ConnectionSite:=1
.EndConnect ConnectedShape:=secondRect, ConnectionSite:=1
c.RerouteConnections
End With
End Sub

Related

Plotting waveform in circular path

Trying to plot file waveform in circular form and looking through the underlying EZAudio's EZAudioPlot class docs tells me this should be possible. However I can't quite wrap my head how to construct the 'points' argument in the linked method. Anyone done this and could point to correct way?
UPDATE:
Looking into this I think I've gotten fairly good grasp how EZAudioPlotting works. The actual waveform drawing is done on EZAudioPlotWaveformLayer which is just simple CAShapeLayer subclass. On creation of EZAudioPlot one EZAudioPlotWaveformLayer is created and reference stored on EZAudioPlot class waveformLayer property.
The actual waveform is CGPath on EZAudioPlotWaveformLayer class and to manipulate it it should go something like below.
// Setup audio data for the plot
let file = EZAudioFile(url: url)
guard let data = file?.getWaveformData(withNumberOfPoints: pointCount) else {return}
// Setup the plot
let waveform = EZAudioPlot()
waveform.frame = CGRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)
waveform.gain = 10.0
// + any other property tweaking you need
//Get hold of the underlaying layer
let myLayer = waveform.waveformLayer!
// Create the default presentation for the waveforms as CGPath
let path = waveform.createPath(withPoints: waveform.points, pointCount: pointCount, in: EZRect(x: 0, y: 0, width: view.bounds.width, height: view.bounds.height)).takeRetainedValue()
// ??? Here somehow tweak the CGPath eg. into circular shape ???
newPath = plotPointsIntoCircleOrSomeOtherNiftyFunc(path)
// Stick new path to layer
myLayer.path = newPath
Only thing is that currently I haven't figured any math to actually implement anything meaningful at that pseudo code point

Disable Gravity for certain physic bodies

How can I disable gravity for certain physic bodies using LOVE Physics for Lua?
blocks.ground.body = love.physics.newBody(world, 0, blocks.ground.y, "dynamic")
blocks.ground.shape = love.physics.newRectangleShape(500, 50)
blocks.ground.fixture = love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
blocks.ground.color = {86,176,0}
That is my current code for the body, I also need it to stay "dynamic" because I need to move its X
View Full Code: code
Assuming you are using LÖVE 0.8.0+:
Option 1:
Your Code:
blocks.ground.body = love.physics.newBody(world, 0, blocks.ground.y, "dynamic")
blocks.ground.shape = love.physics.newRectangleShape(500, 50)
blocks.ground.fixture = love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
blocks.ground.color = {86,176,0}
Note: In your code love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
From LOVE's Website (1):
objects.ground.fixture = love.physics.newFixture(objects.ground.body, objects.ground.shape) --attach shape to body
Also from LOVE's Website (2):
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1) -- Attach fixture to body and give it a density of 1.
In the second snippet from their website they set the balls density (mass) to 1. Similarly you should be able to set the mass to 0 in which case gravity would have no affect on the object. However if other objects collide with your object, of mass 0, I am not sure what type of funky actions may occur.
Option 2:
The other option is to create a new world with gravity of 0:
love.physics.setMeter(64) --the height of a meter our worlds will be 64px
worldNoGravity = love.physics.newWorld(0, 0, true)
Then add the bodies to that world:
blocks.ground.body = love.physics.newBody(worldNoGravity , 0, blocks.ground.y, "dynamic")
blocks.ground.shape = love.physics.newRectangleShape(500, 50)
blocks.ground.fixture = love.physics.newFixture(blocks.ground.body, blocks.ground.shape)
blocks.ground.color = {86,176,0}
Hope one of those will work for you :).

Corona transition.moveTo() seems to stop other transitions on the same object?

local rect = display.newRoundedRect(200, 200, 150, 150, 2)
rect.fill = {0,0,0}
rect.alpha = 0.1
rect.xScale = 0.1
rect.yScale = 0.1
transition.to(rect, {time=1000, xScale=1, yScale=1, alpha=1}) -- transA
local function moveListener()
transition.moveTo(rect, {time=800,x=300, y=300}) -- this will puase transA!!
end
timer.performWithDelay(400,moveListener, 1)
Any idea how to perform moveTo() without stopping other transitions?
Cheers!
I just tried this on my computer, and it seems to be an issue with transition.moveTo().
It works using transition.to().
I just tried the following:
local rect1 = display.newRoundedRect(100, 100, 150, 150, 2)
rect1.fill = {0,0,0}
local rect2 = display.newRoundedRect(300, 100, 150, 150, 2)
rect2.fill = {1,0,1}
transition.moveTo(rect1, {time=1000, y=500})
transition.to(rect2, {time=1000, y=500})
And noticed that rect1 moved after rect2 with some delay!. However, adding small delay to transition.to() will make the movement exactly identical as follows:
transition.to(rect2, {delay=1, time=1000, y=500})
To summerize, it is still an issue with moveTo() to stop other transitions. As work around, in order to get exact behavior just use transition.to() with micro delay as previous line of code!
Thanks.....

Batch variable creation in Swift

So im writing my first lines of code in Swift, and i want to make a game where you need to tilt the device to make a gravity shift and by doing so make a ball drop to the floor while maneuvering around obstacles.
Ive been looking up different methods, and I found one where you can make the obstacles by just using let, For example (Im using UIKit)
let barrier1 = UIView(frame: CGRect(x: 0, y: 300, width: 20, height: 20))
barrier1.backgroundColor = UIColor.redColor()
view.addSubview(barrier1)
Its quite a bit of code to declare every barrier this way, and I was hoping if there was a way of doing this in a while loop where every time the loop runs, x = x + 1 is stated and you make variables that way in batch. Can anyone help me? Thanks!
This is what arrays are for. Declare a variable called barriers of type [UIView] and then append each new barrier to this array.
var barriers:[UIView] = []
for i in 1...20 {
let newbarrier = UIView(frame: CGRect(x: 0, y: 300 + i * 30, width: 20, height: 20))
newbarrier.backgroundColor = UIColor.redColor()
view.addSubview(newbarrier)
barriers.append(newbarrier)
}
// Now you can refer to each barrier by its index: barriers[0], barriers[1]
// up to barriers[19]

newTextField overlapping newRect in group

I have a problem with Corona SDK. I want my newRect to overlap newTextField control. My code:
local localGroup = display.newGroup()
local txtOne = display.newTextField( display.contentWidth/2 - 140, 260, 280, 60)
local txtTwo= display.newTextField( display.contentWidth/2 - 140, 360, 280, 60)
local rect= display.newRect( display.contentWidth/2 - 140, 160, 200, 360)
localGroup:insert(txtOne)
localGroup:insert(txtTwo)
localGroup:insert(rect)
Result i have: txtOne and txtTwo always overlapping my rect object. But I want rect object to be on top of
txtOne and txtTwo. Is there a way to do this?
According to the docs
Because native textfields are not part of the OpenGL canvas, they do
not obey the Corona display object hierarchy. They always appear
above normal display objects, and cannot be inserted into display
groups.
So you can't bring the rect object in front.
You can work around it if you want. Just hide the textfield when not necessary
Read This link.
Try:
rect:toFront()
Read this link for creating textfield.

Resources