Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optional Arduino/digital electronics simulator for Ardublockly. #249

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
7cdf015
Add files via upload
boylesg Feb 7, 2022
4ea4d22
Create dummy.txt
boylesg Feb 7, 2022
220a18a
Add files via upload
boylesg Feb 7, 2022
7250ad4
Delete dummy.txt
boylesg Feb 7, 2022
496e86e
Delete ardublockly/img/Components/Active directory
boylesg Feb 7, 2022
368c0ee
Create temp.txt
boylesg Feb 15, 2022
6fdbbb7
Add files via upload
boylesg Feb 15, 2022
e049197
Delete temp.txt
boylesg Feb 15, 2022
acf7669
Create temp.txt
boylesg Feb 15, 2022
9015834
Add files via upload
boylesg Feb 15, 2022
95deb7a
Delete LED_BLOWN.png
boylesg Feb 15, 2022
40b2017
Delete LED_BLOWN180.png
boylesg Feb 15, 2022
7ed75d8
Delete LED_BLOWN270.png
boylesg Feb 15, 2022
ea7b4d1
Delete LED_BLOWN90.png
boylesg Feb 15, 2022
64deb25
Delete LED_OFF.png
boylesg Feb 15, 2022
c0a2839
Delete LED_OFF180.png
boylesg Feb 15, 2022
8b88c54
Delete LED_OFF270.png
boylesg Feb 15, 2022
d840772
Delete LED_OFF90.png
boylesg Feb 15, 2022
2b93d67
Delete LED_ON.png
boylesg Feb 15, 2022
699b034
Delete LED_ON180.png
boylesg Feb 15, 2022
6c62452
Delete LED_ON270.png
boylesg Feb 15, 2022
13b68c2
Delete LED_ON90.png
boylesg Feb 15, 2022
344669b
Create temp.txt
boylesg Feb 15, 2022
de77b05
Add files via upload
boylesg Feb 15, 2022
38dea52
Delete temp.txt
boylesg Feb 15, 2022
c902f4e
Delete temp.txt
boylesg Feb 15, 2022
508298a
Create temp.txt
boylesg Feb 15, 2022
c163ae9
Add files via upload
boylesg Feb 15, 2022
676720a
Delete temp.txt
boylesg Feb 15, 2022
e8d7705
Add files via upload
boylesg Feb 15, 2022
b56c2a9
Add files via upload
boylesg Feb 15, 2022
f078c06
Add files via upload
boylesg Feb 15, 2022
283b529
Add files via upload
boylesg Feb 15, 2022
80140a4
Add files via upload
boylesg Feb 15, 2022
b08c70c
Add files via upload
boylesg Feb 16, 2022
edcc409
Add files via upload
boylesg Feb 16, 2022
cde02f3
Add files via upload
boylesg Feb 16, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
98 changes: 98 additions & 0 deletions ardublockly/CanvasDataStructures.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
//*************************************************************************
//*
//* GLOBAL VARIBALES FOR COMPONENTS
//*
//*************************************************************************

var g_arrayGrid = [];
var g_Canvas = document.getElementById("canvas"), g_BlankCanvasClone = document.createElement('canvas');
var g_CanvasContext = null, g_BlankCanvasCloneContext = null;
var g_DrawSpace = document.getElementById("draw_space");
var g_pointCanvasScrollPos = new CPoint(0, 0);
var g_nGridSize = 10;

if (g_Canvas != null)
{
g_CanvasContext = g_Canvas.getContext("2d");
if (g_CanvasContext == null)
alert("Could not get canvas context object for 'canvas'!");
}
else
alert("Could not get canvas object for 'canvas'!");

if (g_BlankCanvasClone != null)
{
g_BlankCanvasClone.width = g_Canvas.width;
g_BlankCanvasClone.height = g_Canvas.height;
g_BlankCanvasCloneContext = g_BlankCanvasClone.getContext("2d");
if (g_BlankCanvasCloneContext == null)
alert("Could not get canvas context object for 'clone canvas'!");
}
else
alert("Could not get canvas object for 'canvas'!");

if (g_DrawSpace == null)
alert("Could not get div object for 'draw_space'!");




//*************************************************************************
//*
//* SCROLL TO MIDDLE OF CANVAS ON START UP
//*
//*************************************************************************

function doScrollToMiddle()
{
if (g_DrawSpace)
{
g_DrawSpace.scrollTop = g_Canvas.height / 2;
g_pointCanvasScrollPos = new CPoint(0, g_Canvas.height / 2);
}
}





//*************************************************************************
//*
//* ERASE THE CANVAS AND CREATE THE GRID
//*
//*************************************************************************

function doCreateGrid()
{
var nX = 0, nY = 0;

if (g_Canvas != null)
{
for (nY = 0; nY < g_Canvas.offsetHeight; nY += g_nGridSize)
{
for (nX = 0; nX < g_Canvas.offsetWidth; nX += g_nGridSize)
g_arrayGrid.push(new CPoint(nX, nY));
}
}
}

function doDrawCanvasGrid(Context, nWidth, nHeight)
{
if (g_arrayGrid.length == 0)
doCreateGrid()
if (Context != null)
{
Context.clearRect(0, 0, nWidth, nHeight);
Context.fillStyle = "#000000";
Context.beginPath();
for (let nI = 0; nI < g_arrayGrid.length; nI++)
Context.fillRect(g_arrayGrid[nI].m_nX, g_arrayGrid[nI].m_nY, 1, 1);
}
}

function doEraseCanvas()
{
g_CanvasContext.clearRect(0, 0, g_Canvas.offsetWidth, g_Canvas.offsetHeight);
g_CanvasContext.drawImage(g_BlankCanvasClone, 0, 0);
}

Loading