Рома Ахмадуллин
Рома Ахмадуллин
div {
width: 300px;
height: 150px;
}
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
<canvas
width="300"
height="150"
>
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
div {
width: 300px;
height: 150px;
}
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
canvas {
width: 300px;
height: 150px;
}
<canvas
width="600"
height="300"
>
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const width = 300;
const height = 150;
const scaleIndex = window.devicePixelRatio;
canvas.width = width * scaleIndex;
canvas.height = height * scaleIndex;
canvas.style.width = `${width}px`;
canvas.style.height = `${height}px`;
const setCanvasSize = () => {
const canvasWidth = window.innerWidth;
const canvasHeight = window.innerHeight;
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
window.addEventListener('resize', setCanvasSize);
const setCanvasSize = () => {
const canvasWidth = window.innerWidth;
const canvasHeight = window.innerHeight;
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
window.addEventListener('resize', setCanvasSize);
const setCanvasSize = () => {
const canvasWidth = window.innerWidth;
const canvasHeight = window.innerHeight;
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
window.addEventListener('resize', setCanvasSize);
const setCanvasSize = () => {
const canvasWidth = window.innerWidth;
const canvasHeight = window.innerHeight;
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
window.addEventListener('resize', setCanvasSize);
const setCanvasSize = () => {
const canvasWidth = getCanvasWidth();
const canvasHeight = getCanvasHeight();
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
const resizeObserver = new ResizeObserver(setCanvasSize);
resizeObserver.observe(canvasWrapper);
const setCanvasSize = () => {
const canvasWidth = getCanvasWidth();
const canvasHeight = getCanvasHeight();
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
const resizeObserver = new ResizeObserver(setCanvasSize);
resizeObserver.observe(canvasWrapper);
const setCanvasSize = () => {
const canvasWidth = getCanvasWidth();
const canvasHeight = getCanvasHeight();
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
const resizeObserver = new ResizeObserver(setCanvasSize);
resizeObserver.observe(canvasWrapper);
const setCanvasSize = () => {
const canvasWidth = getCanvasWidth();
const canvasHeight = getCanvasHeight();
canvas.width = canvasWidth * devicePixelRatio;
canvas.height = canvasHeight * devicePixelRatio;
canvas.style.setProperty('width', `${canvasWidth}px`);
canvas.style.setProperty('height', `${canvasHeight}px`);
};
const resizeObserver = new ResizeObserver(setCanvasSize);
resizeObserver.observe(canvasWrapper);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 60px sans-serif";
ctx2.fillText('Abc', 240, 180);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.font = "bold 60px sans-serif";
ctx2.fillText('Abc', 240, 180);
ctx1.scale(1, 1);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.scale(2, 2);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.scale(1, 1);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.scale(2, 2);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.scale(1, 1);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.scale(2, 2);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
ctx1.scale(1, 1);
ctx1.font = "bold 30px sans-serif";
ctx1.fillText('Abc', 120, 90);
ctx2.scale(2, 2);
ctx2.font = "bold 30px sans-serif";
ctx2.fillText('Abc', 120, 90);
const ctx = canvas.getContext('2d');
const scaleIndex = window.devicePixelRatio;
ctx.scale(scaleIndex, scaleIndex);
ctx.font = "bold 30px sans-serif";
ctx.fillText('my-text', 135, 90);
const ctx = canvas.getContext('2d');
const scaleIndex = window.devicePixelRatio;
ctx.scale(scaleIndex, scaleIndex);
ctx.font = "bold 30px sans-serif";
ctx.fillText('my-text', 135, 90);
const ctx = canvas.getContext('2d');
const scaleIndex = window.devicePixelRatio;
ctx.scale(scaleIndex, scaleIndex);
ctx.font = "bold 30px sans-serif";
ctx.fillText('my-text', 135, 90);
const ctx = canvas.getContext('2d');
const scaleIndex = window.devicePixelRatio;
ctx.scale(scaleIndex, scaleIndex);
ctx.font = "bold 30px sans-serif";
ctx.fillText('my-text', 135, 90);
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
const animate = () => {
// код с анимацией
ballPosition = ballPosition + 10;
};
const render = () => {
animate();
requestAnimationFrame(render);
};
render();
let lastTime = 0;
const animate = (timestamp) => {
if (!lastTime) lastTime = timestamp;
const delta = (timestamp - lastTime) / 1000;
lastTime = timestamp;
// код с анимацией
ballPosition = ballPosition + 10 * delta;
};
const render = (timestamp) => {
animate(timestamp);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
let lastTime = 0;
const animate = (timestamp) => {
if (!lastTime) lastTime = timestamp;
const delta = (timestamp - lastTime) / 1000;
lastTime = timestamp;
// код с анимацией
ballPosition = ballPosition + 10 * delta;
};
const render = (timestamp) => {
animate(timestamp);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
let lastTime = 0;
const animate = (timestamp) => {
if (!lastTime) lastTime = timestamp;
const delta = (timestamp - lastTime) / 1000;
lastTime = timestamp;
// код с анимацией
ballPosition = ballPosition + 10 * delta;
};
const render = (timestamp) => {
animate(timestamp);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
let lastTime = 0;
const animate = (timestamp) => {
if (!lastTime) lastTime = timestamp;
const delta = (timestamp - lastTime) / 1000;
lastTime = timestamp;
// код с анимацией
ballPosition = ballPosition + 10 * delta;
};
const render = (timestamp) => {
animate(timestamp);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
let lastTime = 0;
const animate = (timestamp) => {
if (!lastTime) lastTime = timestamp;
const delta = (timestamp - lastTime) / 1000;
lastTime = timestamp;
// код с анимацией
ballPosition = ballPosition + 10 * delta;
};
const render = (timestamp) => {
animate(timestamp);
requestAnimationFrame(render);
};
requestAnimationFrame(render);
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const getColorFromMouseEvent = (event) => {
const bounding = canvas.getBoundingClientRect();
const x = (event.clientX - bounding.left) * devicePixelRatio;
const y = (event.clientY - bounding.top) * devicePixelRatio;
const pixel = ctx.getImageData(x, y, 1, 1);
const data = pixel.data;
return `rgb(${data[0]} ${data[1]} ${data[2]})`;
};
const getColorFromMouseEvent = (event) => {
const bounding = canvas.getBoundingClientRect();
const x = (event.clientX - bounding.left) * devicePixelRatio;
const y = (event.clientY - bounding.top) * devicePixelRatio;
const pixel = ctx.getImageData(x, y, 1, 1);
const data = pixel.data;
return `rgb(${data[0]} ${data[1]} ${data[2]})`;
};
const getColorFromMouseEvent = (event) => {
const bounding = canvas.getBoundingClientRect();
const x = (event.clientX - bounding.left) * devicePixelRatio;
const y = (event.clientY - bounding.top) * devicePixelRatio;
const pixel = ctx.getImageData(x, y, 1, 1);
const data = pixel.data;
return `rgb(${data[0]} ${data[1]} ${data[2]})`;
};
const getColorFromMouseEvent = (event) => {
const bounding = canvas.getBoundingClientRect();
const x = (event.clientX - bounding.left) * devicePixelRatio;
const y = (event.clientY - bounding.top) * devicePixelRatio;
const pixel = ctx.getImageData(x, y, 1, 1);
const data = pixel.data;
return `rgb(${data[0]} ${data[1]} ${data[2]})`;
};
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.src = imageUrl;
const imageUrl = 'https://pictures.com/1';
const canvas = document.getElementById('canvas');
const ctx = canvas.getContext('2d');
const img = new Image();
img.addEventListener('load', () => {
ctx.drawImage(img, 0, 0);
});
img.crossOrigin = 'anonymous';
img.src = imageUrl;
const scaleIndex = window.devicePixelRatio;
setCanvasSize(scaleIndex);
scaleCanvas(scaleIndex);
const setCanvasSize = () => {...};
// так
window.addEventListener('resize', setCanvasSize);
// или так
const resizeObserver = new ResizeObserver(setCanvasSize);
resizeObserver.observe(canvasWrapper);
const delta = (timestamp - lastTime) / 1000;
elementPosition = elementPosition + 10 * delta;
// на одной стороне
element.crossorigin = 'anonymous'
// на второй
Access-Control-Allow-Origin: 'domain'
Дром