Apply some picture to the circle graphic in the as3 - image

So, I already have the circle in my screen and showed it up, but I wanted to change the graphic from the "default circle", which is created by using the code like so:
circle.graphic.BeginFill();
circle.graphic.DrawCircle(10,10,10);
circle.graphic.EndFill();
addChild(circle);
I wanted to change that to my desired image like so:
How do I do that?

Use BitmapData and beginBitmapFill with circle like so:
var myBitmap:BitmapData;
var imgLoader:Loader = new Loader();
imgLoader.load(new URLRequest("myImage.png"));
imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, drawImage);
function drawImage(e:Event):void
{
myBitmap = new BitmapData(imgLoader.width, imgLoader.height, false);
myBitmap.draw(imgLoader);
var circle:Sprite = new Sprite();
circle.graphics.beginBitmapFill(myBitmap, null, true);
circle.graphics.drawCircle(50,50,100);
circle.graphics.endFill();
addChild(circle);
}
For more info see beginBitmapFill()

Related

Potree Zoom in/out on click

I am trying to zoom in/out when the user clicks the “+” or “-” buttons on my control panel. I got it to move left, right, up, down with the “tweenFunction” and it worked. I’ve tried
viewer.scene.camera.zoom += 0.1;
Which didn’t work for me because I don’t have the “camera” variable in my code, only the viewer. Here is my code
setup();
window.viewer = new Potree.Viewer(document.getElementById("potree_render_area"));
viewer.setEDLEnabled(false);
viewer.setFOV(60);
viewer.setPointBudget(5*1000*1000);
document.title = "";
viewer.setBackground("gradient"); // ["skybox", "gradient", "black", "white"];
viewer.loadSettingsFromURL();
viewer.loadGUI(() => {
viewer.setLanguage('en');
$("#menu_scene").next().show();
//viewer.toggleSidebar();
});
viewer.setDescription(`
`);
let sceneSG = new Potree.Scene();
let sceneSG2 = new Potree.Scene();
viewer.setScene(sceneSG);
Potree.loadPointCloud("model.js", "model", function (e){
sceneSG.addPointCloud(e.pointcloud);
sceneSG.view.position.set(37.812, -26.781, 51.178);
sceneSG.view.lookAt(new THREE.Vector3(-53.587, 33.834, 28.864));
let material = e.pointcloud.material;
material.size = 1;
material.pointSizeType = Potree.PointSizeType.ADAPTIVE;
});
you can't access "directly" to viewer.scene.camera because potree has two cameras (a perspective one and an orthographic). But you can access to the active camera with this function:
viewer.scene.getActiveCamera()
So if you want to zoom in, it could look like this:
var myactivecamera = viewer.scene.getActiveCamera();
myactivecamera.zoom += 0.1;

TextGeometry and PointCloud

I want to obtain vertixes for any given text. Text is created via TextGeometry and then PointCloud is instantiated:
var textGeo = new THREE.TextGeometry( "three.js", {...});
var textMaterial = new THREE.MeshBasicMaterial({
color:0x8080FF,
side:THREE.DoubleSide,
});
textObject = new THREE.PointCloud( textGeo, textMaterial)
The effect is following:
As you can see, the issue is that, points are not uniformely distributed, especially they are missing on straight lines.
Do you guys have any suggestions how to achieve a nicer effect?
I met the same problem. And I change the .JSON in THREE.FontLoader.load(),then I can see most of the points.
fontLoader.load('build/optimer_bold.typeface.json',
function (font) {
let fontOptions = {
font:font,
size:10
......
}
.....
}
);
Try the optimer_bold.typeface.json.

nokia Imaging SDK customize BlendFilter

I have created this code
Uri _blendImageUri = new Uri(#"Assets/1.png", UriKind.Relative);
var _blendImageProvider = new StreamImageSource((System.Windows.Application.GetResourceStream(_blendImageUri).Stream));
var bf = new BlendFilter(_blendImageProvider);
Filter work nice. But I want change image size for ForegroundSource property. How can I load image with my size?
If I understood you correctly you are trying to blend ForegroundSource with only a part of the original image? That is called local blending at it is currently not supported on the BlendFilter itself.
You can however use ReframingFilter to reframe the ForegroundSource and then blend it. Your chain will look like something like this:
using (var mainImage = new StreamImageSource(...))
using (var filterEffect = new FilterEffect(mainImage))
{
using (var secondaryImage = new StreamImageSource(...))
using (var secondaryFilterEffect = new FilterEffect(secondaryImage))
using (var reframing = new ReframingFilter(new Rect(0, 0, 500, 500), 0)) //reframe your image, thus "setting" the location and size of the content when blending
{
secondaryFilterEffect.Filters = new [] { reframing };
using (var blendFilter = new BlendFilter(secondaryFilterEffect)
using (var renderer = new JpegRenderer(filterEffect))
{
filterEffect.Filters = new [] { blendFilter };
await renderer.RenderAsync();
}
}
}
As you can see, you can use the reframing filter to position the content of your ForegroundSource so that it will only blend locally. Note that when reframeing you can set the borders outside of the image location (for example new Rect(-100, -100, 500, 500)) and the areas outside of the image will appear as black transparent areas - exactly what you need in BlendFilter.

Blend two images with pixastic does not work. How to get the new image?

Hey i´m trying to blend two images with pixastic. One image can be dragged an dropped on the other image (with jqueryUI) and after it has got the right position the two images shall become one.
So i want to use the pixastic blend effect.
I tried this so far:
function BlendTheImages() {
var img = new Image();
img.onload = function() {
var blendImg = new Image();
blendImg.onload = function() {
Pixastic.process(img, "blend",
{
amount : 1,
mode : "multiply",
image : blendImg
}
);
}
blendImg.src = "Small_Image.png";
}
img.src = "Background_Big_Image.jpg";
}
The function BlendTheImages should be called, when the smaller image has the right position to blend the two images.
I don´t know if it works or how i can get the new blended image..
Please help me! Thanks
I thought about using html2canvas to grab the image but then I got really surprised when I discovered that, even though it's not documented in Pixastic's website, the Blend effect also has a callback function (that works just like the other effects):
var img = new Image();
img.onload = function() {
Pixastic.process(img, "blend",
{
amount : 1.0,
mode : "Multiply",
image : someOtherImage
}, function(blendedImg) {
console.log(blendedImg);
applySepia(blendedImg);
}
);
}
document.body.appendChild(img);
img.src = "myimage.jpg";
There's a callback for the Pixastic.process function and it works for all effects.

Dat.gui with Three.js

I need to put a link within the control dat.gui to open an html file, How to do this ? I have already put levels of transparency and checkbox but do not know how do to open a link.
This has nothing to do with Three.js. Anyway, just pass a function variable/member like you would do other controls... It will create a button with your function in onclick. Example:
var obj = {};
obj.sampleNumber = 1;
obj.sampleLink = function() {
window.open("myfile.html");
}
var gui = new dat.GUI();
gui.add(obj, 'sampleNumber', -5, 5);
gui.add(obj, 'sampleLink');

Resources