Posts

Showing posts with the label canvas

(check if) Mouse in cycle? (coordinate Js canvas)

(check if) Mouse in cycle? (coordinate Js canvas) So, I want to check, if the mouse is (clicked) inside of a ring. Here it (the ring) is : <canvas id="textur" width="1584" height="750"></canvas> <script> var textur = document.getElementById('textur'); var canvas = textur.getContext('2d');//Dimension zähler = 0; diff = ((1)*Math.PI*2*10).toFixed(2) canvas.lineWidth = 95 ; canvas.fillStyle = '#09F' canvas.strokeStyle = '#09F' canvas.textAlign = 'center' canvas.beginPath(); canvas.arc(150, 100, 5, 4.72, diff / 10 + 4.72, false) canvas.stroke(); </script> So, I know how to do it with a rectangle,but with a ring... I´m happy about every (useful) answer! Possible duplicate of Detect if user clicks inside a circle – AndroidNoobie Jul 1 at 9:08 ...

How to superimpose a canvas on an HTML5 video using object-fit cover?

How to superimpose a canvas on an HTML5 video using object-fit cover? I am refactoring this code: https://github.com/idevelop/predator-vision to superimpose heatmap on a video (with any resolution and aspect-ratio). I have the following html code: <div id="videos" class="embed-responsive"> <canvas id="heatmap" class="embed-responsive-item"></canvas> <video id="remote-video" autoplay muted playsinline class="embed-responsive-item"></video> </div> CSS: #remote-video { display: block; height: 100%; max-height: 100%; max-width: 100%; position: absolute; top: 0; left: 0; object-fit: cover; /* no letterboxing */ opacity: 1; -moz-transform: rotateY(180deg); -ms-transform: rotateY(180deg); -o-transform: rotateY(180deg); -webkit-transform: rotateY(180deg); transform: rotateY(180deg); transition: opacity 1s; width: 100%; } #re...

Render a red square on Matter.js

Render a red square on Matter.js I am having trouble displaying a red square on the Matter.js physics engine. I sure that I referenced the necessary variables, but I can't seem to display anything else other than the minimal example of Matter.js. What did I do wrong? <html> <script src='matter.min.js'> </script> <canvas> </canvas> <script> var banvas = document.querySelector('canvas'), context = banvas.getContext('2d'); var Engine = Matter.Engine, Render = Matter.Render, World = Matter.World, Bodies = Matter.Bodies; // create an engine var engine = Engine.create(); // create a renderer var render = Render.create({ canvas: banvas, engine: engine }); // create two boxes and a ground var boxA = Bodies.rectangle(400, 200, 80, 80); var boxB = Bodies.rectangle(450, 50, 80, 80); var ground = Bodies.rectangle(400, 610, 810, 60, { isStatic: true }); context.fillStyle='red'; context.fillRect(0,0,40,40...

Zoom is not working for a drawn circle

Zoom is not working for a drawn circle I have implemented TouchImageView class from the following github repository in my code. https://github.com/MikeOrtiz/TouchImageView/blob/master/src/com/ortiz/touch/TouchImageView.java in the above TouchImageView class in onDraw method i have implemented following code to draw circle dotPaint.setColor(ContextCompat.getColor(getContext(), R.color.map_site_dot)); Point point = site.getPoint(); canvas.drawCircle((float) point.getX(), (float) point.getY(), ViewUtils.dpToPx(DOT_DEFAULT_RADIUS), dotPaint); but circle is not displaying. If i have used dispatchDraw override method to draw circle it draw over the image. then zoom not getting applied for drawned circle, only its working for the below image. Could you please help me in this. By clicking "Post Your Answer", you acknowled...