I'm struggling with the problem that the image is displayed terribly badly in canvaskit mode on flutter web. Of course, if you take a smaller size than the original, the image will not be sharp. I have seen this problem in many places. But I couldn't find a working solution anywhere. It's sad that this doesn't work in flutter 3.7.3 stable either. Of course, there is no such problem when rendered in html, but then the animations are cruelly choppy. Simply, none of the displays are good. And the project has grown too big to be worth rewriting into a native framework. My question is how to solve this image problem in canvaskit so that the smaller images stay sharp. Or how to move animation smoothly in html markup.
filterQuality: I already tried the FilterQuality.high solution, but it doesn't work for me.
Container(
height: size,
width: size,
decoration: url.isNotEmpty || !enableBorder
? null
: BoxDecoration(
borderRadius: BorderRadius.circular(size / 2),
border: Border.all(color: lightPurple, width: 1.2),
),
child: ClipRRect(
borderRadius: BorderRadius.circular(size / 2),
child: Image.network(
photoUrl,
filterQuality: FilterQuality.high,
loadingBuilder: (context, child, loadingProgress) {
if (loadingProgress?.expectedTotalBytes == loadingProgress?.cumulativeBytesLoaded) {
return child;
}
final value = (loadingProgress?.cumulativeBytesLoaded ?? 0.0) /
(loadingProgress?.expectedTotalBytes ?? 0.0);
return Padding(
padding: EdgeInsets.all(size / 3),
child: CircularProgressIndicator(value: value),
);
},
errorBuilder: (context, error, stackTrace) {
return Container(
height: size,
width: size,
color: midBlue,
);
},
fit: BoxFit.cover,
height: size,
width: size,
),
),
),
Picture urls:
https://saltnqcejbmjsxggcyze.supabase.co/storage/v1/object/public/ezduels/klan/cvyxcyvsfawef/logo/scaled_07b133e78156c97e369946d65b4bfef6.jpg
https://saltnqcejbmjsxggcyze.supabase.co/storage/v1/object/public/ezduels/klan/Kep_feltoltes_teszt10/logo/scaled_FJjvZ38UYAMpSEB.jfif
https://saltnqcejbmjsxggcyze.supabase.co/storage/v1/object/public/ezduels/klan/AfadwefwgToltes/teszt/logo/scaled_logo.png
Related
I am using open layers 6 lib for map rendering and events.
my application needed same like this example http://viglino.github.io/ol-ext/examples/layer/map.geoimage.html i.e. Example have ol.source.GeoImage..
I have tried
i am using affine transformation above lib and returns scaling, rotation and center of image transformation..
its giving the values
scaling : 327.805670381418,327.805670381418
rotation : -0.1310210334156003
transformation : 7179251.8557908312,6022627.228704552
now I have calculated extent and image projection & image static source is in ol 6
and
rotated image projection in this link (https://codesandbox.io/s/reprojection-image-z0uit)
// center of image from affine
const translationX = transformation.getTranslation()[0];
const translationY = transformation.getTranslation()[1];
extent = transformExtent([translationX - (xScale * this.imageData.width / 2),
translationY - (yScale * this.imageData.height / 2),
translationX + (xScale * this.imageData.width / 2),
translationY + (yScale * this.imageData.height / 2)],
get('EPSG:3857'), get('EPSG:4326'));
const imageProjection = this.returnRotateProjection(
viewProjection,
fromLonLat([transformation.getTranslation()[0], transformation.getTranslation()[1]], 'EPSG:4326'),
transformation.getRotation(),
extent
);
const imgSource = new Static({
url: this.imgURL,
projection: imageProjection,
imageExtent: extent,
imageSize: [this.imageData.width, this.imageData.height],
imageLoadFunction : (image) => {
image.getImage().src = this.imgURL;
if (image.resolution === undefined) {
image.resolution = (image.extent[3] - image.extent[1]) / image.image_.height;
}
image.state = 2; // ImageState.LOADED;
image.unlistenImage_();
image.changed();
}
});
here issue is image resolution is very bad like image displaying like curve shape
is there any possibles for finding 4 corners(bounding box using center of image and rotated image center point and width, height, scalling)
suggest or help on this.. thanks in advance.. and save my days..
gis
Is it possible to make Stroke width dependent on the zoom level?
Basically, I am going to use LineStrings/MultiLineStrings to highlight some roads but I would also like to be able to zoom out and not have massive clutter (there will be about 8 pretty wide lines along each path).
You can use the resolution which is passed to a style function. I've use this code to display contours, setting lines at multiples of 50m wider, and when the resolution is greater than 2.5 both widths are reduced proportionately.
style: function(feature, resolution) {
return new ol.style.Style({
stroke: new ol.style.Stroke({
color: 'rgba(224,148,94,1)',
width: (feature.getProperties().value % 50 == 0 ? 3.175 : 1.863) * Math.min(1, 2.5/resolution)
})
});
}
I created a Cesium label, using the following code:
var label: Cesium.LabelGraphics = new Cesium.LabelGraphics({
text : lab,
verticalOrigin: Cesium.VerticalOrigin.TOP,
horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
font: '15px Helvetica',
fillColor: Cesium.Color.WHITE,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL,
pixelOffset: new Cesium.Cartesian2(20, 20)
});
But it is blurred...
I would like to have a clearer label. Is this image you can see inside the red rectangle the real label. In the blue rectangle is the label with a zoom In. In the green rectangle is how I would like it to be.
Is there some way to make the label clearer?
Thanks!
In Bllboard.js or Cesium.js change
gl_Position = czm_viewportOrthographic * vec4(positionWC.xy,-positionWC.z, 1.0);
to
gl_Position = czm_viewportOrthographic * vec4(floor(positionWC.xy + 0.5), -positionWC.z, 1.0);
It will makethe billboards snap to a pixel, instead of get blurred.
also disable the FXAA (antialias) in your viewer initialization
viewer.scene.fxaa = false
it will make the billboards and labels much more crispy !
Before
.
After
A trick I sometimes use is to combine a larger font size with a scale setting on the label to scale the large font down using WebGL. This is a slightly different scaling than simply picking a smaller font size, because WebGL's texture scaling system comes into play to scale the rasterized font images. This works because Cesium labels are not anchored to an integer pixel position, they can be placed at coordinates with sub-pixel precision. So, the extra resolution in the label texture comes in handy as the label moves around. Of course this method costs a little bit more texture memory, but is usually worth it to get the cleaner edges.
Here's an example, showing the difference between normal (no scaling), double (0.5 scaling), and triple (roughly, 0.3 scaling).
var viewer = new Cesium.Viewer('cesiumContainer', {
navigationHelpButton: false, animation: false, timeline: false
});
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : 'Label == || normal',
verticalOrigin: Cesium.VerticalOrigin.TOP,
horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
font: '15px Helvetica', // NOTE: Standard size, no scaling here.
fillColor: Cesium.Color.WHITE,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL,
pixelOffset: new Cesium.Cartesian2(20, -10)
}
});
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : 'Label == || double',
verticalOrigin: Cesium.VerticalOrigin.TOP,
horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
font: '31px Helvetica',
fillColor: Cesium.Color.WHITE,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL,
pixelOffset: new Cesium.Cartesian2(20, 20),
scale: 0.5
}
});
viewer.entities.add({
position : Cesium.Cartesian3.fromDegrees(-75.1641667, 39.9522222),
label : {
text : 'Label == || triple',
verticalOrigin: Cesium.VerticalOrigin.TOP,
horizontalOrigin: Cesium.HorizontalOrigin.RIGHT,
font: '57px Helvetica', // NOTE: Large font size here
fillColor: Cesium.Color.WHITE,
outlineWidth: 2,
style: Cesium.LabelStyle.FILL,
pixelOffset: new Cesium.Cartesian2(20, 50),
scale: 0.3 // NOTE: Large font images scaled down via WebGL texturing.
}
});
html, body, #cesiumContainer {
width: 100%; height: 100%; margin: 0; padding: 0; overflow: hidden;
}
<link href="http://cesiumjs.org/Cesium/Build/Cesium/Widgets/widgets.css"
rel="stylesheet"/>
<script src="http://cesiumjs.org/Cesium/Build/Cesium/Cesium.js"></script>
<div id="cesiumContainer"></div>
I have a problem with the HTML5 Canvas. I use jCanvas to add layers to an canvas but I have a problem with the sizes.
I have 2 rectangles a green one and a red one.
Now I want the red box touch the green left top corner.
Using the coordinate system I start green at coordinates 200, 200
then red has to start at 0,0 and the width and height has to be 200 and 200.
But that doesn't work
Check this example
Why doesnt this work??
When I use 100x100 dimensions it does work
All depends on the origin of your layer. By default it is the center of the layer.
So to have the results you expect there are two solutions (exemples with layer 100*100) :
First in your case you have to calculate correct position from top left canvas origin to the middle of your object :
$('canvas')
.addLayer({
type: 'rectangle',
name: 'redBox',
fillStyle: '#c33',
x: 50, y: 50,//canvas origin to center (100/2)
width: 100, height: 100
})
.addLayer({
type: 'rectangle',
name: 'greenBox',
fillStyle: '#585',
x: 150, y: 150,//canvas origin to center (100 of red layer + 100/2)
width: 100, height: 100
})
.drawLayers();
Or you can set origin to top left corner by disable fromCenter property:
$('canvas')
.addLayer({
type: 'rectangle',
name: 'redBox',
fillStyle: '#c33',
fromCenter: false,
x: 0, y: 0,
width: 100, height: 100
})
.addLayer({
type: 'rectangle',
name: 'greenBox',
fillStyle: '#585',
fromCenter: false,
x: 100, y: 100,
width: 100, height: 100
})
.drawLayers();
Hope this help
I'm just starting with fabric.js and I wonder if there is a way to create a canvas in such a way that I can work with cartesian coordinates? For example, I want a circle that I create at (0,0) to show up in the center of my canvas that reaches from -400 to 400 on the x-axis and -400 to 400 on the y.axis, with higher values of y going up and higher values of x going right.
Is there a way to do that without translating every position by hand?
You can use originX and originY attributes.
var obj = canvas.getObjects();
for (var i in obj) {
obj[i].set({
originX: 'left',
originY: 'top',
left: 0,
top: 0
});
}
canvas.renderAll();
Check this fiddle with examples: http://jsfiddle.net/1ow02gea/51/
You cannot change the origin of the canvas element without introducing visual artifacts. What you can do is pan the canvas to a virtual "0,0" position. Bear in mind that you will have to adjust both X_PAN_VALUE and Y_PAN_VALUE to your specific use case.
canvas.viewportTransform[4] = X_PAN_VALUE;
canvas.viewportTransform[5] = Y_PAN_VALUE;
Better late than never ;)