Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
harmonograph
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aapeli
harmonograph
Commits
de346dd6
Commit
de346dd6
authored
Jun 11, 2016
by
Aapeli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Drew board and colours, set it up
parent
8a48e6d9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
88 additions
and
0 deletions
+88
-0
harmonograph/board.pde
harmonograph/board.pde
+34
-0
harmonograph/color.pde
harmonograph/color.pde
+27
-0
harmonograph/harmonograph.pde
harmonograph/harmonograph.pde
+27
-0
No files found.
harmonograph/board.pde
0 → 100644
View file @
de346dd6
class
Board
{
// probably bad form to name somethign "colour" if there already is a "color"
Colour
[][]
bPixels
;
int
bWidth
,
bHeight
;
Board
(
int
w
,
int
h
,
Colour
bg
)
{
bWidth
=
w
;
bHeight
=
h
;
bPixels
=
new
Colour
[
w
][
h
];
for
(
int
y
=
0
;
y
<
bHeight
;
y
++
)
{
for
(
int
x
=
0
;
x
<
bWidth
;
x
++
)
{
if
(
x
==
50
&&
y
==
50
)
{
println
(
"created 50 50"
);
println
(
bPixels
[
x
][
y
]);
}
bPixels
[
x
][
y
]
=
new
Colour
(
bg
);
if
(
x
==
50
&&
y
==
50
)
{
println
(
bPixels
[
x
][
y
]);
}
}
}
}
Colour
getPixel
(
int
x
,
int
y
)
{
return
bPixels
[
x
][
y
];
}
void
Draw
()
{
for
(
int
y
=
0
;
y
<
bHeight
;
y
++
)
{
for
(
int
x
=
0
;
x
<
bWidth
;
x
++
)
{
set
(
x
,
y
,
bPixels
[
x
][
y
].
getColor
());
}
}
}
}
\ No newline at end of file
harmonograph/color.pde
0 → 100644
View file @
de346dd6
class
Colour
{
float
r
,
g
,
b
,
a
;
Colour
(
float
rS
,
float
gS
,
float
bS
,
float
aS
)
{
r
=
rS
;
g
=
gS
;
b
=
bS
;
a
=
aS
;
}
Colour
()
{
r
=
0
;
g
=
0
;
b
=
0
;
a
=
0
;
}
Colour
(
Colour
c
)
{
r
=
c
.
r
;
g
=
c
.
g
;
b
=
c
.
b
;
a
=
c
.
a
;
}
void
darken
(
float
rS
,
float
gS
,
float
bS
,
float
aS
)
{
r
+=
rS
;
g
+=
gS
;
b
+=
bS
;
a
+=
aS
;
}
void
lighten
(
float
rS
,
float
gS
,
float
bS
,
float
aS
)
{
r
-=
rS
;
g
-=
gS
;
b
-=
bS
;
a
-=
aS
;
}
void
darken
(
Colour
c
)
{
r
+=
c
.
r
;
g
+=
c
.
g
;
b
+=
c
.
b
;
a
+=
c
.
a
;
}
Colour
multiply
(
float
p
)
{
return
new
Colour
(
r
*
p
,
g
*
p
,
b
*
p
,
a
);
}
color
getColor
()
{
return
color
(
round
(
r
*
255
),
round
(
g
*
255
),
round
(
b
*
255
),
round
(
a
*
255
));
}
}
\ No newline at end of file
harmonograph/harmonograph.pde
0 → 100644
View file @
de346dd6
float
penX
,
penY
;
Board
board
;
Colour
penColour
;
void
setup
()
{
size
(
800
,
500
);
board
=
new
Board
(
width
,
height
,
new
Colour
(
0
,
0
,
0
,
1
));
penColour
=
new
Colour
(
0
,
0
,
1
,
1
);
noSmooth
();
penX
=
50
;
penY
=
50
;
}
void
mouseMoved
()
{
penX
=
mouseX
;
penY
=
mouseY
;
drawCurrentPixel
();
}
void
draw
()
{
board
.
Draw
();
}
void
drawCurrentPixel
()
{
board
.
getPixel
(
round
(
penX
),
round
(
penY
)).
darken
(
penColour
.
multiply
(
0.5
));
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment