mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 19:16:41 +07:00
render: image rendering
This commit is contained in:
parent
fb087c67ac
commit
af2107984a
1 changed files with 8 additions and 1 deletions
|
@ -15,10 +15,14 @@ export class Renderer extends React.Component {
|
||||||
this.fetchImages(ctx, geometry)
|
this.fetchImages(ctx, geometry)
|
||||||
.then(images => this.composeImages({ geometry, images, ctx }))
|
.then(images => this.composeImages({ geometry, images, ctx }))
|
||||||
.then(() => this.composePoly({ geometry, points, ctx }))
|
.then(() => this.composePoly({ geometry, points, ctx }))
|
||||||
|
.then(() => this.canvas.toDataURL('image/jpeg'))
|
||||||
|
.then(image => window.open().document.write(`<img src="${image}" />`))
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchImages = (ctx, geometry) => {
|
fetchImages = (ctx, geometry) => {
|
||||||
const { minX, maxX, minY, maxY, zoom } = geometry;
|
const {
|
||||||
|
minX, maxX, minY, maxY, zoom
|
||||||
|
} = geometry;
|
||||||
|
|
||||||
const images = [];
|
const images = [];
|
||||||
for (let x = minX; x <= maxX; x += 1) {
|
for (let x = minX; x <= maxX; x += 1) {
|
||||||
|
@ -34,6 +38,7 @@ export class Renderer extends React.Component {
|
||||||
|
|
||||||
imageFetcher = source => new Promise((resolve, reject) => {
|
imageFetcher = source => new Promise((resolve, reject) => {
|
||||||
const img = new Image();
|
const img = new Image();
|
||||||
|
img.crossOrigin = 'anonymous';
|
||||||
img.onload = () => resolve(img);
|
img.onload = () => resolve(img);
|
||||||
img.onerror = () => reject(img);
|
img.onerror = () => reject(img);
|
||||||
|
|
||||||
|
@ -88,6 +93,8 @@ export class Renderer extends React.Component {
|
||||||
ctx.strokeStyle = gradient;
|
ctx.strokeStyle = gradient;
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.closePath();
|
ctx.closePath();
|
||||||
|
|
||||||
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue