Making canvas visible out of canvas











up vote
0
down vote

favorite












Is it possible to render canvas element out of own area?



In this example I draw a rectangle, which x-coordinate and y-coordinate is a negative value. Is it possible to render whole rectangle? overflow rule doesn't work here.



jsfiddle



html



<div class="container">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col main">
<canvas id="example" width="150" height="150"></canvas>
</div>
</div>
</div>


javascript



var canvas = document.getElementById("example");
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.rect(-30, -30, 150, 100);
ctx.fillStyle = "red";
ctx.fill();


css



.row {
background: CornflowerBlue;
margin-top: 20px;
}

.col {
padding: 0 !important;
border: solid 1px #6c757d;
padding: 10px;
}

.main, canvas {
overflow: visible;
}









share|improve this question






















  • This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
    – DBS
    Nov 9 at 15:32












  • Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
    – enxaneta
    Nov 9 at 16:53















up vote
0
down vote

favorite












Is it possible to render canvas element out of own area?



In this example I draw a rectangle, which x-coordinate and y-coordinate is a negative value. Is it possible to render whole rectangle? overflow rule doesn't work here.



jsfiddle



html



<div class="container">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col main">
<canvas id="example" width="150" height="150"></canvas>
</div>
</div>
</div>


javascript



var canvas = document.getElementById("example");
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.rect(-30, -30, 150, 100);
ctx.fillStyle = "red";
ctx.fill();


css



.row {
background: CornflowerBlue;
margin-top: 20px;
}

.col {
padding: 0 !important;
border: solid 1px #6c757d;
padding: 10px;
}

.main, canvas {
overflow: visible;
}









share|improve this question






















  • This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
    – DBS
    Nov 9 at 15:32












  • Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
    – enxaneta
    Nov 9 at 16:53













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Is it possible to render canvas element out of own area?



In this example I draw a rectangle, which x-coordinate and y-coordinate is a negative value. Is it possible to render whole rectangle? overflow rule doesn't work here.



jsfiddle



html



<div class="container">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col main">
<canvas id="example" width="150" height="150"></canvas>
</div>
</div>
</div>


javascript



var canvas = document.getElementById("example");
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.rect(-30, -30, 150, 100);
ctx.fillStyle = "red";
ctx.fill();


css



.row {
background: CornflowerBlue;
margin-top: 20px;
}

.col {
padding: 0 !important;
border: solid 1px #6c757d;
padding: 10px;
}

.main, canvas {
overflow: visible;
}









share|improve this question













Is it possible to render canvas element out of own area?



In this example I draw a rectangle, which x-coordinate and y-coordinate is a negative value. Is it possible to render whole rectangle? overflow rule doesn't work here.



jsfiddle



html



<div class="container">
<div class="row">
<div class="col">
1 of 2
</div>
<div class="col main">
<canvas id="example" width="150" height="150"></canvas>
</div>
</div>
</div>


javascript



var canvas = document.getElementById("example");
var ctx = canvas.getContext('2d');
ctx.beginPath();
ctx.rect(-30, -30, 150, 100);
ctx.fillStyle = "red";
ctx.fill();


css



.row {
background: CornflowerBlue;
margin-top: 20px;
}

.col {
padding: 0 !important;
border: solid 1px #6c757d;
padding: 10px;
}

.main, canvas {
overflow: visible;
}






html css css3 html5-canvas






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 9 at 15:28









Matt

9511352113




9511352113












  • This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
    – DBS
    Nov 9 at 15:32












  • Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
    – enxaneta
    Nov 9 at 16:53


















  • This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
    – DBS
    Nov 9 at 15:32












  • Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
    – enxaneta
    Nov 9 at 16:53
















This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
– DBS
Nov 9 at 15:32






This is not possible. Think of a canvas an interactive image, it's just one element with it's set boundaries, everything inside it is a part of it (rather than a contained element that may be able to break the boundaries) However using a larger canvas and faking the "edge" of the canvas is a possible workaround.
– DBS
Nov 9 at 15:32














Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
– enxaneta
Nov 9 at 16:53




Maybe you should explain why do you need it for. Depending on the situation there may be some workarounds.
– enxaneta
Nov 9 at 16:53

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














 

draft saved


draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228647%2fmaking-canvas-visible-out-of-canvas%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















 

draft saved


draft discarded



















































 


draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53228647%2fmaking-canvas-visible-out-of-canvas%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Schultheiß

Liste der Kulturdenkmale in Wilsdruff

Android Play Services Check