Canvas Background Color - smartface.io

how can i set the canvas background? its always shown black. if i set the fillcolor its just filling the circle, outside is still black.
this.drawArc({
x1 : 10,
y1 : 10,
x2 : "95%",
y2 : "95%",
startAngle : -270,
endAngle : 90,
useCenterLines : false,
paint : {
type : 0,
fillColor : null,
strokeColor : "#cccccc",
width: 20
}
});

Background color of the Canvas object is not a changeable property.
Android uses it as Black , iOS uses is as Transparent.
These are native behaviours of Canvas objects.

i think nearest solution is using drawimage before drawing canvas object
this.drawImage({
image:"imagebg2.png", // image filled by bg color
destRect : [0, 0, this.Canvas1.width, this.Canvas1.height]
});
but its rendering colors different

Related

What is the correct way to parent ImageBundles in the Bevy game engine so the child image doesn't alter the size of the parent image?

When I try to parent two ImageBundles together I don't get the expected result. The child image causes the parent image to resize to the size of the child image. I am trying to place the button image on top of the background image, but the following code places the button image on the background image and then scales the background image to the size of the button image.
If I comment out the push_children line of code then both images are displayed at the correct size.
let ent1 = commands.spawn_bundle(ImageBundle {
style: Style {
align_self: AlignSelf::Center,
..Default::default()
},
material: materials.add(
asset_server.load("Background.png").into()),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)),
..Default::default()
}).id();
let ent2 = commands.spawn_bundle(ImageBundle {
style: Style {
align_self: AlignSelf::Center,
..Default::default()
},
material: materials.add(
asset_server.load("button.png").into()),
transform: Transform::from_translation(Vec3::new(0.0, 0.0, 0.0)),
..Default::default()
}).id();
commands.entity(ent1).push_children(&[ent2]);

invert image black to white in flutter

I have a bitmap image with black and white color I just need to invert the image and display how can I convert and display image. I have inverted bitmap image in java using this code can anyone suggest me how to do this in a flutter.
private Bitmap createInvertedBitmap(Bitmap src) {
ColorMatrix colorMatrix_Inverted =
new ColorMatrix(new float[] {
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0});
ColorFilter ColorFilter_Sepia = new ColorMatrixColorFilter(
colorMatrix_Inverted);
Bitmap bitmap = Bitmap.createBitmap(src.getWidth(), src.getHeight(),
Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint();
paint.setColorFilter(ColorFilter_Sepia);
canvas.drawBitmap(src, 0, 0, paint);
return bitmap;
}
Now it is possible to change/invert the color via ColorFiltered class
You can refer to this blog for more details: https://www.burkharts.net/apps/blog/over-the-rainbow-colour-filters/
Another solution
You can try using ShaderMask class, and try passing it to the corresponding Shader, such as InvertColorShader. Currently, no shader can do this as of now.
Also check out BlendMode class to achieve your desired result.

Showing a fix boundary box to capture image

My ionic appp is to take pictures of business cards. as 99% of the business cards are landscape style so users tries to change the camera orientation to landscape mode as well. This is a natural behavior.
However, i want to avoid that and one way is to show a rectangle while camera is open (width equal to screen width and a 3:2 aspect ratio for height)
This will make life easy as users wont try to change the camera orientation.
I was looking into camera plugin which uses code like
this.camera.getPicture({
destinationType: this.camera.DestinationType.DATA_URL,
quality: 25,
correctOrientation: true,
allowEdit:false,
sourceType: this.camera.PictureSourceType.SAVEDPHOTOALBUM
}).then(async(imageData) => {
//console.log("image data is:" + imageData)
// imageData is a base64 encoded string
var base64Image = "data:image/jpeg;base64," + imageData;
I was trying targetWidth and height but that does not draw that box like i have seen in many other apps.
there are other plugins like cropperJs but seems they let u crop the image after taken which not what i need.
Use camera-preview-plugin instead of camera for that :
const cameraPreviewOpts: CameraPreviewOptions = {
x: 0,
y: 0,
width: window.screen.width,
height: window.screen.height,
camera: 'rear',
tapPhoto: true,
previewDrag: true,
toBack: true,
alpha: 1
}
Ionic Camera Preview

Getting Invalid normalized color error when changing image color in Unity

I want to change the background color of my canvas from the script. The following script is attached to the canvas:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class CanvasController : MonoBehaviour {
Color lightBlue = new Color(173, 222, 246);
Color purple = new Color(107, 62, 143, 255);
void Start () {
Image img = transform.GetComponent<Image>();
img.color = lightBlue;
}
void Update () {
}
}
However, when I press play the color turns white and I get two errors:
Invalid normalized color: RGBA(107.000, 62.000, 143.000, 1.000), normalize value: 0
UnityEditor.DockArea:OnGUI()
Setting normalized color with a non-normalized color: RGBA(107.000,62.000,143.000,1.000)
UnityEditor.DockArea:OnGUI()
When you use Color you have to pass a value between 0 and 1.
You can use Color32 to pass values between 0 and 255.
Links to documentation for Color and Color32

unable to set background color on iTextSharp signature appearance

Does anyone have any ideas on how to set the background color on the PdfSignatureAppearance rectangle in iTextSharp? I create the PdfSignatureAppearance object and can set its positioning on the page, but the rectangle only has a transparent background. I'm trying to apply a color (any really).
I've tried creating a new iTextSharp.text.Rectangle then setting the rect.BackgroundColor = new BaseColor(System.Drawing.Color.Yellow); That doesn't work. I saw someone else trying to something similar by applying the styles to the layer2 of the signature appearance object. I've tried these with no luck.
PdfTemplate sigAppLayer2 = appearance.GetLayer(2);
sigAppLayer2.SetRGBColorFill(255, 0, 0);
sigAppLayer2.SetGrayFill(2);
sigAppLayer2.BoundingBox.BackgroundColor = new BaseColor(System.Drawing.Color.Yellow);
Anytime I try one of the above styling changes to the layer2 the visible signature disappears on the PDF. If I try applying it to layer 0 or layer 1 then nothing happens. I'm assuming then I'm touching the correct layer (2).
Any ideas? The goal is to just get a background on the signature box vs having it be transparent.
See comment below. I tried this as well setting against layer 2 and layer 0. Both result in a red box, but the signature text is missing.
PdfTemplate sigAppLayer2 = appearance.GetLayer(2);
Rectangle rect = sigAppLayer2.BoundingBox;
PdfTemplate sigAppLayer0 = appearance.GetLayer(0);
sigAppLayer0.SetRGBColorFill(255, 0, 0);
sigAppLayer0.Rectangle(rect.Left, rect.Bottom, rect.Width, rect.Height);
sigAppLayer0.Fill();
You need to draw the rectangle and fill that rectangle with the fill color.
From memory (untested), you need something like this:
PdfTemplate sigAppLayer2 = appearance.GetLayer(2);
Rectangle rect = sigAppLayer2.BoundingBox;
sigAppLayer2.SetRGBColorFill(255, 0, 0);
sigAppLayer2.Rectangle(rect.Left, rect.Bottom, rect.Width, rect.Height);
sigAppLayer2.Fill();
This is the way:
PdfTemplate sigAppLayer2 = appearance.GetLayer(2);
Rectangle rect = sigAppLayer2.BoundingBox;
sigAppLayer2.SetRGBColorFill(255, 0, 0);
sigAppLayer2.Rectangle(rect.Left, rect.Bottom, rect.Width, rect.Height);
sigAppLayer2.Fill();
sigAppLayer2.ResetRGBColorFill();// <--------- you needs this
sigAppLayer2.BeginText() ...etc