Skip to content

Commit

Permalink
Merge branch 'rslashplace2:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Outfit8TSB authored Dec 29, 2024
2 parents ef049a2 + 424668b commit 07653f1
Show file tree
Hide file tree
Showing 57 changed files with 4,522 additions and 3,368 deletions.
18 changes: 16 additions & 2 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,19 @@
<link rel="apple-touch-icon" href="favicon.png">
<link rel="icon" type="image/x-icon" href="favicon.png">
<link rel="stylesheet" href="shared.css?v=1">
<script type="application/javascript" src="shared.js?v=2"></script>
<script type="application/javascript" src="shared.js?v=8"></script>
<title>custom canvas</title>
<script>
const REDIRECTS = {
"/discord": "https://discord.com/invite/xbRrVSXJdZ",
"/twitter": "https://x.com/rplacetk",
"/x": "https://x.com/rplacetk",
"/reddit": "https://www.reddit.com/r/placetk",
"/github": "https://github.com/rplacetk",
"/telegram": "https://t.me/rplacelive",
"/admin": "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
};

async function getVanityInstance(name) {
try {
const response = await fetch(`${localStorage.auth || DEFAULT_AUTH}/instances/vanity/${name}`)
Expand All @@ -23,7 +33,11 @@

let vanityRequestFinished = false
;(async function() {
const urlName = window.location.pathname.replaceAll("/", "")
const urlName = window.location.pathname.replaceAll("/", "");
if (REDIRECTS[window.location.pathname]) {
window.location.replace(REDIRECTS[window.location.pathname]);
return;
}
const info = await getVanityInstance(urlName)
if (info !== null) {
const protocol = info.usesHttps ? "https://" : "http://"
Expand Down
2 changes: 1 addition & 1 deletion MANUAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ Setting up a custom server that users can connect to via the posts menu is very

10. If you encountered no errors, Bon Voilà, you have set up an rplace custom server acessable from in the game.

11. If you did encounter errors, no worries, visit the rplace discord, acessable through out site `https://rplace.tk` and ask one of the admins (our usernames are usually `@BlobKat`/`@zekiahepic`), and we will try our best to assist you!
11. If you did encounter errors, no worries, visit the rplace discord, acessable through out site `https://rplace.live` and ask one of the admins (our usernames are usually `@BlobKat`/`@zekiahepic`), and we will try our best to assist you!
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ This site aims to be as similar to the april fools r/place event, where users we
*Feel free to contribute!*

# Setting up my own custom canvas!
To set up your own custom canvas to be played on rplace.tk, we have made a guide at our [Manual](MANUAL.md)!
To set up your own custom canvas to be played on rplace.live, we have made a guide at our [Manual](MANUAL.md)!


# Development
Expand Down
1 change: 1 addition & 0 deletions ads.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
google.com, pub-2508999262953411, DIRECT, f08c47fec0942fa0
10 changes: 5 additions & 5 deletions august21-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ const eventDate = 1724238000000
//popup.showModal()

setInterval(() => {
august21PopupTimer.textContent = ` (${toCountdownString(eventDate)})`
august21PopupTimer.textContent = ` (${toCountdownString(eventDate)})`
}, 1000)

startCountDown(eventDate, false).then((async) => {
august21PopupTimer.style.display = "none"
// TODO: Reimplement on game release
august21PopupLabel.style.display = "none"
august21PopupButton.style.display = "flex"
august21PopupTimer.style.display = "none"
// TODO: Reimplement on game release
august21PopupLabel.style.display = "none"
august21PopupButton.style.display = "flex"
})
Binary file modified bun.lockb
Binary file not shown.
258 changes: 129 additions & 129 deletions captcha-canvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,151 +2,151 @@
let captchaCanvasHandle = null

function updateImgCaptchaCanvas(imageData) {
const ctx = setTargetCanvas(captchaCanvas)
const patternImg = Texture().fromSrc("./images/pattern.png", _, REPEAT | MIPMAPS | UPSCALE_PIXELATED)
const img = Texture()
img.from(imageData, _, MIPMAPS)
const ctx = setTargetCanvas(captchaCanvas)
const patternImg = Texture().fromSrc("./images/pattern.png", _, REPEAT | MIPMAPS | UPSCALE_PIXELATED)
const img = Texture()
img.from(imageData, _, MIPMAPS)

const cornerShader = Shader(`
void main()
{
float u_radius = 0.02;
vec3 u_colour = u.rgb;
float u_edgeFeather = 0.002;
vec2 rectSize = vec2(0.9, 0.9);
const cornerShader = Shader(`
void main()
{
float u_radius = 0.02;
vec3 u_colour = u.rgb;
float u_edgeFeather = 0.002;
vec2 rectSize = vec2(0.9, 0.9);
vec2 fragCoordNorm = abs(uv.xy - 0.5);
float distance = length(max(fragCoordNorm - rectSize * 0.5 + u_radius, 0.0)) - u_radius;
float alpha = 1.0 - smoothstep(u_radius - u_edgeFeather, u_radius + u_edgeFeather, distance) *
smoothstep(0.0 - u_edgeFeather, 0.0 + u_edgeFeather, length(fragCoordNorm - 0.5 * rectSize));
vec2 fragCoordNorm = abs(uv.xy - 0.5);
float distance = length(max(fragCoordNorm - rectSize * 0.5 + u_radius, 0.0)) - u_radius;
float alpha = 1.0 - smoothstep(u_radius - u_edgeFeather, u_radius + u_edgeFeather, distance) *
smoothstep(0.0 - u_edgeFeather, 0.0 + u_edgeFeather, length(fragCoordNorm - 0.5 * rectSize));
color = vec4(u_colour * alpha, alpha);
}
`)
const cornerTextureShader = Shader(`
void main()
{
float u_radius = 0.02;
vec3 u_colour = texture(tex0, uv.xy).rgb;
float u_edgeFeather = 0.002;
vec2 rectSize = vec2(0.9, 0.9);
color = vec4(u_colour * alpha, alpha);
}
`)
const cornerTextureShader = Shader(`
void main()
{
float u_radius = 0.02;
vec3 u_colour = texture(tex0, uv.xy).rgb;
float u_edgeFeather = 0.002;
vec2 rectSize = vec2(0.9, 0.9);
vec2 fragCoordNorm = abs(uv.xy - 0.5);
float distance = length(max(fragCoordNorm - rectSize * 0.5 + u_radius, 0.0)) - u_radius;
float alpha = 1.0 - smoothstep(u_radius - u_edgeFeather, u_radius + u_edgeFeather, distance) *
smoothstep(0.0 - u_edgeFeather, 0.0 + u_edgeFeather, length(fragCoordNorm - 0.5 * rectSize));
vec2 fragCoordNorm = abs(uv.xy - 0.5);
float distance = length(max(fragCoordNorm - rectSize * 0.5 + u_radius, 0.0)) - u_radius;
float alpha = 1.0 - smoothstep(u_radius - u_edgeFeather, u_radius + u_edgeFeather, distance) *
smoothstep(0.0 - u_edgeFeather, 0.0 + u_edgeFeather, length(fragCoordNorm - 0.5 * rectSize));
color = vec4(u_colour * alpha, alpha);
}
`)
function cubicBezier(t, initial, p1, p2, final) {
return ((1 - t) * (1 - t) * (1 - t) * initial
+ 3 * (1 - t) * (1 - t) * t * p1
+ 3 * (1 - t) * t * t * p2
+ t * t * t * final)
}
function ease(start, end, weight) {
return start + (end - start) * cubicBezier(weight, 0, 1.1, 0.2, 1);
}
function drawCaptcha() {
if (captchaCanvasHandle === null) {
return
}
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const now = performance.now()
const hRatio = captchaCanvas.width / captchaCanvas.height
color = vec4(u_colour * alpha, alpha);
}
`)
function cubicBezier(t, initial, p1, p2, final) {
return ((1 - t) * (1 - t) * (1 - t) * initial
+ 3 * (1 - t) * (1 - t) * t * p1
+ 3 * (1 - t) * t * t * p2
+ t * t * t * final)
}
function ease(start, end, weight) {
return start + (end - start) * cubicBezier(weight, 0, 1.1, 0.2, 1);
}
function drawCaptcha() {
if (captchaCanvasHandle === null) {
return
}
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const now = performance.now()
const hRatio = captchaCanvas.width / captchaCanvas.height

const patternTexSize = 64
const scaleX = patternTexSize / captchaCanvas.width
const scaleY = patternTexSize / captchaCanvas.height
const patternRepeatsX = 12
const patternRepeatsY = 16
const patternTexSize = 64
const scaleX = patternTexSize / captchaCanvas.width
const scaleY = patternTexSize / captchaCanvas.height
const patternRepeatsX = 12
const patternRepeatsY = 16

const weight = (now / 2200) % 1
const shift = ease(0, patternTexSize, weight)
const patternMesh = Mesh()
patternMesh.translate(shift / captchaCanvas.width - scaleX, -shift / captchaCanvas.height)
patternMesh.addRect(0, 0, scaleX * patternRepeatsX, scaleY * patternRepeatsY,
uv(0, 0, patternRepeatsX, patternRepeatsY), _, 1, 1, 1, 0.96)
ctx.draw(patternMesh, patternImg)
const weight = (now / 2200) % 1
const shift = ease(0, patternTexSize, weight)
const patternMesh = Mesh()
patternMesh.translate(shift / captchaCanvas.width - scaleX, -shift / captchaCanvas.height)
patternMesh.addRect(0, 0, scaleX * patternRepeatsX, scaleY * patternRepeatsY,
uv(0, 0, patternRepeatsX, patternRepeatsY), _, 1, 1, 1, 0.96)
ctx.draw(patternMesh, patternImg)

const imgSize = 210
const imgWidth = imgSize / captchaCanvas.width
const imgHeight = imgWidth * hRatio
const imageX = 0.5 - imgWidth * 0.5
const imgBotttom = captchaImagePositon.offsetTop + captchaImagePositon.offsetHeight
const imageY = (captchaCanvas.height - imgBotttom) / captchaCanvas.height
const imgSize = 210
const imgWidth = imgSize / captchaCanvas.width
const imgHeight = imgWidth * hRatio
const imageX = 0.5 - imgWidth * 0.5
const imgBotttom = captchaImagePositon.offsetTop + captchaImagePositon.offsetHeight
const imageY = (captchaCanvas.height - imgBotttom) / captchaCanvas.height

let prevShader = ctx.useShader(cornerShader)
ctx.setU(0.6, 0.6, 0.6, 1.0)
const borderSize = 1
const borderWidth = borderSize / captchaCanvas.width
const bx = imageX - borderWidth
const by = imageY - (borderWidth * hRatio)
const bw = imgWidth + (borderWidth * 2)
const bh = imgHeight + (borderWidth * hRatio * 2)
const borderMesh = Mesh.singleRect(bx, by, bw, bh)
ctx.draw(borderMesh)
ctx.useShader(prevShader)
let prevShader = ctx.useShader(cornerShader)
ctx.setU(0.6, 0.6, 0.6, 1.0)
const borderSize = 1
const borderWidth = borderSize / captchaCanvas.width
const bx = imageX - borderWidth
const by = imageY - (borderWidth * hRatio)
const bw = imgWidth + (borderWidth * 2)
const bh = imgHeight + (borderWidth * hRatio * 2)
const borderMesh = Mesh.singleRect(bx, by, bw, bh)
ctx.draw(borderMesh)
ctx.useShader(prevShader)

prevShader = ctx.useShader(cornerTextureShader)
const imgMesh = Mesh.singleRect(imageX, imageY, imgWidth, imgHeight)
ctx.draw(imgMesh, img)
ctx.useShader(prevShader)
prevShader = ctx.useShader(cornerTextureShader)
const imgMesh = Mesh.singleRect(imageX, imageY, imgWidth, imgHeight)
ctx.draw(imgMesh, img)
ctx.useShader(prevShader)

captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}

function updateImgCaptchaCanvasFallback(imageData) {
const ctx = captchaCanvas.getContext("2d")
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const captchaImg = new Image()
const url = URL.createObjectURL(imageData)
captchaImg.src = url
const captchaImgRadius = 8
const ctx = captchaCanvas.getContext("2d")
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const captchaImg = new Image()
const url = URL.createObjectURL(imageData)
captchaImg.src = url
const captchaImgRadius = 8

captchaImg.onload = function() {
function drawCaptcha() {
if (captchaCanvasHandle === null) {
return
}
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const canvasImageSize = 196
const x = captchaImagePositon.offsetLeft
const y = captchaImagePositon.offsetTop
ctx.clearRect(0, 0, captchaCanvas.width, captchaCanvas.height)
ctx.save()
ctx.beginPath()
ctx.moveTo(x + captchaImgRadius, y)
ctx.arcTo(x + canvasImageSize, y, x + canvasImageSize, y + canvasImageSize, captchaImgRadius)
ctx.arcTo(x + canvasImageSize, y + canvasImageSize, x, y + canvasImageSize, captchaImgRadius)
ctx.arcTo(x, y + canvasImageSize, x, y, captchaImgRadius)
ctx.arcTo(x, y, x + canvasImageSize, y, captchaImgRadius)
ctx.closePath()
ctx.clip()
ctx.drawImage(captchaImg, x, y, canvasImageSize, canvasImageSize)
ctx.restore()
const captchaImageBottom = captchaImagePositon.offsetTop + canvasImageSize
const captchaImageCentreX = captchaCanvas.width / 2
ctx.fillStyle = "#ff0000a3"
ctx.font = "16px reddit"
ctx.textAlign = "center"
ctx.fillText("Warning: Your browser doesn't support WebGL 2,",
captchaImageCentreX, captchaImageBottom + 16)
ctx.fillText("this can cause some site features to break!",
captchaImageCentreX, captchaImageBottom + 52)
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
captchaImg.onload = function() {
function drawCaptcha() {
if (captchaCanvasHandle === null) {
return
}
captchaCanvas.width = captchaPopup.offsetWidth
captchaCanvas.height = captchaPopup.offsetHeight
const canvasImageSize = 196
const x = captchaImagePositon.offsetLeft
const y = captchaImagePositon.offsetTop
ctx.clearRect(0, 0, captchaCanvas.width, captchaCanvas.height)
ctx.save()
ctx.beginPath()
ctx.moveTo(x + captchaImgRadius, y)
ctx.arcTo(x + canvasImageSize, y, x + canvasImageSize, y + canvasImageSize, captchaImgRadius)
ctx.arcTo(x + canvasImageSize, y + canvasImageSize, x, y + canvasImageSize, captchaImgRadius)
ctx.arcTo(x, y + canvasImageSize, x, y, captchaImgRadius)
ctx.arcTo(x, y, x + canvasImageSize, y, captchaImgRadius)
ctx.closePath()
ctx.clip()
ctx.drawImage(captchaImg, x, y, canvasImageSize, canvasImageSize)
ctx.restore()
const captchaImageBottom = captchaImagePositon.offsetTop + canvasImageSize
const captchaImageCentreX = captchaCanvas.width / 2
ctx.fillStyle = "#ff0000a3"
ctx.font = "16px reddit"
ctx.textAlign = "center"
ctx.fillText("Warning: Your browser doesn't support WebGL 2,",
captchaImageCentreX, captchaImageBottom + 16)
ctx.fillText("this can cause some site features to break!",
captchaImageCentreX, captchaImageBottom + 52)
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
captchaCanvasHandle = requestAnimationFrame(drawCaptcha)
}
}

function clearCaptchaCanvas() {
window.cancelAnimationFrame(captchaCanvasHandle)
captchaCanvasHandle = null
window.cancelAnimationFrame(captchaCanvasHandle)
captchaCanvasHandle = null
}
5 changes: 2 additions & 3 deletions censors.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# game imaginable, but should help to catch the majority of cases where a user is not intentionally
# attempting to circumvent the system.

# General symbols / nuisances / controversial topics
# General symbols / nuisances / websites / controversial topics
𓂸
Expand All @@ -22,7 +22,6 @@ kiwifarms
soyjak\.?party
4chan


# English
[a4]n[a4]l
[a4]rse
Expand Down Expand Up @@ -103,4 +102,4 @@ vittu

# Chinese
傻逼
傻逼
Loading

0 comments on commit 07653f1

Please sign in to comment.